Skip to content

client: peer-store latency folds cold-miss TTFB, so the fast path ranks nearby nodes behind the origin #2196

Closed

Description

@thiras

Observed

The client peer store (~/.decdn/client/peers/*.json) ranks nodes by latency_ms, an EWMA that folds in two different measures:

  • the probe RTT (spawn_harvest, crates/cli/src/commands/fetch.rs), and
  • the stream time-to-first-byte of every opened entry (record_sample(… header.ttfb_ms …) in the fetch path, fetch.rs about line 2565).

On a cold miss, the serving node must first pull from an upstream holder. So its TTFB includes a whole second leg, and measures the content's cache state, not the node's distance.

Peer store after a mistral-7b bundle pull, against ICMP RTT from the same host:

node region stored latency_ms ICMP RTT
fra1 DE 1051 57 ms
lon1 GB 1167 78 ms
nbg1 DE 1129 —
hel1 FI 1768 —
bcl (sole origin) US 394 ICMP blocked; transatlantic

The EU nodes were serving cold two-leg misses from bcl, so they look 15–20× slower than their RTT. bcl serves from its origin, so it looks fastest.

Impact

store_fast_path sorts candidates by this value and skips the probe round when at least MIN_FRESH_CANDIDATES samples are younger than LATENCY_TTL_SECS (10 min). A follow-up fetch or bundle entry inside that window prefers the origin node over nearby nodes that now hold the content warm. That concentrates load on the origin, and nearby caches stay unused after they fill.

Expected

The ranking signal measures the node, not the content's cache state. Options:

  • Fold only probe RTT (or handshake RTT) into latency_ms, and keep stream TTFB as a separate field or drop it.
  • Fold TTFB only from streams the node served from cache. The serve response or header can say hit or miss.

Either way, a cold miss must not rank a nearby node behind a distant origin for the next 10 minutes.

🤖 Generated with Claude Code

Activity

  1. added
    kind:bug
    prio:medium
    rust
    area:cli
    on Sep 28, 2026
  2. self-assigned this
    on Sep 28, 2026
  3. moved this from In progress to Done in deCDNon Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:bugprio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions