Repository navigation
refactor(cli): route bundle pull through the streaming top-up loop - #1612
Conversation
|
Warning Review limit reached
Next review available in: 43 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 (4)
WalkthroughBundle pulls now stream blobs into per-hash staging files. The files support resumed downloads and materialization retries. Shared fetch code validates resumed prefixes and exposes streaming APIs for bundle use. ChangesStreaming bundle pull
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant BundlePull
participant fetch_blob_streaming
participant Provider
participant StagingFile
participant materialize_group
BundlePull->>fetch_blob_streaming: fetch blob with staging path
fetch_blob_streaming->>Provider: stream blob and request top-ups
Provider-->>fetch_blob_streaming: blob chunks
fetch_blob_streaming->>StagingFile: write or resume partial data
fetch_blob_streaming-->>BundlePull: completed staged fetch
BundlePull->>materialize_group: read staged blob for destinations
materialize_group-->>BundlePull: success or retained staging file
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.32%, ▼ 0.02%) — 57060/71065 lines
History
|
There was a problem hiding this comment.
Pull request overview
This PR refactors decdn bundle pull to reuse the same streaming paid-pull loop as decdn fetch (fetch_blob_streaming), enabling mid-fetch reactive top-ups and keeping memory usage O(1) by streaming verified chunk groups directly to disk. The old buffered fetch_blob path (and its write_blob_atomic helper) is removed, and bundle pull now stages each distinct hash to a per-hash .partial file before materializing to destination paths via atomic copy/link fan-out.
Changes:
- Route
bundle pullblob transfers throughfetch_blob_streaming, including resumed-prefix verification via a sharedverify_resumed_prefix. - Replace in-memory fan-out with a per-hash staging file and atomic materialization/link-or-copy to all destination paths.
- Remove the buffered
fetch_bloband the now-deadwrite_blob_atomichelper/test.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/node/tests/node_origin_pull.rs | Updates test documentation to reflect CLI moving off the buffered fetch_blob path. |
| crates/client-pull/src/lib.rs | Updates docs about the byte_offset == 0 retry wrapper now being exercised primarily by test-only callers. |
| crates/cli/src/commands/fetch.rs | Makes streaming fetch primitives reusable by bundle pull; deletes buffered fetch + atomic writer helper; adds verify_resumed_prefix. |
| crates/cli/src/commands/bundle_pull.rs | Implements staging-file-based bundle pulling and atomic materialization/link fan-out; adds staging cleanup helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
decdn bundle pull buffered each blob via fetch_blob and had no reactive top-up. It now streams every blob through the same fetch_blob_streaming loop decdn fetch uses (#1497), into a per-hash staging file under out_root/.decdn-partial/, and materializes to each destination path by atomic file-copy — so bundle pull gains reactive mid-fetch top-up AND O(1) memory (no whole-blob Vec). Both CLI commands now share one paid-pull loop; the buffered fetch_blob (and the now-dead write_blob_atomic) are deleted. Once-per-hash fetch-and-pay, per-provider open locks, dedup, and skip-existing are unchanged. A staging file is left in place on error (resume, same contract as fetch's .partial) and removed on success. The node keeps its own separate loop (node_origin/resume.rs) — to re-evaluate later. Co-Authored-By: Claude Opus 4.8 <[email protected]>
deee443 to
33badd1
Compare
What
decdn bundle pullnow streams every blob through the same paid-pull loopdecdn fetchuses (fetch_blob_streaming), instead of the bufferedfetch_blob. Sobundle pullgains reactive mid-fetch top-up (#1497) and O(1) memory (no whole-blobVec). Both CLI commands now share one loop; the bufferedfetch_bloband the now-deadwrite_blob_atomicare deleted.How
Per distinct blob hash,
bundle pullstreams into a staging fileout_root/.decdn-partial/<hex>.partial, then materializes to each destination path by atomic file-copy (first path copied, the rest hard-linked/copied from it — the existing fetch-once/link-rest #1306 invariant, now over a file source instead of aVec).Preserved exactly: once-per-hash fetch-and-pay, per-provider open locks,
buffer_unorderedconcurrency, dedup, skip-existing-destinations.Money-correctness: a staging file is left in place on any fetch or materialize failure, so a rerun resumes from the paid prefix rather than re-fetching (re-paying) from zero; it's removed only when every destination landed. (An independent review caught an earlier version that deleted staging on total-materialize-failure — fixed.)
Scope
CLI only. The node keeps its own separate paid-pull loop (
node_origin/resume.rs) — a deliberate choice (the loops differ on sink shape, funder, logging, and persistence); converging it would trade the duplication for several trait objects, to be re-evaluated separately.Verification
All clean.
Follow-ups
crates/e2e/tests/cli_fetch_topup.rsthroughbundle pull(a manifest blob larger than the initial deposit tops up and completes). The loop is already covered by thefetche2e suite; this would additionally exercise the staging/fan-out under a real top-up.fetch_blob_streaminglimitation (affectsdecdn fetchtoo): a complete.partialwhose blob size is an exact multiple ofCHUNK_GROUP_BYTESresumes atbyte_offset == total_bytes, which the serve gate answers asNotFound, triggering a full restart + re-pay. Not introduced here; tracked for a focused fix.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes