mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-10 08:08:16 -05:00
**Motivation** - fix performance issue of Bun due to sparse array, see https://github.com/ChainSafe/lodestar/issues/8519#issuecomment-3420322338 - decompose VoteTracker, same to #6945 **Description** - decompose VoteTracker to `voteCurrentIndices` `voteNextIndices` `voteNextEpochs`, data is populated on initialization, hence avoid the sparse issue in https://github.com/ChainSafe/lodestar/issues/8519#issuecomment-3420322338 - the old `null` index means not to point to any nodes of ProtoArray, we represent it as 0xffffffff (max u32) instead of null - update `computeDeltas()` benchmark to reproduce the issue and fix it in this PR. It shows bun loops is 2x faster than NodeJS for now part of #8519 **Hoodi result** - 4x-5x faster on NodeJS <img width="967" height="300" alt="Screenshot 2025-10-20 at 14 35 01" src="https://github.com/user-attachments/assets/80998967-f6d6-4179-8976-699750a1e6fe" /> - almost 30x faster on Bun <img width="1301" height="377" alt="Screenshot 2025-10-20 at 14 35 32" src="https://github.com/user-attachments/assets/eb51f6b5-2560-478f-865a-c127f1cf008d" /> - overall it shows Bun is >= 2x faster than NodeJS now but we can probably makes it better because this decomposition strategy makes it easier for a native binding (which I will give it a try next) --------- Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>