Repository navigation
feat: serve fs-origin blobs zero-copy without importing into the store (#1511) - #1750
alpergundogdu wants to merge 11 commits into
Conversation
…ault doc open_local_origin_reader now accumulates a last_err and only surfaces it after every origin declines, mirroring origin_fetch_outboard_bytes's fallback discipline instead of failing on the first origin's transient error. Also corrects export_bao_range_stream_from_origin's doc: a vanished local reader/outboard after the caller has committed to the zero-copy serve is a delivery fault, not a benign degrade.
… fault_seen style, atomic obao4 write
There was a problem hiding this comment.
Pull request overview
Adds a zero-copy serve path for filesystem origins: when a {hex}.obao4 pre-order outboard exists next to an origin file, nodes can stream verified bao (whole or ranged) directly from that file without importing into the iroh-blobs store. This fits the deCDN cache/miss ladder by adding an eligibility gate + a new export source while keeping the downstream framing/voucher logic unchanged.
Changes:
- Add a new
bao-rangeheader-less,ReadAt-based verified range encoder plus streaming pre-order outboard computation. - Add cache + node plumbing to gate and stream origin-backed zero-copy delivery (
ServeSource::OriginZeroCopy) while preserving existing fallback tiers. - Add
decdn origin indexto generate.obao4siblings for configured filesystem origins, plus new loopback/e2e coverage.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/client_loopback.rs | Adds loopback tests for zero-copy whole + ranged serve and a missing-outboard fallback control. |
| crates/node/src/handlers/client/dispatch.rs | Introduces the zero-copy eligibility gate and routes delivery via a new ServeSource selector. |
| crates/node/src/handlers/client/delivery.rs | Teaches deliver to stream from either store-backed export or origin-backed zero-copy export. |
| crates/e2e/tests/fs_origin_zero_copy_paid_fetch.rs | New anvil-e2e test proving paid fetches don’t import into the node store when outboards exist. |
| crates/e2e/src/node.rs | Adds a helper to kill the daemon and reopen the cache dir to check store blob presence. |
| crates/common/src/cli/origin.rs | Adds clap argument types for decdn origin index. |
| crates/common/src/cli/mod.rs | Wires the new Origin command group into the shared CLI command model. |
| crates/cli/src/main.rs | Dispatches Command::Origin to the new origin command handler. |
| crates/cli/src/commands/origin.rs | Implements decdn origin index (walk fs origins, compute+write .obao4 siblings). |
| crates/cli/src/commands/mod.rs | Registers the new origin command module. |
| crates/cli/Cargo.toml | Adds decdn-bao-range as a CLI dependency (intended to preserve the iroh-blobs-free invariant). |
| crates/cache/src/origin/mod.rs | Extends the Origin trait with open_local_reader and introduces LocalBlob. |
| crates/cache/src/origin/fs.rs | Implements open_local_reader for FilesystemOrigin with canonicalize+containment guard. |
| crates/cache/src/engine.rs | Adds the zero-copy gate (origin_zero_copy_total) and the origin-backed bao export stream. |
| crates/bao-range/src/lib.rs | Adds encode_verified_range_headerless and compute_pre_order_outboard plus unit coverage. |
| Cargo.lock | Locks the new workspace dependency wiring. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ync obao4, non-blocking child reap - cache: reject a size-mismatched origin file before emitting any frame, so a file truncated/grown between the gate and serve can't produce a partial, already-billed delivery. - cli: sync_all the .obao4 temp file before persist, matching the CLI's other atomic writers, so a power loss after rename can't leave an empty outboard. - e2e: reap the killed daemon under block_in_place so the blocking wait doesn't stall the multi-thread runtime's worker. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 80.82% (was 80.84%, ▼ 0.02%) — 59097/73123 lines
History
|
|
Closing without merging. On review, the double-store this eliminates is bounded by the store's LRU cache (
The The one case where zero-copy still wins is a blob larger than the cache (importing it thrashes the working set and it can't be cached anyway). If that becomes a priority, the right shape is a size-aware gate — zero-copy only when the blob won't fit the cache — not an unconditional replacement of the import→cache→coalesce path. Captured on #1511. The reusable building blocks (header-less |
Closes #1511.
What
A node can now serve a content-addressed blob — whole or ranged — straight from a configured filesystem origin's file (
{base}/{hex[0..2]}/{hex}+ sibling{hex}.obao4pre-order outboard), bypassing the iroh-blobs store entirely. No import, no second on-disk copy. Previously an fs-origin serve imported the blob (or a partial range) into the store first, costing two copies on the same disk for no benefit.Zero-copy engages only when the outboard already exists; otherwise dispatch falls through to today's tiers unchanged — it is a pure optimization overlay with no regression when ineligible. The node daemon never writes to the origin tree; outboards are an operator-maintained artifact generated by a new CLI.
How
bao-range— a header-less, seekable range encoder (encode_verified_range_headerless, generic overpositioned_io::ReadAt+Write) that streams a verified range straight from aFilein O(chunk-group) RAM, and a streaming pre-order outboard computation (compute_pre_order_outboard, bounded memory).cache—Origin::open_local_reader(fs override, symlink-containment guarded) yields a seekableLocalBlob;export_bao_range_stream_from_origincomposes it with the.obao4and the encoder, bridging the sync encoder to the async serve stream via a bounded channel (same stream type as the store path, soChunkFramer/vouchers are untouched);origin_zero_copy_totalis the dispatch gate.node—delivergains aServeSource { Store, OriginZeroCopy }selector; dispatch carries an authoritative total past the shared size/floor/sign tail (the existingrange_pulled_sizepattern), guards the import tiers so neither runs when zero-copy is elected, and gates the whole thing behindpull_authorized.cli—decdn origin indexwalks each configured fs origin and generates{hex}.obao4siblings (streaming compute, hash-verified, idempotent,--force, atomic write). Stays iroh-blobs-free (CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578): onlydecdn-bao-range, a leaf crate, is added.Correctness / safety
pull_authorized— an unauthorized client cannot induce origin egress or be served origin bytes. Floor-reservation, voucher, andmax_blob_size/bounds guards are shared with the store path (singledelivercaller), so no payment/authorization guard is weakened.open_local_readerreuses the same canonicalize + base-containment symlink guard as the existing fsfetch/sizemethods.Testing
Nonewithout; the origin export leaves the store empty; multi-origin fallback.origin_fetches == 1).anvil-e2e): a real paid client fetch (whole + ranged tail) against an fs-origin node leaves the node's blob store empty — proof of zero import (ran green repeatedly).Full suites green on the branch: node 897/897, bao-range + cache + cli 799/799, clippy (anti-panic gate) clean across all touched crates.
Notes for reviewers
bao-range(cosmetic).contracts/foundry.lockworking-tree change is deliberately not included.🤖 Generated with Claude Code