-
Notifications
You must be signed in to change notification settings - Fork 2.2k
perf(trie): batch storage proof jobs at worker level (experiment) #20210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+1,334
−754
Conversation
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
9329deb to
1ea84bb
Compare
Member
Author
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Alexey Shekhirin <[email protected]> Co-authored-by: Matthias Seitz <[email protected]>
Co-authored-by: Alexey Shekhirin <[email protected]>
#20187) Co-authored-by: Matthias Seitz <[email protected]>
Implement worker-level batching for both storage and account proofs to reduce redundant trie traversals when multiple proof requests queue up. When proof requests arrive faster than workers can process them, jobs for the same account (storage proofs) or consecutive jobs (account proofs) are now merged into single proof computations.
- Wrap DecodedMultiProof and DecodedStorageMultiProof in Arc within ProofResult for O(1) cloning when sending batched results to multiple receivers - Add debug assertions in BatchedStorageProof::merge and BatchedAccountProof::merge to validate that all batched jobs share the same Arc for multi_added_removed_keys and missed_leaves_storage_roots (critical invariants for correctness) - Unwrap Arc at extraction sites using try_unwrap for zero-cost when sole owner
- Change debug_assert to assert for multi_added_removed_keys Arc equality check in BatchedStorageProof::merge, ensuring incorrect proofs are caught in release builds, not just debug - Change BatchedAccountProof::merge to try_merge returning Result, properly handling incompatible caches by processing as separate batches instead of panicking - Add MAX_DEFERRED_BLINDED_NODES (16) limit to prevent starvation of blinded node requests under high proof load - stops batching early when limit reached - Pre-allocate deferred_blinded_nodes vectors with capacity - Remove unnecessary clone of storage_work_tx by taking reference
9bd4b62 to
9bd5a3e
Compare
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.
Problem
When proof tasks queue up in the worker pool (workers busy), each worker processes tasks one at a time. Multiple tasks for the same account result in redundant trie traversals.
Fixes #20088
Solution
Implement worker-level batching for both storage and account proofs:
Changes
Expected Impact
Reduced trie I/O and computation overhead when proof requests queue up, especially beneficial under high transaction throughput where state updates arrive faster than proof computation.