Merged
Conversation
Move validator balance lookups out of the rejection sampling loop in `compute_balance_weighted_selection` into a one-time pre-fetch. This avoids repeated SSZ Merkle tree traversals during each acceptance check, reducing `compute_ptc` time on mainnet from ~30s to ~9s per epoch (3.3x improvement). The signature of `compute_balance_weighted_acceptance` changes from `(state, index, seed, i)` to `(effective_balance, seed, i)`.
Cache three functions that call compute_balance_weighted_selection, which performs costly SSZ tree traversals for validator balances during rejection sampling: - altair: get_next_sync_committee_indices (called at sync committee boundaries) - fulu: compute_proposer_indices (called during process_proposer_lookahead) - gloas: compute_ptc (called during process_ptc_window)
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.
With #4979 merged, the testing framework generates an input state for each test and calls
initialize_ptc_window. This is computing two epochs worth of PTCs which is causing the mainnet tests to take considerably longer; ~5 hours before the change and 12+ hours after the change. On my system, it takes ~30 seconds to compute PTCs for a single epoch. This PR's goal is to speed this up. For details on each optimization, please refer to the extended description for each commit.Note: This PR is necessary to make the upcoming release. We triggered the release action yesterday but it timed out (12 hours per fork/preset combo) in the Gloas/Heze tests.