Skip to content

Serve configured-origin content efficiently per origin kind: zero-copy pass-through (fs) + prewarm-into-cache (http/s3) #1130

Closed

Description

@alpergundogdu

Summary

To serve a blob from any configured cache.origin, the node currently imports it into the cache store first. For a local fs origin that doubles storage (origin copy + cache copy on the same disk) for no benefit; for remote (http/s3) origins nothing proactively warms pinned content, so first requests pay full pull-through latency. Fix both with two complementary mechanisms, split by origin kind (a node has exactly one configured origin kind, so the gating is trivial):

1. fs origin → zero-copy pass-through

Serve bytes directly from {path}/{hex[0..2]}/{hex} — no import into the cache store.

  • Verified range streaming (ADR 038) needs the BLAKE3 bao tree. Use the sibling {hex}.obao4 if present.
  • If .obao4 is missing, compute the outboard once and store ONLY the outboard (a fraction of a percent of the blob — iroh-blobs uses 16 KiB chunk groups) — never a second copy of the data.
  • Bonus: streams from the file instead of buffering the whole blob in memory.
  • Open question / main unknown: does iroh-blobs expose file-backed / referenced entries (a blob whose bytes live in an external file the store points at)? That determines whether this is small or large.

2. http/s3 origin → prewarm into cache

Add a cache.prewarm flag: at startup/reload, fetch pinned_hashes from the remote origin into cache.

  • Opt-in, because remote prewarm costs egress (fs pass-through is free, so it's implicit; remote costs money, so it's a flag).
  • fs origins ignore prewarm — they serve pass-through (mechanism 1). So if origin.kind in {http, s3} && cache.prewarm { warm pinned_hashes }.
  • Prewarm implies pinned / eviction-excluded (no point fetching what can be evicted before it's served).
  • Validate the pinned prewarm set fits cache_size_mb (pinned content can't be evicted to make room) — deploy-time warn/fail.
  • Since pinned_hashes is already hot-reloadable, prewarm newly-added pins on decdn node reload too (this is what makes the indexer work on remote origins).

Cross-cutting

Activity

  1. altanoruc commented on Jul 20, 2026

    @altanoruc
    Contributor

    Automated triage note for a later run: this combines two independent mechanisms and leaves the fs path contingent on whether iroh-blobs supports external file-backed entries. Please split fs pass-through from remote prewarm, and for fs pin the storage/outboard API and held/probe semantics before dispatch.

  2. added this to the v0.1 milestone on Jul 28, 2026
  3. assigned and unassigned on Jul 28, 2026
  4. self-assigned this
    on Jul 29, 2026
  5. thiras commented on Jul 29, 2026

    @thiras
    Contributor

    Split completed per the triage note. #1508 landed the discovery half; #1510 lands the http/s3 prewarm half (cache.prewarm, opt-in and restart-required, fs origins skipped by design, populate_local so it never fronts USDC to a peer, plus a pinned-set-vs-cache_size_mb warning and three decdn_cache_prewarm_* metrics).

    The fs zero-copy pass-through half is now #1511. Two findings worth carrying over:

    1. The issue's open question is answered — iroh-blobs does expose file-backed entries (ImportMode::TryReference) — but it is probably the wrong route: it recomputes the hash over the whole file, ignores a published {hex}.obao4 entirely, and leaves the LRU driver able to drop a tag on a blob whose bytes are the operator's origin file.
    2. The iroh-blobs-free route works and is preferable: bao_tree::io::sync::encode_ranges_validated is generic over ReadAt/Outboard/Write and positioned-io implements ReadAt for File, so a verified header-less range streams from the data file + PreOrderOutboard<File> in O(chunk-group) RAM with no new dependency. The real work is a ReadAt/Write-generic bao-range API, a new serve tier, and deciding where a computed .obao4 is persisted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions