Skip to content

fix(relay): require 10 ms minimum RTT gain before switching relay entrances - #24

Merged
CommaBot merged 1 commit into
stillfailfrom
ember/entry-probe-min-gain
Nov 20, 2026
Merged

CommaBot merged 1 commit into
stillfailfrom
ember/entry-probe-min-gain

Conversation

@CommaBot

Copy link
Copy Markdown
Collaborator

Summary

  • Add ENTRY_MIN_GAIN = 10 ms floor to ActiveRelayActor::choose_entry: requires an alternate relay entrance to beat the current entrance by both >= 10 ms (current.saturating_sub(*best_rtt) >= ENTRY_MIN_GAIN) and the existing > 20% relative margin (best_rtt * 5 < current * 4) across the two-round hysteresis before recording a candidate or switching entrances.
  • Why: On local loopback (< 1 ms RTT) or low-RTT regional links under normal Wi-Fi / worker scheduling jitter (2–6 ms on median-of-3 sequential WebSocket pings), a pure relative 20% check treats sub-millisecond or few-millisecond noise as a candidate (self.candidate = Some(...)), repeatedly resetting adaptive backoff (300 s -> 30 s) and occasionally churning the live relay WebSocket between equivalent entrances.
  • Tests & Docs:
    • entry_probe_noise_only_difference_keeps_backoff_to_300s: paused-clock live-socket test (+5 ms vs 0 ms, >90% relative difference but < 10 ms absolute) verifying zero candidate resets, zero socket churn, and full 30 -> 60 -> 120 -> 240 -> 300 -> 300 s backoff.
    • choose_entry_requires_both_min_gain_and_relative_margin: boundary unit test covering sub-ms noise, 30 ms -> 22 ms (8 ms < 10 ms), 60 ms -> 49 ms (11 ms >= 10 ms but < 20%), and 30 ms -> 19 ms (both satisfied -> candidate + 2-round switch).
    • Updated STILLFAIL.md.

@CommaBot
CommaBot force-pushed the ember/entry-probe-min-gain branch from eb9a1bb to 74fea64 Compare November 20, 2026 18:38
@CommaBot
CommaBot merged commit a602f4d into stillfail Nov 20, 2026
2 of 4 checks passed
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