Repository navigation
refactor(node): stream node-to-node pull to disk, drop the last O(blob) ingest buffer (#1682) - #1696
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…the pull thread Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eadyAdmitted Co-Authored-By: Claude Opus 4.8 <[email protected]>
…de ingest path Co-Authored-By: Claude Opus 4.8 <[email protected]>
… refused reactive top-up Co-Authored-By: Claude Opus 4.8 <[email protected]>
…e for the gap-driven pull Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-cadence consts Co-Authored-By: Claude Opus 4.8 <[email protected]>
It is now constructed on the live node-origin pull path, so the allow (and its changelog-voice reason) no longer applies. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR removes the last whole-blob in-RAM ingest path for node-to-node cache-miss pulls by porting NodeOrigin from the legacy buffered resume loop to the shared gap-driven decdn_client_pull::drive() machinery, streaming verified ranges directly into the cache store via admit_bao_stream.
Changes:
- Introduces
OriginFetch::AlreadyAdmittedto let origins admit into the store themselves and short-circuit cache re-ingest/readback paths. - Reworks
NodeOriginnode-to-node pulls to rundrive()on a dedicated blocking thread + current-thread runtime, with cancellation/settle/drain behavior mirrored from the serve-miss pull leg. - Strengthens ingest/driver correctness: typed-fault recovery for
admit_bao_streamfailures and a paid-frontier clamp againstdelivered_frontierto prevent shared-ledger concurrent pulls from “completing” gaps early.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/node_origin_pull.rs | Updates fixtures to use AlreadyAdmitted and read back from CacheEngine; adds streaming populate + cancellation/watermark tests. |
| crates/node/src/runtime/mod.rs | Wires the node’s cache engine into NodeOriginDeps so node-to-node pulls can admit directly into the store. |
| crates/node/src/node_origin/resume.rs | Deletes the legacy buffered resumable pull loop. |
| crates/node/src/node_origin/pull_leg.rs | Adapts to new settle/funder wiring and exports ABANDON_DRAIN for reuse. |
| crates/node/src/node_origin/mod.rs | Ports populate-path pull-through to gap-driven drive() + direct admission; adds cancellation/settle/drain thread model. |
| crates/node/src/node_origin/funder.rs | Moves reactive-top-up budgeting + settle cadence constants here; extends NodeFunder to meter top-up outcomes and expose “funded” signal. |
| crates/node/src/node_origin/admit_store.rs | Recovers parked typed peer faults from readers on admit failure and maps bao verification failures to typed HashMismatch. |
| crates/node/src/handlers/client/serve_encoder.rs | Updates for admit_bao_stream’s new error return shape. |
| crates/client-pull/src/pacer.rs | Updates module docs now that policy is fully unit-testable without referencing the deleted node resume loop. |
| crates/client-pull/src/driver.rs | Clamps paid completion frontier to delivered_frontier to prevent shared-ledger concurrent pulls from completing gaps early. |
| crates/cache/tests/s3_origin.rs | Adjusts tests for the new OriginFetch::AlreadyAdmitted variant (ensures S3 never returns it). |
| crates/cache/src/retry.rs | Preserves AlreadyAdmitted through retry buffering logic (no buffering needed). |
| crates/cache/src/origin/s3.rs | Extends exhaustiveness matches to include AlreadyAdmitted (documented as unreachable here). |
| crates/cache/src/origin/mod.rs | Adds OriginFetch::AlreadyAdmitted and updates helpers/debug formatting accordingly. |
| crates/cache/src/origin/fs.rs | Adjusts tests for the new OriginFetch::AlreadyAdmitted variant (ensures FS origin never returns it). |
| crates/cache/src/engine.rs | Changes admit_bao_stream to return the reader on both success and failure; short-circuits pull-through when an origin returns AlreadyAdmitted; updates tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reconcile the node-origin pull port with main's credit-slow-start ramped credit window (#1691) and fixed voucher cadence (#1676), and the present-tense comment rewrite (#1687). - Delete resume.rs (the buffered loop this branch already replaced); main only rewrote its comments. - Keep the collapsed SettleOnDrop (no SettleDeps enum / lifetime), our driver delivered_frontier completion clamp, and the AlreadyAdmitted + typed-fault-recovery ingest changes, alongside main's RampPacer rework. - Restore the AtomicBool import dropped with main's LeechPacer removal. - Resize the concurrent-resume fixture to span several VOUCHER_INTERVAL_BYTES so it still exercises mid-pull exhaustion under the ramped credit window. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 80.60% (was 80.71%, ▼ 0.11%) — 58669/72792 lines
History
|
…es contract Both bytes-less variants collect to None; AlreadyAdmitted must never yield an empty buffer that a caller could mistake for content. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
Re: the coverage report (−0.11% total, non-blocking) — the dip is understood and expected:
🤖 Addressed by Claude Code |
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.
What
Ports
node_origin's node-to-node cache-miss pull off its in-RAM whole-blob buffer onto the streaming gap-drivendrive()/NodeAdmitStorepath. After this, no ingest tier holds a whole blob in RAM — the node-to-node pull streams range-by-range to disk throughadmit_bao_stream, so a multi-GiB blob costs O(chunk-group) RSS instead of the full disk budget.Closes #1682.
Why
resume::pull_blobaccumulated the whole blob intoLoopState.buf: Vec<u8>and returned it asOriginFetch::found_one_shot(bytes)— the last O(blob) ingest path. With #1685/#1686 defaultingmax_blob_size_mbtocache_size_mb, its worst-case RSS became the entire disk budget on one pull. It buffered because its resumable-rewind + reactive-top-up loop rewound withVec::truncate; the gap-driven driver makes retry "re-derive missing ranges" instead, so the buffer disappears.How
OriginFetch::AlreadyAdmitted(new variant): the origin streams the blob into the store itself viaadmit_bao_streamand tells the engine not to re-ingest.pull_through_attemptshort-circuits to the existing post-commit tail (CommitOnly → Committed,ReturnBytes → read_local).pull_from_candidatenow runsdrive()overNodeAdmitStore+PeerSource+BudgetPacer+NodeFunder(the same machineryrun_pull_leguses), on a dedicated blocking-thread current-thread runtime becausedrive's future is non-SendvsOrigin::fetch'sSendbound. Cancellation (CancellationToken+select!), on-threadSettleOnDrop, andABANDON_DRAINmirrorrun_pull_legso a droppedfetchfuture stops the pull, persists the final watermark, and never strands a connection.admit_bao_streamnow hands the reader back on its error path (Result<R, (R, CacheError)>) andNodeAdmitStore::ingest_streamrecovers the reader's stashed typed fault (take_fault()), mapping bao verify failures to the typedHashMismatch. Without this, every mid-stream peer fault collapsed toUnreachableand reactive top-up never fired. This also repairs the same latent hole in the already-mergedrun_pull_legserve path.drive'sfill_gapclamps the gap-completion frontier to the store'sdelivered_frontier, so two concurrent pulls on one channel can't complete each other's blobs early via the shared voucher watermark. No-op on solo/CLI pulls.NodeFunder(the one seam both pull legs fund through) + a populate-path refuse-metering guard for a lying-peerCapExceeded(feat(node): reactive mid-pull deposit top-up on the node-to-node buyer leg (#1530) #1600).resumeloop (~1.1k lines) and rehomes its still-used settle-cadence constants intofunder.rs.Scope notes
max_blob_size_bytesdisk-budget ceiling,PullVerdict::OversizeClaim, andnode_pull_too_largeare kept — they gate/meter the real ceiling on the surviving path. The issue's other named deletions (BufferedTierTooLarge,buffered_tier_max_bytes) did not exist in the tree (leftovers from a closed PR).total_bytes, then thedrivepull) — the same shaperun_pull_leguses. Eliminating the redundant connection and the per-pull ephemeral runtime is tracked as Pull legs run on ephemeral per-serve runtimes, stranding shared connection drivers (HTTP + QUIC) #1675 and deliberately left for that work.Testing
Full workspace green:
cargo build,cargo clippy --all-targets,cargo fmt --check,cargo nextest run(2765 passed, 0 failed), and theanvil-e2ecompile gate. Includes a new 8 MiB streaming-populate test, a cancellation-persists-watermark test, the fault-classification/reactive-top-up regression suite, and a concurrent-pull completion test (5× stable).Known minor follow-ups (non-blocking)
node_pull_reactive_topup_refusedif a concurrent proactive refill lands with no headroom while the pull also terminates onCapExceeded(observability-only).run_pull_legserve leg does not meter a lying-peer refused top-up (pre-existing; feat(node): reactive mid-pull deposit top-up on the node-to-node buyer leg (#1530) #1600 scopes the from-zero populate pull).🤖 Generated with Claude Code