Repository navigation
perf(node,cache): answer per-leaf serve presence from the held watch (#1790 item 3) - #1883
Merged
Merged
Conversation
…1790 item 3) The coherent serve encoder probed the store for presence on every 16 KiB leaf: `present_covers` → `missing_ranges` → `present_ranges` did a deny-gate check plus two store-actor hops (`status` + `observe`) before each leaf's data read — ~190 store round trips per MiB served on the miss path, bounding pull-through throughput by store-actor message rate rather than by disk or upstream bandwidth. The reader already holds a live `PresentRangeWatch` and awaits it for progress, but discarded its yielded ranges and re-probed the store instead. Fold each watch item (the blob's absolute present bitfield) into a local `present: ChunkRanges` snapshot and answer per-leaf coverage from it — a `ChunkRanges` subtraction with no store hop. The watch advances only as the pull fills, so the snapshot grows monotonically and the encoder's forward walk reads each landed leaf for free. Takedown enforcement is preserved exactly, not weakened: `NodeRangedStore::refuses` is a pure in-memory check (lock-free deny/blacklist/evict sets), folded into the local coverage test so an evicted/blacklisted hash still reads as not-present — mirroring the guard `present_ranges` applied, minus the round trip. The authoritative store probe survives only for the rare race where a fill retires between the liveness and outcome reads, and the durable-clean-end shortcut is untouched. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR improves miss-path streaming throughput in the node’s coherent serve encoder by eliminating per-leaf store presence probes and instead answering “is this leaf present?” from the already-held PresentRangeWatch snapshot (while still applying the refusal/takedown gate locally).
Changes:
- Add a local
present: ChunkRangessnapshot toAwaitingDataReaderand use it to satisfy per-leaf coverage checks without store actor round trips. - Keep refusal/takedown semantics in the fast path by checking
NodeRangedStore::refuses()alongside the snapshot coverage test. - Add a targeted unit test to validate snapshot coverage behavior and refusal gating (eviction) without requiring store presence probes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/node/src/handlers/client/serve_encoder.rs | Cache per-hash present-range snapshots from PresentRangeWatch and use them for per-leaf coverage checks; add a unit test for snapshot + refusal behavior. |
| crates/cache/src/ranged_store.rs | Expose NodeRangedStore::refuses() as a cheap in-memory gate so the node serve encoder can fold refusal into local coverage checks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.31% (was 80.30%, ▲ +2.01%) — 69479/84407 lines
History
|
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 3 of #1790 (Group C serve-path hot-path audit), landed as its own PR — same per-item cadence as #1879 (item 7, merged) and #1882 (item 5).
Problem
The coherent serve encoder's
AwaitingDataReaderprobed the store for presence on every 16 KiB leaf:present_covers→NodeRangedStore::missing_ranges→CacheEngine::present_ranges, which runs the deny-gate check plus two store-actor hops (status()+observe()) before the leaf's own data read. That's ~3 store round trips per served leaf — ~190 per MiB — so miss-path streaming throughput is bounded by store-actor message rate rather than by disk or upstream bandwidth. The gap widens as upstream bandwidth improves.The reader already holds a live
PresentRangeWatchand awaits it for progress, but it discarded the yielded ranges (.map(|_ranges| ())) and re-probed the store anyway.Fix
Fold each watch item — the blob's absolute present bitfield — into a local
present: ChunkRangessnapshot, and answer per-leaf coverage from it: aChunkRangessubtraction, no store hop. The watch advances only as the pull fills, so the snapshot grows monotonically and the encoder's forward walk reads each already-landed leaf for free. Presence now costs one watch open per serve (amortized) instead of two store hops per leaf.Takedown is preserved exactly, not weakened.
NodeRangedStore::refusesis a pure in-memory check (lock-free deny/blacklist/evict sets — no store hop), folded into the local coverage test so an evicted/blacklisted hash still reads as not-present, mirroring the guardpresent_rangesapplied. The mid-serve eviction model is unchanged: in-flight readers still drain via the durable-clean-end shortcut (untouched), new serves are still blocked at admission. The authoritative store probe survives only for the rare race where a fill retires between the liveness and outcome reads.Tests
covers_locally_answers_from_snapshot_and_refuses_takedown(new) — empty snapshot covers nothing; a snapshot including the range covers it; an evicted hash reads as not-present with no store hop.partial_overlap_shares_one_fill_and_serves_r_byte_exact(existing) — the park-then-resume coalesced serve, the strongest guard on this path, stays byte-exact.decdn-nodesuite (~780 tests) and cache suite green; clippy/doc/fmt/pre-commit clean.Remaining #1790 items
Items 1, 2, 4, 6, 8, 9 remain open as separate follow-ups (7 merged, 5 in #1882).
🤖 Generated with Claude Code