Repository navigation
Conversation
processRewardsAndPenalties built cache.balances from an exact-length slice, so the first balance processPendingDeposits appended for a new validator reallocated and copied the whole list (about 18.5 MB at 2.3M validators). Allocate the list with MAX_PENDING_DEPOSITS_PER_EPOCH spare capacity. The deposit loop applies at most that many deposits per epoch and each adds at most one balance, so applyPendingDeposit uses appendAssumeCapacity. Measured on a 128-block mainnet replay of silver's perf fixture (EPYC 9634, ReleaseSafe, 5 alternating rounds against main ff956b2): process_pending_deposits 4.46 -> 1.72 ms per epoch boundary, process_rewards_and_penalties unchanged (median 37.23 vs 37.13 ms).
This was referenced Oct 30, 2026
Contributor
Author
|
Moved to ChainSafe/lodestar#10523 (combined with #819) now that lodestar-z is merged into Lodestar (ChainSafe/lodestar#10513). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
processRewardsAndPenaltiesbuildscache.balanceswithfromOwnedSliceover an exact-length slice, so the list has no spare capacity. The first balanceprocessPendingDepositsappends for a new validator then reallocates and copies the whole list, about 18.5 MB on mainnet (2.3M validators). Instrumenting a 128-block mainnet replay (2 new validators):Description
Reserve room in
cache.balancesfor the deposits applied in the same epoch.processRewardsAndPenalties: allocate withinitCapacity(validator_count + MAX_PENDING_DEPOSITS_PER_EPOCH)and fill withgetAllInto. Same single allocation and fill as before.applyPendingDeposit:appendAssumeCapacity. The deposit loop applies at mostMAX_PENDING_DEPOSITS_PER_EPOCHdeposits per epoch and each adds at most one balance.Replay A/B (EPYC 9634, ReleaseSafe, 5 alternating rounds), ms per epoch boundary:
process_pending_depositsprocess_rewards_and_penalties, medianAI Assistance Disclosure
Primarily AI-authored with Claude Code.