ChainSafe / ChainSafe/lodestar
Experiment different javascript runtimes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 483
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 156
Description
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:
- Memory: as tested [here](url), Bun is very efficient to store a short Uint8Array of 32 bytes which is critical for our merkle tree. This could help unblock #5857
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 |
- Performance - deserialize a BeaconBlock:
- deserialize a BeaconBlock of 200 transactions, 500 bytes each: https://github.com/ChainSafe/ssz/blob/d7417022d15755a70b481f6f815ae08a4e685cec/packages/ssz/deserialize_beacon_block_perf_test.ts#L6
- modify 100k validators of a 2M-validator merkle tree: https://github.com/ChainSafe/ssz/blob/d7417022d15755a70b481f6f815ae08a4e685cec/packages/persistent-merkle-tree/nodejs_bun_deno.ts#L5
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
- Bun is potentially to be a candidate javascript runtime that help boost lodestar's performance, do we need other tests for it?
- One blocker for Bun is the lack of napi support, how to deal with that? https://github.com/oven-sh/bun/issues/158
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked BeaconBlock deserialization benchmark and packages/persistent-merkle-tree/nodejs_bun_deno.ts, then reproduce the Node.js, Bun, and Deno comparisons. Review the reported Uint8Array memory results and Bun's napi limitation. Done is not defined in the issue; the runtime experiments and criteria for proceeding still need agreement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, deno, nodejs, typescript
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100