Skip to content

feat: measure link latency and prefer low-latency paths for ring hosts - #2254

Open
abendrothj wants to merge 1 commit into
exo-explore:mainfrom
abendrothj:fix/1723-latency-aware-link-selection
Open

feat: measure link latency and prefer low-latency paths for ring hosts#2254
abendrothj wants to merge 1 commit into
exo-explore:mainfrom
abendrothj:fix/1723-latency-aware-link-selection

Conversation

@abendrothj

Copy link
Copy Markdown

Addresses the link-preference half of #1723 (P2P mesh falling back to a slow path after crash/restart).

Problem

MLX ring host selection (find_ip_prioritised) chooses between candidate IPs purely by interface-type label, with a TODO: Profile and get actual connection speeds. After the crash/restart scenario in #1723, inference traffic can land on a 40–70 ms path (Tailscale/WAN) even when a sub-millisecond Thunderbolt link is available — the label heuristic has no way to notice, and VPN interfaces classify as unknown.

Changes

  • Measure RTT in the existing probe. check_reachability already makes an HTTP request to each peer interface every 10s; it now records the round-trip time of the successful request instead of discarding it.
  • Carry latency on topology edges. SocketConnection gains latency_ms. Identity is explicitly IP+port (matching the existing IP-based __hash__), so measurement jitter does not make otherwise-identical edges unequal. The worker republishes an edge (delete + create) only when latency changes materially — both >2 ms absolute and a factor-of-two — so fast-link jitter never churns the topology.
  • Prefer measured latency for ring hosts. find_ip_prioritised(ring=True) now sorts by measured latency first, using the interface-type priority (thunderbolt first) only as tie-break/fallback for unmeasured links. The RDMA coordinator path (ring=False) is unchanged. This resolves the TODO and fixes the stale docstring (which described the coordinator priority, not the ring one).

With this, after a restart where the Thunderbolt bridge comes back late: the periodic probe measures both paths, the topology reflects real latencies within ~10s, and the next placement picks the fast link by measurement rather than by label.

Not in scope

Tests

  • find_ip_prioritised: measured low latency beats a thunderbolt-labelled slow link; latency outranks labels; unmeasured links fall back to label priority; measured links beat unmeasured ones.
  • latency_changed_materially: first measurement, sub-noise-floor jitter, sub-factor-two changes, and genuine degradation (0.8 ms → 45 ms).

basedpyright, ruff, and the master/shared/utils/worker-unit test suites pass locally.


Refiled from #2215, which was closed unintentionally.

The reachability probe that already runs every 10s now records the
round-trip time of its successful request. The measured latency is
carried on SocketConnection topology edges (excluded from edge identity
so probe jitter does not churn the topology; edges are republished only
on a material change) and MLX ring host selection prefers the lowest
measured latency, falling back to the interface-type heuristic for
unmeasured links.

Previously ring hosts were chosen purely by interface-type label, so a
degraded or misclassified link (e.g. traffic falling back to a VPN path
after a crash/restart while the Thunderbolt bridge was still down) could
be selected over a healthy sub-millisecond link. Addresses the
low-latency link preference part of exo-explore#1723.
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