Skip to content

refactor(cache): unify blob ingest behind a range-aware cache API with retained partials #1607

Closed

Description

@alpergundogdu

Problem

The cache engine exposes ingest as several source-flavored entrypoints — populate, populate_local, pull_through_range, open_tee_sink, open_local_outboard_pull — plus separate read paths (get, export_bao_range_stream). Each ingest path re-implements the same store bookkeeping, and they disagree on one thing that matters: what happens to bytes already fetched when an ingest aborts.

On abort/retry the engine drops the iroh-blobs TempTag, so a partially fetched blob's bytes become GC-eligible and are reclaimed — worst case (1 + max_retries) × blob_bytes of "orphaned" bytes until the next sweep (#518). Those bytes were verified and, on a peer pull, paid for; discarding them makes a resume re-fetch and re-pay from a lower offset than necessary.

None of this is a store limitation. iroh-blobs already models partials as first-class: verified spans import as partial blobs, the store tracks exactly which chunk ranges are present, serves them via export_ranges (ADR 038), and reports a partial's on-disk size honestly. The duplication and the orphaning are policy artifacts of wiring ingest up per-source.

Intent

One source-agnostic, range-aware cache API that every producer writes through and every reader reads through:

  • admit(hash, range) — positioned, not append: a range lands at its true byte offset (sparse on disk — the last 1 GB of a 100 GB blob costs ~1 GB, not a 99 GB zero-fill). Present-ranges are a set, so disjoint interior spans are first-class.
  • read(hash, range) — completeness-aware: serve what is present, report what is missing, rather than assuming whole-blob presence.
  • hold — an explicit lease (TempTag) that protects a reader's / warmer's bytes from reclaim while it streams.
  • evict — one logical + lease-protected + deferred-reclaim path, reused for both takedown and capacity eviction. A blob evicted mid-serve keeps serving to in-flight readers; only new requests see it gone.

No orphan class. Aborted ingests are retained as resumable partials, attributed to (hash, range) and reclaimed only via eviction on the same accounting — never dropped to GC. Disk usage becomes the sum of present ranges, complete and partial alike.

Why it matters

This is the foundation that lets any fetch source share one ingest path and lets a node hold blobs far larger than RAM without re-implementing store logic per source. It is a store-layer refactor: behavior-preserving, migratable entrypoint-by-entrypoint to keep the tree green.

Out of scope

  • No source-seam changes, no payment/wire changes — that is the follow-up (unify miss sources behind BlobSource; remove max_blob_size_mb), which depends on this.
  • No admission-policy change and no max_blob_size_mb removal here.
  • No change to what a partial advertises (a partial warming copy stays unadvertised).

Activity

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

    @alpergundogdu
    ContributorAuthor

    Foundation for #1608 (unify miss sources behind BlobSource; remove max_blob_size_mb), which writes every source through this API.

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

    @alpergundogdu
    ContributorAuthor

    Context: this is the node RangedStore backend in the unified range-minimized fetch design (#1621). Its P1 query oracle — present_ranges / missing_ranges — shipped in #1609. The remaining work here (retained partials + unified admit) is what makes the node's held partials durable (not GC-reclaimed) and gap-serveable, so the gap-driven pull driver (A, #1621) can actually skip them. The trait itself lands in bao-range; this issue is its node-side impl over iroh-blobs.

  5. alpergundogdu commented on Aug 13, 2026

    @alpergundogdu
    ContributorAuthor

    Complete. The node-side range-aware cache API is on main:

    Every miss source (BackendSource, PeerSource) writes through this admit path. Closing as done.

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

Metadata

Metadata

Assignees

Labels

kind:featureprio:highrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions