Skip to content

Pluggable cache admission & eviction policies (ADR 040) #1754

Closed

Description

@alpergundogdu

Pluggable cache admission & eviction policies

Status: in progress (branch claude/cdn-eviction-admission-policies-11802e, ADR 040). This is the tracking issue; the PR links here.

Problem

deCDN caches while serving (stream-while-store) but has no admission policy — every authorized miss is admitted unconditionally — and eviction is recency-only, whole-blob (no frequency/heat, not range-aware). A real CDN needs to decide what to keep and what to drop, and those decisions should be pluggable, not baked into the cache engine.

Design (ADR 040)

Signals-in / decisions-at-sweep:

  • Engine emits a hit signal and exposes generic segment primitives (set_segment / segment_of / segment_bytes). Segment membership is pure in-memory metadata; the engine holds zero policy semantics — it reads no frequency and runs no promotion.
  • AdmissionPolicy acts instantly at store time (returns the segment).
  • EvictionPolicy::plan(ctx) -> { evict, promote } is the single sweep-time decision; the driver is a dumb executor. No tag mutation between sweeps.
  • First real pair: W-TinyLFU (in-tree count-min sketch, no doorkeeper, keyed off BLAKE3) + probationary admission (mechanism C: one-hit-wonders land in a capped probation segment, promote on repeat). Defaults always + lru reproduce today's behavior.
  • Config-selectable, node-local (not governance/consensus).

Deferred / known limits

  • Range-aware eviction is blocked on an upstream iroh-blobs partial-truncation ("range-forget") primitive; v1 ships whole-blob reclaim only.
  • In-memory segment membership is lost on restart (un-capped until re-observed).
  • gc_interval_sec=0 reclaim hole and missing write-path backpressure carried forward (out of scope).

Related axes (separate issues)

  • Refuse-to-serve / stop-serving policy (economic, margin-based) — sibling to admission.
  • Load-shedding under resource pressure.

Together these three make a trustless CDN node decide, per request, whether serving is worth it — on storage, on economics, and on load.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions