perf: batch multiproof dispatch for small blocks#22082
Draft
perf: batch multiproof dispatch for small blocks#22082
Conversation
added 2 commits
February 11, 2026 18:39
For blocks with fewer than 128 state updates, buffer per-tx hashed state updates and dispatch a single merged proof request at block completion instead of dispatching per-tx proofs. This eliminates per-update overhead from: - partition_by_targets (splitting already-fetched vs not-fetched) - dispatch_with_chunking (worker availability checks + chunking) - Arc<MultiAddedRemovedKeys> clone per dispatch - crossbeam channel send/recv per dispatch - ProofSequencer sequence numbering per dispatch The multi_added_removed_keys tracking is still done per-update during buffering for correctness. Only the dispatch/partition/chunking is deferred and done once on the merged state. Falls back to per-update dispatch if the threshold is exceeded, and disables batching for BAL (Block Access List) paths which already provide complete state. Amp-Thread-ID: https://ampcode.com/threads/T-019c4dc7-32c0-76dd-a099-4966bf2717f2
Two optimizations for small-block multiproof dispatch: 1. Single-dispatch path for batched small blocks: When flushing the small-block state update batch (< 128 updates), bypass dispatch_with_chunking entirely and dispatch a single proof request. This prevents the merged state (typically ~80-100 targets) from being split into multiple chunks when chunking_len > chunk_size (60), which would partially undo the batching win. 2. Fix V2 chunk size: Use effective_multiproof_chunk_size() instead of multiproof_chunk_size() in both MultiProofTask and SparseTrieCacheTask creation. With V2 proofs enabled (default), this changes the chunk size from 60 to 240, reducing unnecessary chunking across all block sizes. Amp-Thread-ID: https://ampcode.com/threads/T-019c4de3-0cce-7083-80fd-f10b6724f5cc
Contributor
|
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.
Summary
The multiproof dispatch path sends a separate proof request per transaction state update: partition, Arc clone, chunking check, channel send, worker wakeup — repeated N times per block. For a 30-tx block, that's 30 dispatches when a single merged request would suffice. This PR buffers
HashedPostStateupdates and dispatches a single merged proof request onFinishedStateUpdatesfor small blocks (<30 state updates), falling back to per-update dispatch for larger blocks.