Repository navigation
feat(cache): range-aware present_ranges / missing_ranges query - #1609
Conversation
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ed range Co-Authored-By: Claude Opus 4.8 <[email protected]>
…mment Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
WalkthroughChangesCache range inspection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant CacheEngine
participant CacheStore
Caller->>CacheEngine: present_ranges(hash)
CacheEngine->>CacheStore: inspect status and chunk bitfield
CacheStore-->>CacheEngine: present ranges and completeness
CacheEngine-->>Caller: PresentRanges
Caller->>CacheEngine: missing_ranges(hash, byte range)
CacheEngine->>CacheEngine: validate and align span
CacheEngine-->>Caller: missing ChunkRanges
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Coverage reportTotal: 80.29% (was 80.28%, ▲ +0.01%) — 57261/71320 lines
History
|
There was a problem hiding this comment.
Pull request overview
This PR adds a range-aware “presence oracle” to decdn-cache via new additive CacheEngine query APIs, enabling future completeness-aware reads and resumable range pulls to cheaply determine what parts of a blob are already cached.
Changes:
- Introduces
CacheEngine::present_ranges(hash) -> PresentRangesto snapshot which chunk ranges are currently present (without blocking on completion). - Adds
CacheEngine::missing_ranges(hash, byte_offset, byte_len, blob_size) -> ChunkRangesto computerequested \ presentover an aligned request span. - Adds an integration test suite (with shared fixtures) covering absent/partial/complete cases and set-difference behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/cache/src/engine.rs | Adds PresentRanges type and the present_ranges / missing_ranges query methods. |
| crates/cache/src/lib.rs | Re-exports PresentRanges from the crate root. |
| crates/cache/tests/present_ranges.rs | Integration tests for presence classification and missing-range computation. |
| crates/cache/tests/util/mod.rs | Test fixtures for standing up origins and building CacheEngine instances used by the new suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let group_chunks = (aligned.fetch_end() - aligned.fetch_start()) / 1024; | ||
| assert!(group_chunks > 0); | ||
| // Whole-blob chunk count is strictly greater than what we imported. | ||
| let whole_chunks = blob_size.div_ceil(1024); |
…d 1024 Addresses PR #1609 review: avoids a magic number that could drift from the canonical block/chunk size. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Addressed the review nit in 582ec34 — |
What
Adds two pure, additive query methods to
CacheEngine, the present-range oracle:present_ranges(hash) -> PresentRanges— which chunk ranges of a blob are on disk right now (via iroh-blobs' per-blob bitfield).missing_ranges(hash, byte_offset, byte_len, blob_size) -> ChunkRanges— the chunk-aligned sub-ranges of a requested span that are not present (requested \ present).Plus the
PresentRangestype and an integration test suite.Why
This is the foundation ("Phase 1") of a range-aware cache API. A completeness-aware read (serve what's present, report what's missing) and a resumable paid-pull (re-fetch only what's absent) both need a single, cheap answer to "which ranges of this hash do I hold?". Today that reasoning is implicit and scattered; this makes it a first-class query. No existing path changes behavior — this PR is purely additive.
Notes
present_rangesclassifies absence viastatus()(BlobStatus::NotFound) and snapshots the current bitfield by awaitingobserve(hash)directly — deliberately notObserveProgress::await_completion(), which blocks until a blob is complete and would hang on a partial or absent blob.missing_rangesmirrorsexport_bao_range_stream'salign_rangeerror mapping (an out-of-range request is an argument error, not an origin fault).Tests
crates/cache/tests/present_ranges.rs— 7 tests covering absent / partial / complete classification and themissing_rangesset-difference (empty when present, whole span when absent, empty on a complete blob).cargo nextest run -p decdn-cache→ 324 passed, 0 skipped. clippy-D warnings,cargo fmt --check,cargo doc,cargo denyall clean.Follow-ups (later phases, not in this PR)
TempTag(kills the "orphan bytes" class) — gated on an iroh-blobs "can you tag an incomplete blob?" spike.admit(hash, range)writer, and collapse the read paths onto a completeness-awareread.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests