Skip to content

Prefer low-rtt announce relays#261

Open
marcus-pousette-hp wants to merge 3 commits into
mainfrom
fix/rtt-aware-announcer-relays
Open

Prefer low-rtt announce relays#261
marcus-pousette-hp wants to merge 3 commits into
mainfrom
fix/rtt-aware-announcer-relays

Conversation

@marcus-pousette-hp

@marcus-pousette-hp marcus-pousette-hp commented May 28, 2026

Copy link
Copy Markdown
Contributor

Prefer lower-RTT announce relays within a small DHT-distance candidate window.

In public-DHT testing this reduced average connect-open time by 117ms (~6%) and p95 connect-open time by 275ms (~11%), while selected relay RTT p95 dropped from 242ms to 37ms.

Previously the announcer used the first 3 closest replies directly, but with this PR: It keeps DHT locality by only considering the first 8 closest replies, then selects the 3 lowest-RTT candidates from that window.

The old behavior could pick high-latency rendezvous relays even when lower-latency candidates were already available nearby.

Testing

Som unit tests where added also below a Public DHT experiment was performed.

Public DHT experiment

Ran public-DHT holepunch attempts using hosted VMs, with both peers forced to firewalled: true so the consistent holepunch path was exercised.

Branch comparison, 30 attempts per branch:

Branch Success Open avg Open p50 Open p95 Data avg Data p95 Selected RTT avg Selected RTT p95
main 30/30 1857ms 1819ms 2436ms 1958ms 2481ms 75ms 242ms
fix/rtt-aware-announcer-relays 30/30 1740ms 1723ms 2161ms 1816ms 2342ms 19ms 37ms

Window comparison, 30 attempts per window:

Window Success Open avg Open p95 Data avg Data p95 Selected RTT avg Selected RTT p95 Rank avg Rank p95
3 30/30 1771ms 2340ms 1844ms 2388ms 72ms 242ms 1 2
5 30/30 1733ms 2075ms 1809ms 2121ms 32ms 97ms 2 4
8 30/30 1738ms 2066ms 1792ms 2111ms 17ms 27ms 3 7
10 30/30 1689ms 2274ms 1743ms 2357ms 14ms 25ms 4 9
12 30/30 1733ms 2292ms 1795ms 2340ms 14ms 23ms 5 10
15 30/30 1734ms 2479ms 1794ms 2527ms 13ms 23ms 7 13
20 30/30 1672ms 2043ms 1717ms 2087ms 9ms 20ms 9 19

Selected RTT is the RTT from the announcing node to the DHT nodes selected as announce/rendezvous relays.

Rank is the selected node position in closestReplies; lower rank means closer to the DHT target.

Window 8 (and what this PR chooses as the default value now), is a conservative cutoff: it captures most of the selected-RTT improvement over the current behavior, while avoiding the larger DHT-rank drift seen with bigger windows.

Co-written with AI

@marcus-pousette-hp marcus-pousette-hp requested a review from a team May 28, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant