Skip to content

Proposal: remove speculative prefetch #1396

Closed

Description

@alpergundogdu

Summary

Delete the speculative prefetch feature entirely: the operator-policy mechanism by which a node pre-acquires (pulls and warm-caches) a blob it does not hold, triggered by DHT FIND_VALUE query frequency crossing a threshold. Nodes would no longer acquire content speculatively at all. Content propagation would rely solely on the cache-miss pull-through path already driven by real, paid cdn/client/v1 demand (plus explicit operator pinning).

This is a proposal for discussion, not a decision. It is spec'd mainly in ADR 022 § Popularity Signals and Market Dynamics (the #### Prefetch Decision block and the "Recommended configuration" table), with satellite references in ADR 037 and appendix-observability.md § Prefetch Metrics.

Note this is distinct from cache-miss pull-through and from ADR 037 proxy warming — both of which are reactive (driven by an in-flight paid StreamRequest) and are explicitly kept. Only speculative acquisition goes away.

Motivation

  1. DHT prefetch does not improve locality. The prefetch demand signal is DHT FIND_VALUE query frequency. A FindValueRequest carries only a hash — it has no region or locality information, and Kademlia routes it to nodes closest to the hash in keyspace, which has nothing to do with where the requesting clients are. So prefetching on DHT popularity pre-acquires globally-hot content onto keyspace-positioned nodes, not onto nodes near the clients that want it. It does not place content closer to demand; ADR 037's reactive window-paced pull-through is what actually warms a regional copy, and it already supersedes the local cache-miss prefetch trigger.

  2. It's overengineering given cache-miss pull-through already exists. When a paying client's cdn/client/v1 StreamRequest misses cache, the node pulls the range from an upstream and warm-caches it as a paid, loss-bounded side effect of delivery. That already covers content propagation on the real demand path — content that clients actually pay for gets cached where it is served. Speculative acquisition adds a second, parallel acquisition path whose only job is to guess at demand the paid path handles on its own. ADR 022 itself already states the reactive path "supersedes any local cache-miss prefetch trigger," so the remaining DHT-popularity trigger is the odd one out.

  3. The feature carries real, load-bearing surface for a speculative benefit — and one of its four defenses just evaporated:

    • an opt-in config block (prefetch.enabled, default false);
    • a spend circuit-breaker (prefetch.budget_usdc_per_hour);
    • a demand-quality auto-throttle (prefetch.demand_quality_min_ratio / _window_secs);
    • an authorized-origin Sybil gate (prefetch.require_authorized_origin) that no longer functions: the namespace-origin redesign (Redesign origin addressing: namespace-as-address, drop per-hash claims and the default-open allow-list #1394, PR docs(adr): namespace-as-origin-addressing, drop per-hash claims and default-open allow-list #1395) deleted the on-chain hash→namespace (namespaceOf) lookup the gate relied on to decide whether a FIND_VALUE candidate was an authorized origin for the hash. With the gate gone, the two Sybil attacks ADR 022 § Threat model describes (demand-only and demand-supply) are now defended only by a spend budget and a served/acquired ratio — a much weaker posture for a feature whose upside is already covered by the paid path. Rather than redesign the Sybil gate around namespace-keyed routing, the simpler move is to drop the speculative acquisition it was protecting.

What removal touches

ADRs / docs

  • adr/022-content-discovery.md — the bulk:
    • ### Popularity Signals and Market Dynamics intro paragraph (rewrite to reactive-only).
    • #### Prefetch Demand Signal: DHT FIND_VALUE Query Frequency (Non-Suppressible) — delete.
    • #### Prefetch Decision, its ##### Threat model, ##### Recommended configuration table, and ##### Scope and limits — delete (keep the "cache-miss pull-through warm-caches unconditionally" statement, which belongs to the reactive path).
    • #### Local cache-miss demand is reactive, not prefetched — keep the substance, drop the framing that contrasts it against a prefetch trigger that no longer exists.
    • Acceptance Criteria 7 (prefetch trigger) and 8 (prefetch demand signal metric) — remove/rewrite; AC 8's cache-miss-frequency metric can stay as pure observability.
    • "Interaction with Existing Protocols" rows for NodeAnnounce and Proxy warming reference the prefetch signal — reword.
  • adr/037-regional-proxy-warming.md — the pull_through_require_authorized_origin knob is documented as reusing "the prefetch gate's OriginDirectory / namespace-0 / fail-closed semantics"; that cross-reference needs a new home (or the gate semantics move here) since the prefetch section is going away. AC 9 (latency-probe sentinel hash "not counted toward any node's prefetch demand signal") also references the signal.
  • adr/appendix-observability.md § Prefetch Metrics — delete the whole subsection (~11 metrics: decdn_prefetch_enabled, decdn_prefetch_acquisitions_{authorized,unauthorized,bypassed}_total, decdn_prefetch_spend_usdc_total, decdn_prefetch_budget_exhaustion_events_total, decdn_prefetch_origin_gate_rejections_total, decdn_prefetch_demand_quality_ratio_milli, decdn_prefetch_throttle_active, decdn_prefetch_acquire_{succeeded,failed,timeout,dropped_saturated}_total).

Config keys (entire [prefetch] block)

prefetch.enabled, prefetch.require_authorized_origin, prefetch.budget_usdc_per_hour, prefetch.find_value_threshold, prefetch.threshold_window_secs, prefetch.demand_quality_min_ratio, prefetch.demand_quality_window_secs, prefetch.max_concurrent_acquisitions, prefetch.acquisition_timeout_secs.

Rust (blast radius from grep -ri prefetch crates/)

  • crates/node/src/prefetch/ — the whole module, ~1,329 lines across mod.rs, decision.rs, acquirer.rs, popularity.rs, acquired.rs (PrefetchEngine, PrefetchAcquisitionObserver, the popularity window, the decision/throttle logic).
  • crates/common/src/config/ — types.rs (PrefetchConfig), resolved.rs (ResolvedPrefetch), mod.rs (validation + defaults; ~64 references).
  • crates/node/src/runtime/mod.rs — heaviest wiring site (~65 references): PrefetchEngine::new, provision_acquirer, the prefetch_shutdown CancellationToken, the armed_origin_gates_over_empty_fallback helper (shared with the pull-through gate — needs to keep the pull-through half), and shutdown cancellation. reload.rs too.
  • crates/node/src/metrics.rs — the ~11 prefetch metrics above (set_prefetch_enabled, set_prefetch_quality, counters).
  • crates/node/src/handlers/dht.rs — feeds the FIND_VALUE popularity signal into the engine.
  • crates/node/src/node_origin.rs and crates/node/src/handlers/client/{mod,voucher,dispatch}.rs — acquisition_observer hook + serve-path crediting.
  • crates/node/src/dht/origin.rs / chain_origin_directory.rs — the OriginDirectory the prefetch gate consulted (shared with pull-through; keep the pull-through consumer).
  • crates/cli/src/commands/config.rs — config surfacing/validation for the [prefetch] block.
  • Tests — crates/node/tests/{node_origin_pull,dht_loopback,sighup_signal,anvil_bringup_shutdown_e2e}.rs, crates/cli/tests/config_validate.rs, and the runtime/mod.rs unit tests for armed_origin_gates_over_empty_fallback.

Rough order of magnitude: ~26 Rust files reference prefetch, dominated by the ~1.3k-line prefetch/ module plus config + runtime wiring.

Alternatives / what we keep

  • Cache-miss pull-through (reactive, paid). Unchanged. A cdn/client/v1 StreamRequest that misses cache still pulls the range from upstream and warm-caches it. This is the real demand path and the primary content-propagation mechanism after removal.
  • ADR 037 regional proxy warming (reactive, window-paced). Unchanged and actually the locality story — it warms a regional copy on real paid demand and STOREs on commit so the copy becomes DHT-discoverable. This is what the locality argument in Motivation §1 points at.
  • Operator pinning. Unchanged. Operators who want a specific blob resident cache it explicitly (see appendix-blob-cache-eviction § Operator pinning overrides LRU). This is the intended replacement for "namespace-0 content gets no prefetch ever" — the ADR already tells operators to pin such content.
  • The pull_through_require_authorized_origin gate (ADR 037). Should survive removal; it currently borrows the prefetch gate's OriginDirectory / namespace-0 / fail-closed semantics, so those semantics need to be re-homed rather than deleted.
  • DHT discovery itself (ADR 022 core). Untouched — FIND_VALUE/STORE routing, provider discovery, and STORE-on-commit all stay. Only the speculative acquisition driven off the FIND_VALUE frequency signal is removed.

Open questions

  1. Metrics compatibility. Do we drop the decdn_prefetch_* series outright, or keep decdn_prefetch_enabled reporting a constant 0 for one release so scrape configs don't error? (The appendix already frames these as a "uniform schema for disabled nodes.")
  2. Config compatibility. Reject a [prefetch] block as an unknown key (current deny_unknown_fields behavior would fail the node), or accept-and-warn for a deprecation window so existing operator configs don't hard-fail on upgrade?
  3. Where do the shared origin-gate semantics live? pull_through_require_authorized_origin and the armed_origin_gates_over_empty_fallback helper currently lean on the prefetch section/module. Move the OriginDirectory / namespace-0 / fail-closed spec into ADR 037, or into ADR 022's cache-role subsection?
  4. FIND_VALUE popularity as pure observability. Keep emitting FIND_VALUE-frequency (and cache-miss-frequency) as metrics for demand visibility even though nothing acts on them, or drop the popularity-window bookkeeping entirely?
  5. Interaction with Redesign origin addressing: namespace-as-address, drop per-hash claims and the default-open allow-list #1394. Should this be sequenced after the namespace-origin redesign lands (since docs(adr): namespace-as-origin-addressing, drop per-hash claims and default-open allow-list #1395 already neutralized the origin gate), or can the prefetch removal proceed independently and in parallel?

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions