Skip to content

feat(node): unify miss sources behind BlobSource; remove max_blob_size_mb #1608

Closed

Description

@alpergundogdu

Problem

A node has three cache-miss ingest paths, and only one is a problem:

Path Memory today
Origin backend (s3/http/fs) O(chunk) — streams into the store
Serve/window pull-through (the #915 "tee") O(chunk) — streams into the store
Cache-miss warm/buyer leg (stream_fetch_shared) O(blob) — buffers the whole blob

The warm/buyer leg is the lone buffered outlier. #1600 halved its peak (~2× → ~1× in RAM) but it still holds the whole blob. max_blob_size_mb (1 GiB default) exists largely to bound that RAM — so a node with 2 GB RAM and 2 TB disk cannot warm a blob bigger than its memory, even though its disk could hold it many times over. The buffering buys nothing: BLAKE3/bao verifies every 16 KiB chunk group against the root as it lands (ADR 038), so integrity is already incremental — holding the whole blob adds only cost.

A CDN that advertises large-file delivery should not cap a blob at memory size.

Intent

Treat "fetch from a peer" and "fetch from my own backend" as the same operation with a swapped source. Introduce a BlobSource seam with two impls:

Both write through the shared range-aware admit path (the cache-API foundation issue), so every source streams to disk at O(chunk-group) memory. The warm/buyer leg's in-memory buffer then disappears.

With memory off the table, remove max_blob_size_mb entirely and make admission a disk decision: the ceiling is cache_size_mb (the disk knob we already have), and warm-concurrency reserves the blob's actual size — a peer signs total_bytes up front, so admission is a precise pre-check, not a worst-case cap. Capacity eviction reuses the foundation's logical + lease-protected eviction path.

Vocabulary

This de-overloads "origin". The OriginAssignment network role (a node authorized to serve a namespace, ADR 002) stays "origin". The ingest trait — today named Origin but actually a backend adapter — becomes BlobSource.

End state

A node serves or warms any blob its cache budget can hold, from any source, at O(chunk-group) memory. Genuinely larger files arrive as application-layer manifests of many blobs (ADR 002), unchanged. Includes updating ADR 003 §Two-tier deposit and the max_blob_size_mb config docs.

Depends on

The range-aware cache API foundation (the shared admit path). This work layers on top of it.

Out of scope

  • No bao-direct store import (kept as a future optimization; we unify at the plaintext seam so backend and peer share one code path).
  • No change to serve/export, DHT routing, or the namespace/origin-role model.
  • No new large-file manifest format.

Activity

  1. added
    kind:feature
    design:adr
    rust
    on Aug 5, 2026
  2. alpergundogdu commented on Aug 5, 2026

    @alpergundogdu
    ContributorAuthor

    Depends on #1607 (the shared range-aware admit path). This work layers on top of it.

  3. alpergundogdu commented on Aug 5, 2026

    @alpergundogdu
    ContributorAuthor

    Land PeerSource in client-pull, not node, so the CLI legs collapse onto it too

    One scope note before this is picked up. As written this is feat(node) and PeerSource reads as NodeOriginDeps-bound. But the paid resume / reactive-top-up loop that moves inside PeerSource is the same loop the CLI hand-rolls in two more places:

    cli depends on client-pull, not on node. So if PeerSource is built in the node crate, those two legs still can't call it and keep their own copies of the loop — #1599 stays a third hand-written copy even after this lands.

    Ask: put PeerSource (or the paid-pull driver it wraps — open_progressive_pull + content_paid_frontier + genuine_exhaustion + the top-up/settle-wait/reseed arms) in client-pull, the one crate both node and cli already depend on. Keep the node-specific bits (NodeOriginDeps, metrics, deps.buyer.top_up_channel) behind a small Funder trait the node implements, so client-pull stays chain-handle-agnostic.

    Then the source/sink split is clean and shared across both binaries:

    Net: reactive top-up becomes a property of PeerSource, and all three paid consumers get it by depending on PeerSource + choosing a sink — instead of the two hand-parallel loops we have now (fetch.rs + node_origin/resume.rs) becoming three. Origin serve stays on BackendSource and correctly has no top-up (no channel to top up).

    Doesn't change this issue's intent or the #1607 → #1608 sequencing — just fixes the crate the seam lands in so #1599 closes as a call-site rather than a third copy.

  4. self-assigned this
    on Aug 5, 2026
  5. alpergundogdu commented on Aug 5, 2026

    @alpergundogdu
    ContributorAuthor

    Context: this is the Source axis (node side) of the range-minimized pull (#1621). BlobSource/PeerSource fill the gaps the driver (A) computes via missing_ranges, writing through #1607's admit. The lean CLI precursor — routing bundle pull through fetch's streaming top-up loop (no new driver) — merged as #1612; the full BlobSource seam + max_blob_size_mb removal is still this issue. Depends on #1607.

  6. alpergundogdu commented on Aug 13, 2026

    @alpergundogdu
    ContributorAuthor

    Closing — split. The core intent (unify miss sources behind one BlobSource writing through the shared admit path) is done: BackendSource (own-origin, Flow A #1655) and PeerSource (paid peer, in client-pull) both ingest through NodeRangedStore/admit_bao_stream at O(chunk-group) memory. The warm/buyer in-memory buffer is gone.

    The one remaining deliverable — remove max_blob_size_mb and make admission a disk decision — is now the whole of a simpler focused issue: #1678. (Re-anchored: after the payment-pool rewrite #1667 the ADR edit targets the refundable-floor M policy, not the retired two-tier deposit.) Tracking there.

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

Metadata

Metadata

Assignees

Labels

design:adrkind:featurerust

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions