ChainSafe / lodestar

🌟 TypeScript Implementation of Ethereum Consensus
https://lodestar.chainsafe.io
Apache License 2.0
1.19k stars 293 forks source link

Experiment different javascript runtimes #7237

Open twoeths opened 2 hours ago

twoeths commented 2 hours ago

Problem description

So far we only run lodestar with NodejS. The goal is to experiment other javascript runtimes like Bun and Deno to see if lodestar performs better there. I had different benchmark for them:

Number of bytes used to store an Uint8Array of 32 bytes

- NodeJS 22.4.1 Bun 1.1.34 Deno 2.0.5
Uint8Array(32) 241.74 47.35 200.65

Here's my result on a Mac M1:

- NodeJS 22.4.1 Bun 1.1.34 Deno 2.0.5
Deserialize a BeaconBlock 0.25ms 0.11ms 0.719ms
Modify 100k nodes of 2M merkle tree 23.86ms 4.727ms 15.889ms

to run the NodeJS, I used the tsx and it's worth to note by @nazarhussain that Typescript overhead is almost negligible in case of Bun, ~10% in case of Deno and 100% in case of TSX/TS-Node

Solution description

Based on the test results I'd like to discuss how to go from there

Additional context

No response

twoeths commented 2 hours ago

also note the result run by @nazarhussain here:

For such comparisons we should avoid typescript complexity. I run it over the build JS files and got different results. But yet Bun is the winner. 

Node: 9.1ms 
Deno: 8.2
Bun: 3.71

One other observation is that Typescript overhead is almost negligible in case of Bun, ~10% in case of Deno and 100% in case of TSX/TS-Node