Skip to content

feat(node): FillRegistry-backed admission reservation — gated on the #1678 metrics #1681

Closed as not planned

Description

@yigitdot

Problem

Since #1678 removed max_blob_size_mb, cache.cache_size_mb is the node's disk budget and the eviction driver is its sole enforcer. Enforcement is entirely after the fact: nothing reserves disk before a fill starts, so N concurrent fills can collectively commit far more than the budget and stay over it until the driver sweeps — and then until the GC sweep actually reclaims (#520).

#1678 deliberately did not build an admission controller. It shipped the instrumentation to find out whether one is needed.

Gate — do not build this until the metrics say so

Build only if, under real load:

  • decdn_cache_bytes + decdn_cache_fill_in_flight_bytes regularly exceeds decdn_cache_size_limit_bytes, and
  • decdn_cache_pending_reclaim_bytes stays elevated across several gc_interval_sec periods rather than spiking and draining.

If the footprint tracks the budget and pending-reclaim drains between sweeps, eviction is sufficient and this issue should be closed unbuilt. Note decdn_cache_fill_in_flight_bytes over-estimates on purpose (whole total_bytes per live session, not covered range), so it errs toward reporting pressure that has not arrived — a small excursion is not evidence.

Also check decdn_node_fill_size_*: if fills are almost all in the le_1mib bucket, no plausible burst threatens a 10 GiB budget and this is not worth building.

Design if it is warranted

A reservation charged with the signed total_bytes — a provider commits to it before delivery, so admission is a precise pre-check rather than a worst-case cap.

Charge once per hash, by refcount. Coalescing is per-hash (FillRegistry::claim), so a hash-keyed refcount reproduces "charged once" exactly. Two concurrent same-hash misses share one pull and must not double-charge; a naive per-request reservation gets this wrong and refuses the second.

Do not push it into FillRegistry::claim itself — that makes claim fallible and couples the ADR 038 registry to disk policy. A separate node-side type keyed the same way is enough, and total_in_flight_bytes() already proves the map walk.

Sketch:

pub enum AdmitDenied {
    /// total_bytes alone exceeds the whole budget — no eviction or waiting helps.
    ExceedsBudget { total_bytes: u64, budget_bytes: u64 },
    /// Would fit an idle node; concurrent fills hold the budget.
    Contended { total_bytes: u64, reserved_bytes: u64, budget_bytes: u64 },
}

Check ExceedsBudget before Contended so an oversized blob always gets the durable answer regardless of current load. RAII guard released on drop, mirroring ObserverLease (fill_session.rs) — its armed flag is the pattern for making explicit release and Drop idempotent.

Wire mapping

  • ExceedsBudget → ServeRejectReason::BlobTooLarge → StreamError::BlobTooLarge. Already the meaning feat(node): remove max_blob_size_mb — make blob admission a disk decision #1678 gave it ("does not fit my disk budget"), and ADR 005 §Retry behavior already says do-not-retry-this-node-but-try-another.
  • Contended → a new ServeRejectReason::DiskContended → StreamError::Overloaded. Must not collapse to NotFound (negative-cached for the full TTL) and must not reuse BlobTooLarge (a full-TTL DurableMiss at node_origin/mod.rs), which would be wrong for a load spike. The requester side already treats Overloaded as transient — no changes needed there.

Out of scope

History

Split out of #1678, which removed the memory-era blob cap and made admission a disk decision.

Activity

  1. added
    kind:feature
    rust
    prio:low
    on Aug 14, 2026
  2. added a commit that references this issue on Aug 14, 2026
  3. yigitdot commented on Aug 14, 2026

    @yigitdot
    ContributorAuthor

    Closing as won't-do.

    This was gated on the instrumentation shipped in #1683 — build the reservation only if decdn_cache_bytes + decdn_cache_fill_in_flight_bytes regularly exceeded the limit and decdn_cache_pending_reclaim_bytes stayed elevated. That instrumentation has been removed from #1683 as out of scope for a PR about deleting max_blob_size_mb, so there is no evidence path left to decide this.

    The admission model stands as the simple gate already in place: a blob is admitted if it fits cache.cache_size_mb; eviction reconciles the rest. That is documented in adr/appendix-blob-cache-eviction.md.

    Reopening this needs the same thing it always did — evidence that concurrent fill bursts overshoot the budget faster than the eviction driver reclaims. The design sketch in the issue body (charge once per hash by refcount, ExceedsBudget before Contended, Overloaded rather than NotFound on contention) stays valid if that evidence ever shows up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:featureprio:lowrust

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions