Skip to content

feat(cache): report progress and stop early in a streamed admit - #2903

Merged
alpergundogdu merged 2 commits into
mainfrom
cache-admit-until
Nov 16, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
cache-admit-until

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Fourth step of moving the decdn gateway cache onto decdn-cache (#2881, after #2884, #2886, #2887). The gateway's Streamer will fill a store backed by CacheEngine. 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_until takes an AdmitControl:

    • on_progress is called after each verified chunk group with the end of the verified prefix (a byte offset into the blob).
    • stop_at is 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 returns AdmitEnd::Stopped.

    Progress is published before stop_at is read, the same order ClientRangedStore uses, so a steal knows where the leg ends.

  • admit_bao_stream is 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

  • New: progress reports each chunk group's end, and a drained admit is complete.
  • New: an end lowered into the third of eight groups stops the admit after that group. Exactly that prefix is present and protected by one tag.
  • cargo nextest run -p decdn-cache -p decdn-node: pass.
  • cargo clippy --workspace --all-targets --all-features and -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

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]>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_until with AdmitControl (on_progress, stop_at) and AdmitEnd (Drained, Stopped).
  • Keep existing admit_bao_stream behavior by delegating to the new API with default (no-control) settings.
  • Refactor post-decode bookkeeping into settle_admit and 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

Comment thread crates/cache/src/engine.rs Resolved
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main a6405f5 cache-admit-until 9af7a2e +/-
77% 77% 0%
View coverage of the 4 most impacted files.
File main a6405f5 cache-admit-until 9af7a2e +/-
crates/protocol/src/framing.rs 93% 92% -1%
crates/client/src/scheduler.rs 94% 94% 0%
crates/node/src...s/client/mod.rs 92% 92% 0%
crates/cache/src/engine.rs 91% 91% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants