Repository navigation
feat(cache): report progress and stop early in a streamed admit - #2903
Conversation
admit_bao_stream_until takes an AdmitControl: on_progress sees the end of the verified prefix after each chunk group, and stop_at is an end the caller can lower mid-admit. A stopped admit keeps and protects its verified prefix and returns AdmitEnd::Stopped. admit_bao_stream runs it with no control. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A moderate-severity active issue remains in crates/cache/src/engine.rs where AdmitControl relies on chunk_ranges being a single contiguous prefix but ChunkRanges may be multi-span, risking incorrect progress reporting and unexpected stop_at behavior unless the invariant is validated up-front.
1 open issue
What changed in this PR
Extend decdn-cache streamed admit to support gateway-style streaming by reporting verified-prefix progress and allowing an in-flight admit to stop early while still retaining/protecting the verified prefix.
Changes:
- Add
CacheEngine::admit_bao_stream_untilwithAdmitControl(on_progress,stop_at) andAdmitEnd(Drained,Stopped). - Keep existing
admit_bao_streambehavior by delegating to the new API with default (no-control) settings. - Refactor post-decode bookkeeping into
settle_admitand add tests for progress reporting, drained admits, and early-stop semantics.
| File | Description |
|---|---|
| crates/cache/src/lib.rs | Re-exports the new streamed-admit control and result types (AdmitControl, AdmitEnd) from the crate root. |
| crates/cache/src/engine/tests.rs | Adds tests covering per-chunk-group progress callbacks, full drain behavior, and early-stop semantics ensuring the verified prefix is retained and protected. |
| crates/cache/src/engine.rs | Implements admit_bao_stream_until with progress reporting and dynamic early-stop via AdmitControl, and factors post-decode work into settle_admit. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 4 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Fourth step of moving the
decdn gatewaycache ontodecdn-cache(#2881, after #2884, #2886, #2887). The gateway'sStreamerwill fill a store backed byCacheEngine. Its lanes lower each range's end when another lane steals the remainder, and its reader wakes on each verified chunk group. The cache's streamed admit supports neither yet. This PR adds both to the cache.What changes
CacheEngine::admit_bao_stream_untiltakes anAdmitControl:on_progressis called after each verified chunk group with the end of the verified prefix (a byte offset into the blob).stop_atis an end the caller can lower while the admit runs. Once the prefix reaches it, the admit stops, keeps and protects that prefix as a whole admit does, and returnsAdmitEnd::Stopped.Progress is published before
stop_atis read, the same orderClientRangedStoreuses, so a steal knows where the leg ends.admit_bao_streamis unchanged for its callers. It runs the new call with no control.The post-decode bookkeeping moved into a helper,
settle_admit, so the function stays under clippy's length limit. Its behavior is unchanged.Tests
cargo nextest run -p decdn-cache -p decdn-node: pass.cargo clippy --workspace --all-targets --all-featuresand-p decdn-cache --no-default-features --all-targets, with warnings denied,cargo doc --workspace --no-deps --document-private-items,cargo fmt --check: pass.🤖 Generated with Claude Code