Repository navigation
perf(cache,node): batch admit-time outboard capture into one wake (#1790 item 7) - #1879
Merged
Merged
Conversation
item 7) The admit path captured proof nodes one at a time, firing the per-hash `captured` notify per node. Every parked serve leg for that hash then woke once per node in the admitted range — a wake storm that scaled with proof-node count and was worst exactly where content is popular (many attached readers). Add `HashOutboard::capture_many` / `FillSession::capture_many`: write the whole admit's pairs under one lock acquisition, then `notify_waiters` once. A single `write_pair` helper backs both the single- and batch-node forms, so capture semantics stay identical. Switch the two admit-time loops — `admit_bao_stream`'s post-import capture and `seed_held_outboard`'s held-range seed — to the batched form. Wakeups per admit drop from N-readers × N-nodes to N-readers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR reduces serve-path wakeup churn during cache admits by batching outboard proof-node capture into a single lock acquisition and a single Notify wakeup per admit, rather than waking parked readers once per captured node.
Changes:
- Add batched outboard capture (
HashOutboard::capture_many/FillSession::capture_many) to write many proof-node pairs under one lock and notify once. - Switch admit-time outboard capture in the cache engine to the batched API.
- Switch held-range proof seeding in the node serve path to the batched API, and add tests to validate batch capture behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/node/src/handlers/client/window.rs | Use batched outboard capture when seeding held-range proof nodes to avoid per-node wakeups. |
| crates/cache/src/fill_session.rs | Introduce shared write_pair helper plus capture_many, and add tests covering batch capture + wake semantics. |
| crates/cache/src/engine.rs | Use capture_many in admit-time proof capture to collapse N proof-node notifies into one per admit. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.28% (was 82.27%, ▲ +0.01%) — 69319/84244 lines
History
|
Copilot review: `write_pair` returned `true` for any interior node even when the offset→usize conversion saturated or the slot fell outside the buffers, contradicting its doc and notifying waiters despite storing nothing. Return `true` only once both the hash bytes and the captured flag — the exact state `try_load` reads back — are set; bail early on a non-addressable offset. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This was referenced Aug 31, 2026
Merged
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.
Closes item 7 of #1790 (Group C serve-path hot-path audit). Landed as its own PR, matching the per-item cadence of the #1792 siblings.
Problem
The miss/fill path captures proof nodes one at a time.
admit_bao_streamloops over an admitted range'soutboard_pairs, callingFillSession::captureper node; eachcapturefires the per-hashcapturednotify_waiters(). Every parked serve leg for that hash therefore wakes once per node in the admitted range. The wake count scales with proof-node count, and it is worst exactly where content is popular — many attached readers — so popularity converts directly into wakeup churn (and, until #1790 items 2/8 land, into global-registry-mutex acquisitions).A second instance of the same loop lives in the node's
seed_held_outboard(held-range proof seeding).Fix
Add
HashOutboard::capture_many/FillSession::capture_many: write the whole admit's pairs under one lock acquisition, thennotify_waitersonce. A sharedwrite_pairhelper backs both the single-nodecaptureand the batch form, so capture semantics (idempotent overwrite, leaf ignored, slot bookkeeping) are identical. The notify fires only if at least one internal node was written.Both admit-time loops switch to the batched form:
engine.rsadmit_bao_streampost-import capturewindow.rsseed_held_outboardheld-range seedWakeups per admit drop from N-readers × N-nodes to N-readers.
Tests
capture_many_round_trips_each_internal_node— a batched capture lands every pair a per-node loop would; a serve reader reads back the whole tree.load_awaits_then_resolves_on_capture_many— a parked reader wakes from the batch's single notify.Full cache suite (399) and node suite green;
cargo clippy --workspace,cargo fmt --check, and the anvil-e2e compile gate all clean.Not in this PR
The other 8 items of #1790 remain open as separate follow-ups. Investigation notes: item 1 is partly already fixed (attach path already skips the allocation); items 2+8 want a per-hash registry lock designed together (item 8's literal fix as written would reopen the #1610 resurrection race); items 4+7 share the admit block, but 7 stands alone cleanly; item 9 is the larger architectural change (overlap discovery with channel funding).
🤖 Generated with Claude Code