Repository navigation
perf(cache): capture serve proof nodes during import, drop the export_bao read-back (#1790 item 4) - #1886
Merged
Conversation
…_bao read-back (#1790 item 4) `admit_bao_stream` imported a verified range via iroh-blobs' `import_bao_reader`, then re-read the whole range back out through the store actor with `export_bao` (`outboard_pairs`) solely to recover the outboard proof nodes for the coupled serve leg. That doubled store-actor traffic per admit — the range's bytes crossed the actor twice — and the node's own fills competed with its serves for the one store actor, delaying `captured` wakeups and widening miss-path inter-chunk gaps. `import_bao_reader` already decodes the wire into `BaoContentItem`s internally but discards them, so drive the decode here instead: run `bao_tree`'s `ResponseDecoder` directly over the header-less wire, forward each item to the lower-level `import_bao` handle, and collect the `Parent` items — which ARE the proof nodes — in the SAME pass. One decode, proof captured for free, no read-back. This also deletes the feeder channel, the spawn, the 8-byte size-prefix injection, and `ChannelRecvStream` (the decoder reads the trusted `total_bytes` size from `BaoTree` directly), and the `import_bao` item queue backpressures so memory stays O(one item). Error classification is preserved: a decode `InvalidData` is a corrupt-upstream `VerifyFailed`, a short/truncated feed or store fault is `Store`, and the reader is still handed back on both arms so the node ingest path can recover a parked typed peer fault. `outboard_pairs` stays for its other caller (held-range seeding in `window.rs`, which has no import wire to decode). Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR optimizes the cache miss/fill admit path by capturing outboard proof nodes during streamed BAO import, eliminating a redundant post-admit export_bao read-back through the store actor (issue #1790 item 4). This reduces store-actor contention on the fill axis while preserving serve-leg behavior by ensuring identical proof availability for coupled serves.
Changes:
- Reworks
CacheEngine::admit_bao_streamto drivebao_tree’sResponseDecoderdirectly and feed decodedBaoContentItems intoimport_bao, capturingParentitems as proof nodes during the same decode pass. - Removes the previous feeder-channel + spawned import task +
ChannelRecvStreamadapter and the size-prefix injection workaround. - Adds a new test validating that proof captured during import matches what
export_baoread-back would have produced.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.40% (was 82.31%, ▲ +0.08%) — 69581/84444 lines
History
|
Copilot review: the new `NonZeroU64` guard turned every `total_bytes == 0` into a Store error, but iroh-blobs' `import_bao_reader` (the path this replaced) treated the canonical empty hash as a no-op success. Restore that: `hash == Hash::EMPTY` with size 0 returns `Ok(reader)` (nothing to decode, import, or protect); a zero size under any other hash stays a Store fault (an upstream inconsistency between the signed `total_bytes` and a non-empty content hash — the same class the old path returned, not a bao verify failure). Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Item 4 of #1790 (Group C serve-path hot-path audit). Items 7, 5, and 3 are merged; this is the deepest of the remaining items and the natural partner to item 3 — it de-loads the store actor on the fill axis the way item 3 did on the read axis.
Problem
admit_bao_streamimported a verified range via iroh-blobs'import_bao_reader, then re-read the whole range back out through the store actor withexport_bao(outboard_pairs) solely to recover the outboard proof nodes for the coupled serve leg. So every admit with a serve leg attached crossed the store actor twice — write, then read-back — and the node's own fills competed with its serves for the one store actor, delayingcapturedwakeups and widening miss-path inter-chunk gaps.Fix
import_bao_readeralready decodes the wire intoBaoContentItems internally but discards them. So drive the decode here instead: runbao_tree'sResponseDecoderdirectly over the header-less wire, forward each item to the lower-levelimport_baohandle, and collect theParentitems — which are the proof nodes — in the same pass. One decode, proof captured for free, no read-back.Bonus: this deletes the feeder channel, the spawned import task, the 8-byte size-prefix injection, and the whole
ChannelRecvStreamadapter (the decoder reads the trustedtotal_bytessize fromBaoTreedirectly). Theimport_baoitem queue backpressures, so memory stays O(one item). Net −46 lines.Behavior preserved:
InvalidDatais a corrupt-upstreamVerifyFailed; a short/truncated feed or store fault isStore.readeris still handed back on both result arms so the node ingest path can recover a parked typed peer fault.outboard_pairsstays for its other caller (held-range seeding inwindow.rs, which has no import wire to decode).Tests
admit_bao_stream_captures_proof_into_the_session_during_import(new) — proves the captured proof set equals exactly what theexport_baoread-back would have recovered, so a serve leg reads back an identical outboard.admit_bao_stream_rejects_corrupt_bao(existing) — confirms theVerifyFailedclassification survives the decoder change.partial_overlap_shares_one_fill_and_serves_r_byte_exact(node, existing) — the end-to-end park-then-resume coalesced serve, byte-exact.#1790 status
7, 5, 3 merged; 4 (this PR) and 1 (#1884) open; 6 closed as already-considered (documented). Remaining: 2+8 (registry re-layout — modest at current scale, per my sizing note) and 9 (architectural, cold-miss only).
🤖 Generated with Claude Code