Repository navigation
fix(client,cli): rank peer-store latency by probe RTT only (#2196) - #2202
Merged
Merged
Conversation
The peer store's `latency_ms` EWMA folded every stream open's time to first byte alongside the probe RTT. On a cache miss that time includes the serving node's own upstream work, so after a bundle pull the nearby EU nodes read 1-1.8 s against a 57-78 ms RTT and the sole origin ranked first on the probe-less fast path for the next 10 minutes. Only probes now feed `latency_ms`. A stream open goes through `PeerStore::record_open`: it files the quoted rate and clears the failure stamp, but folds no latency and stamps no freshness. Both first-open sites in `decdn fetch` share `record_first_open`, which now logs a failed peer-store write with the peer and outcome. `UpstreamPullHeader::ttfb_ms` had no other reader and is removed. ADRs 037, 012 and 039 state that only probe round trips feed the RTT map. Closes #2196 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Serialize or merge record_open updates to prevent stale writes, and correct the ADR TTL references.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
Updates peer-store latency ranking to use probe RTT only, avoiding cold-cache stream latency from skewing peer selection.
Changes:
- Adds
record_openfor stream price and failure bookkeeping. - Removes
UpstreamPullHeader::ttfb_ms. - Updates fetch logic, tests, snapshots, changelog, and ADRs.
| File | Summary | Review status |
|---|---|---|
crates/node/src/node_origin/backend_source.rs |
Updates header construction. | No final comment. |
crates/client/tests/snapshots/public_api__public_api.snap |
Regenerates the public API snapshot. | No final comment. |
crates/client/src/streamer.rs |
Updates test headers. | No final comment. |
crates/client/src/source.rs |
Updates scripted source headers. | No final comment. |
crates/client/src/peer_store.rs |
Adds stream-open bookkeeping. | Critical concurrency issue requires changes. |
crates/client/src/lib.rs |
Removes ttfb_ms. |
No final comment. |
crates/client/src/driver.rs |
Updates driver test headers. | No final comment. |
crates/cli/src/commands/fetch.rs |
Records stream-open outcomes. | No final comment. |
CHANGELOG.md |
Documents the ranking fix. | No final comment. |
adr/039-multi-source-parallel-fetch.md |
Documents stream-open behavior. | No final comment. |
adr/037-regional-proxy-warming.md |
Documents probe-only RTT ranking. | Nit: references a nonexistent setting. |
adr/012-client.md |
Updates peer-store behavior. | Nit: references a nonexistent setting. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit e3ad1b1 in the Show a line coverage summary of the most impacted files.
Updated |
… ADRs Each peer-store mutation reads a whole record and writes it back, so a stream open racing the off-path probe harvest could write back a record read before the probe sample landed, dropping the only latency input. A process-wide lock now serializes upsert_identity, record_sample, record_open, record_failure and prune_and_cap. A new test runs concurrent samples and opens and checks no sample is lost (12/100 survived without the lock). ADRs 037 and 012 named a `rtt_map.staleness_secs` knob that does not exist; they now name the fixed `LATENCY_TTL_SECS` (600 s) and say a stale entry is skipped by the fast path until a probe re-samples it, not evicted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What
The client peer store's
latency_msEWMA folded each stream open's time to first byte alongside the probe RTT. On a cache miss that time includes the serving node's own upstream work, so it measures the content's cache state, not the node's distance. After a bundle pull the EU nodes read 1–1.8 s against a 57–78 ms RTT, and the sole origin (bcl) ranked first onstore_fast_pathfor the next 10 minutes (LATENCY_TTL_SECS).latency_ms(issue option 1).PeerStore::record_open(node_id, rate_per_mb): sets the quoted rate and clears the failure stamp; folds no latency, stamps no freshness; no-op for an unknown peer.record_first_openindecdn fetchis now the single path for the preludescoredclosure and both multi-source lane sites; a failed peer-store write logsnode_idand outcome at debug.UpstreamPullHeader::ttfb_mshad no other reader and is removed fromdecdn-client(public API snapshot regenerated).Closes #2196
Reviewer notes
probe.rs), so it includes the handshake; the transportrtt()is one round trip. Mixing both in one EWMA reintroduces a unit bias.LATENCY_TTL_SECSafter the last probe, not the last stream, so the next fetch takes the identity-fresh re-probe tier (no registry read). That re-probe is what lets warm nearby caches win again.spawn_harveststill drops its peer-store write results withlet _ =; ADR 039:90 says per-lane outcomes are not persisted, butsettle_drivepersists a failure stamp; ADRs 037/012 cite artt_map.staleness_secsknob that does not exist (the TTL is theLATENCY_TTL_SECSconstant).Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client -p decdn-cli -p decdn-node: 2693 passed (origin_range_pull::mid_blob_open_behind_a_paying_owners_frontier_attachesflaked once, passed on retry; unrelated path)cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(peer_store_probeless)': passedINSTA_UPDATE=always cargo nextest run -p decdn-client --features public-api-test: snapshot regeneratedRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemspre-commit run --all-filesCHANGELOG.mdentry addedrecord_open_files_rate_and_clears_failure_without_touching_latency,record_open_on_unknown_peer_is_a_noop,successive_samples_fold_by_ewma,stream_opens_do_not_rank_near_nodes_behind_the_origin,failed_first_open_suppresses_the_peer~/.decdn/client/peers/*.json)🤖 Generated with Claude Code