perf(zakura): trim bbr fill-loop overhead#453
Merged
Conversation
evan-forbes
marked this pull request as ready for review
July 3, 2026 23:57
Author
|
this might be duplicate to some of what @p0mvn found and was working on, apologies if so, happy to close |
evan-forbes
marked this pull request as draft
July 4, 2026 00:26
evan-forbes
marked this pull request as ready for review
July 4, 2026 00:43
ValarDragon
approved these changes
Jul 4, 2026
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
CPU profiles during fast sync showed avoidable overhead in two Zakura block-sync paths:
BbrState::has_fresh_bdponly needs to know whether fresh BDP samples exist, but it recomputed BDP by scanning both BBR sample windows on every byte-mode fill-loop iteration.BlockSyncReactor::trace_sync_stateran expensive peer, floor-gap, and work-queue diagnostics on every sequencer view change, including per-commit progress updates.Solution
WindowedSamplesset sohas_fresh_bdpis an O(1) freshness check instead of two window scans.Instantthrough slot and byte-headroom checks, avoiding repeatedInstant::now()calls and keeping one iteration internally consistent.The per-view trace rows are deliberately diagnostic-light: fields that require registry/work-queue walks, such as
outstandingand queue/needed/slot summaries, are sampled on detailed periodic rows instead of every sequencer view change.This complements #437: that PR reduces no-op sequencer view wakeups, while this PR reduces the CPU cost of legitimate wakeups and fill-loop iterations.
Validation
cargo fmt --all -- --checkgit diff --checkcargo test -p zebra-network bbrcargo check -p zebra-network --all-targetscargo clippy -p zebra-network --all-targets -- -D warningsgit merge-treeagainst the working-tree commit andorigin/pr/437Issue
No linked issue.
AI Disclosure
Used Codex to implement the BBR freshness fast path, reduce per-view trace diagnostics, compare with #437, run validation, and draft/update this PR description.