Skip to content

feat(node): remove max_blob_size_mb — make blob admission a disk decision (#1678) - #1683

Closed
yigitdot wants to merge 3 commits into
mainfrom
feat/1678-disk-admission
Closed

yigitdot wants to merge 3 commits into
mainfrom
feat/1678-disk-admission

Conversation

@yigitdot

@yigitdot yigitdot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1678.

What changed

cache.max_blob_size_mb existed to bound RAM, back when the warm/buyer leg buffered a whole blob. Since the range-aware admit path (#1607/#1608) that leg streams to disk at O(chunk-group), so the cap only stopped a node from holding a blob its disk could easily fit — a 1 GiB default sized for memory refusing a 2 GB blob on a node with 2 TB of disk.

The knob is gone, along with its CLI flag/env (--max-blob-size-mb / DECDN_MAX_BLOB_SIZE_MB), the max_blob_size_mb < cache_size_mb startup invariant, and the serve-side and buyer-side BlobTooLarge gates. cache.cache_size_mb is now both the disk budget and the admission ceiling.

Admission, not delivery

A resident blob is always served. The old serve-side gate refused blobs already in the store, which burned the storage cost and then declined the revenue for it. StreamError::BlobTooLarge survives with a narrower meaning: "I could not take this in", never "I have it but will not send it".

The cache engine keeps its cap, retargeted to cache_size_mb. It guards the one ingest path with no signed size ahead of the bytes — an origin backend can misstate or omit its length, where a paid provider commits to total_bytes up front and the body streams to disk.

The admission model is deliberately simple: a blob is admitted if it fits cache_size_mb; the eviction driver reconciles the rest. Nothing reserves disk before a fill starts, so a burst of concurrent fills can overshoot the budget until the driver catches up — documented in adr/appendix-blob-cache-eviction.md. An up-front reservation was considered and dropped (#1681, closed won't-do).

Two things reviewers should look at

1. cache_size_mb = 0 is now rejected at startup. The budget became load-bearing, and the engine cap has no "unlimited" sentinel — a zero budget is a 0-byte cap that refuses every blob, the opposite of what 0 reads as to an operator.

2. The buffered miss tier keeps a ceiling, in memory rather than disk. resume::pull_blob still accumulates the whole blob into LoopState.buf — it is the last O(blob) ingest path, and max_blob_size_mb was its only bound (as CHANGELOG.md and ADR 037 already recorded). Sizing it off a 10 GiB disk budget would be a category error, so it is bounded by cache.origin_retry.buffered_max_bytes (4 MiB default) instead. Blobs above that fall to the streaming window tier — a live behaviour change on that tier. Porting the loop off the buffer is #1682.

Commits

  1. 5cb8def8 — the knob removal itself.
  2. e8dc161a — removes ~300 lines of cache observability the first commit carried (decdn_cache_pending_reclaim_bytes, decdn_cache_evicting, decdn_cache_fill_in_flight_bytes, the decdn_node_fill_size_* ladder, and the advance_latch extraction behind them). It was added as the alternative to building an admission reservation, which is a separate concern from deleting the knob. crates/cache/src/metrics.rs, crates/cache/src/fill_session.rs, crates/node/src/runtime/eviction.rs, and adr/appendix-observability.md are byte-identical to main as a result.
  3. f5067538 — drops a redundant paragraph from ADR 003. The section already states the worst-case exposure is small against the reserve M, and the Credit Window section below covers pool drawdown; a third restatement added no constraint.

Reviewing commit-by-commit is the easier read — 2 and 3 are pure deletions.

Kept deliberately: the FillOutcome classification split (for_cache_error / is_reportable_fill_error / classify_fill_error). It is justified by FillOutcome::TooLarge, a knob-removal change, not by the metrics — removing it would mean re-adding #[allow(clippy::cognitive_complexity)] to both fill functions.

Also worth noting

FillOutcome::TooLarge is new. Without it the engine refusal would have degraded to a wire NotFound, sending clients to re-pay elsewhere with no signal; BlobTooLarge is what ADR 005 §Retry behavior defines as "do not retry this node, a different node may accept it".

decdn fetch --max-blob-mb is unaffected, but now enforced in the CLI rather than in the requester — the CLI is the layer that owns the user disk.

Verification

  • cargo nextest run --workspace — 2776 passed, 0 failed
  • cargo clippy --workspace --all-targets -- -D warnings — clean (CI-exact)
  • cargo fmt -- --check, cargo doc --no-deps — clean

Docs updated: ADR 002 (no protocol size limit), ADR 003 (voucher-interval negotiation), ADR 005 (BlobTooLarge enforcement, probe interaction, retry semantics), ADR 037 (deposit-guard prose), appendix-blob-cache-eviction.md, docs/runbook.md, config template, CHANGELOG. Several of those carried stale claims that cache_size_mb was unenforced — untrue since the #1173 eviction driver.

🤖 Generated with Claude Code

…sion (#1678)

`cache.max_blob_size_mb` existed to bound RAM, back when the warm/buyer leg
buffered a whole blob. Since the range-aware `admit` path (#1607/#1608) that
leg streams to disk at O(chunk-group), so the cap only stopped a node from
holding a blob its disk could easily fit — a 1 GiB default sized for memory
refusing a 2 GB blob on a node with 2 TB of disk.

The knob, its CLI flag/env, and the `max_blob_size_mb < cache_size_mb`
invariant are gone. `cache.cache_size_mb` is now both the disk budget and the
admission ceiling, and gains a non-zero floor: it became load-bearing, and the
engine's cap has no "unlimited" sentinel, so a zero budget would refuse every
blob rather than disable the check.

Admission, not delivery. A resident blob is always served — the old serve-side
gate burned the storage cost and then declined the revenue for it. The engine's
cap is kept and retargeted, because it guards the one ingest path with no
signed size ahead of the bytes: an origin backend can misstate or omit its
length, where a paid provider commits to `total_bytes` up front.

`resume::pull_blob` is the exception and keeps a ceiling, in memory rather than
disk. It is the last ingest path holding a whole blob in RAM, so it is bounded
by `cache.origin_retry.buffered_max_bytes` — sizing it off a 10 GiB disk budget
would be a category error. Blobs above it fall to the streaming window tier;
porting that loop off the buffer is #1682.

No admission reservation ships here. Eviction remains the sole enforcer, and
this adds the instrumentation to find out whether that is enough:
`decdn_cache_pending_reclaim_bytes` (reclaim lag — already tracked in
`DriverState`, never exported), `decdn_cache_evicting`,
`decdn_cache_fill_in_flight_bytes`, and a `decdn_node_fill_size_*` ladder.
#1681 is pre-written for if they show bursts outrunning reclaim; making GC
on-demand, which would close the lag directly, stays blocked upstream (#520).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.82% (was 80.83%, ▼ 0.01%) — 59599/73745 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 91.82% 3536/3851 ● 0.00%
crates/cache/src/error.rs 51.85% 14/27 ● 0.00%
crates/cache/src/origin/fs.rs 78.38% 591/754 ● 0.00%
crates/cache/src/origin/http.rs 84.76% 395/466 ● 0.00%
crates/cache/src/origin/mod.rs 47.19% 42/89 ● 0.00%
crates/cache/src/origin/s3.rs 89.36% 546/611 ● 0.00%
crates/cache/src/retry.rs 80.26% 187/233 ● 0.00%
crates/cli/src/commands/config.rs 85.76% 530/618 ▲ +0.05%
crates/cli/src/commands/fetch.rs 30.97% 323/1043 ▼ 0.03%
crates/client-pull/src/lib.rs 89.65% 1447/1614 ▼ 0.11%
crates/client-pull/src/source.rs 90.56% 259/286 ▲ +0.21%
crates/common/src/config/mod.rs 97.10% 6823/7027 ● 0.00%
crates/common/src/config/resolved.rs 100.00% 33/33 ● 0.00%
crates/e2e/src/client.rs 0.00% 0/456 ● 0.00%
crates/node/src/handlers/client/dispatch.rs 83.37% 346/415 ▼ 0.39%
crates/node/src/handlers/client/fill.rs 69.44% 75/108 ▲ +3.61%
crates/node/src/handlers/client/mod.rs 88.60% 746/842 ▲ +0.01%
crates/node/src/handlers/client/window.rs 75.66% 317/419 ▲ +0.13%
crates/node/src/metrics.rs 95.34% 1024/1074 ● 0.00%
crates/node/src/node_origin/mod.rs 91.00% 971/1067 ▼ 0.01%
crates/node/src/node_origin/pull_leg.rs 86.57% 664/767 ▼ 1.08%
crates/node/src/node_origin/resume.rs 92.29% 515/558 ▼ 0.54%
crates/node/src/runtime/mod.rs 46.76% 1090/2331 ▲ +0.04%
crates/node/src/runtime/reload.rs 96.38% 1652/1714 ▼ 0.01%
History
Commit Total Δ vs base
5cb8def 80.83% ● 0.00%
f506753 (HEAD) 80.82% ▼ 0.01%

The knob removal shipped alongside ~300 lines of cache observability
(`decdn_cache_pending_reclaim_bytes`, `decdn_cache_evicting`,
`decdn_cache_fill_in_flight_bytes`, the `decdn_node_fill_size_*` ladder, and
`FillRegistry::total_in_flight_bytes` behind them). None of it is about
`max_blob_size_mb`. It was added as the alternative to building an admission
reservation — instrumentation to decide #1681 later — which is a separate
concern from deleting the knob.

`advance_latch` goes with it. It would still be used after the gauges are
removed, so it is not dangling, but it was extracted out of `tick` solely to
make the `evicting` gauge testable: a refactor that exists only to serve the
metrics goes when the metrics go. `crates/cache/src/metrics.rs`,
`crates/cache/src/fill_session.rs`, `crates/node/src/runtime/eviction.rs`, and
`adr/appendix-observability.md` are now byte-identical to main.

The `FillOutcome` classification split stays. It is justified by
`FillOutcome::TooLarge` — a knob-removal change — not by the metrics; removing
it would mean re-adding `#[allow(clippy::cognitive_complexity)]` to both fill
functions.

The admission model is unchanged and is what the docs now describe: a blob is
admitted if it fits `cache_size_mb`, and eviction reconciles the rest. #1681 is
closed as won't-do — with the metrics gone there is no evidence path left to
decide it. #1682 (port `resume::pull_blob` off its in-memory buffer) is
unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The paragraph restated what the section above it already establishes — the
line under the risk table, and the `Credit Window` section that follows, both
cover how far a pool may be drawn before nodes stop serving it. Saying it a
third time in the voucher-interval discussion added no constraint.

The replaced sentence's actual job is done by what remains: interval
negotiation carries per-voucher overhead, and blob size is not a payment-side
bound at all.
@alpergundogdu

Copy link
Copy Markdown
Contributor

Superseded by #1686 (closes #1685). Rather than remove max_blob_size_mb, we keep the knob node-configurable and change its default from a fixed 1 GiB to cache_size_mb. That gets the same out-of-the-box 'disk is the ceiling' behavior without the serve/buyer gate removal, the wire-semantics rework, or the forced RAM re-plumb. Closing unmerged; the branch stays if anything here is worth cherry-picking.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(node): remove max_blob_size_mb — make blob admission a disk decision

2 participants