apollo_consensus_orchestrator: fetch backfill windows from the batcher concurrently - #14963
apollo_consensus_orchestrator: fetch backfill windows from the batcher concurrently#14963gkaempfer wants to merge 2 commits into
Conversation
…r concurrently collect_recent_block_hashes and collect_recent_state_commitment_infos run once per block on the consensus-critical finalize_decision path and previously awaited each batcher call sequentially in a loop, paying up to window_size round trips in series. Fetch the (small, bounded) windows concurrently with join_all instead, while keeping the exact same break/skip/cap semantics when processing the resolved results in order.
…backfill Make the state-commitment-infos fetch bound branch-aware instead of a generic max() so it can't silently under-fetch if either window's size changes later. Build the block-hashes height list once and reuse it for both the join_all and the zip, instead of relying on two independently-constructed ranges staying in lockstep. Rename the block-hashes window_size local to avoid colliding with the unrelated fee_proposal window_size used elsewhere in this file.
PR SummaryMedium Risk Overview For state commitment backfill, the PR also materializes the height list up front with a branch-aware fetch cap (full fallback window when the cende recorder is empty vs Reviewed by Cursor Bugbot for commit 0e907d5. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale. |
Performance follow-up to #14892
Automated performance-review routine, triggered by the merge of #14892, found a
sequential-latency issue in two backfill loops on the consensus-critical
finalize_decision/decision_reachedpath.Problem
collect_recent_block_hashesandcollect_recent_state_commitment_infoseach runonce per block and loop over a small, bounded window of heights (≤ 11 after
#14892's cap), calling the batcher once per height with a sequential
.awaitinside the
forloop:Each iteration pays a full round trip to the batcher component before the next one
starts. In a remote deployment topology (HTTP, per this repo's component-server
model) this means up to ~10-11 sequential round trips in series, on a path that
per the existing code comments "must not stall block production."
Fix
Fetch each window concurrently with
futures::future::join_all— the same patternalready used elsewhere in this file (
send_reproposal) and inbuild_proposal.rs/validate_proposal.rs— then apply the exact samesequential break/skip/cap decision logic afterward, over the resolved results in
original height order. This preserves identical observable behavior to the
sequential version (including the "skip a leading gap only when the cende
recorder is empty, but break immediately on any gap once it has a real offset"
logic) while collapsing the round trips into a couple of concurrent batches
instead of paying for each one back-to-back.
Review
An Opus subagent reviewed the diff for correctness against every branch/edge case
(empty ranges,
height = 0, the exact-11 vs exact-10 window bounds, mock-orderingassumptions in existing tests, whether the batcher calls are safe to fire
concurrently given the local component server's serial processing loop) and
flagged 4 suggestion-level findings, all addressed in a follow-up commit:
max(), so it can't silently under-fetch if either window's size changes later.join_alland the
zip, instead of relying on two independently-constructed rangesstaying in lockstep.
window_sizeusedelsewhere in this file.
Test
cargo test -p apollo_consensus_orchestrator— 200 passed, 0 failed (includingall 9
collect_recent_state_commitment_infos_sends_expected_deltacases and thecollect_recent_block_hashes/retrospective_*coverage)cargo clippy -p apollo_consensus_orchestrator --all-targets -- -D warnings— cleanscripts/rust_fmt.sh— clean🤖 Generated by an automated performance-review routine (Claude Code), triggered by the merge of #14892.
Generated by Claude Code