Skip to content

fix(router): swap out a sustained-bad primary leg instead of riding it forever - #4208

Merged
0pcom merged 1 commit into
skycoin:developfrom
0pcom:feat/adaptive-swap-bad-primary
Aug 26, 2026
Merged

fix(router): swap out a sustained-bad primary leg instead of riding it forever#4208
0pcom merged 1 commit into
skycoin:developfrom
0pcom:feat/adaptive-swap-bad-primary

Conversation

@0pcom

@0pcom 0pcom commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Every park/evict rule exempts leg 0 (the group must always keep a send leg), so when the primary itself is the drag — a webrtc-second-hop leg anchoring a download at ~2x the latency and a fraction of the throughput of its peers (observed live: leg 0 = 546ms/30-rtx carrying 256K while leg 1 = 311ms/15-rtx carried 917K) — no metric could act on it.

Rule (2.5): when leg 0 is a gross latency/throughput outlier for the health hysteresis and a healthy active alternative exists, DROP leg 0. It can't be parked (setLegStandby refuses idx 0), but dropping it makes dropLegsByIndex flush its in-flight window onto a healthy leg, removeLegs promote the next aux into the primary slot, and self-heal re-dial a replacement — a hot-swap of the primary with the retx buffer rescued. Guarded so a healthy or transiently-spiking primary is never swapped.

bundle.wasm regenerated; parity_test green; test covers the swap + the no-swap-on-healthy guard.

…t forever

Every park/evict rule exempts leg 0 — the group must always keep a selectable
send leg — so when the PRIMARY itself is the drag (a webrtc-second-hop leg
anchoring a download at 2x the latency and a fraction of the throughput of its
peers, e.g. observed live: leg 0 = 546ms/30-rtx carrying 256K while leg 1 =
311ms/15-rtx carried 917K), no metric could act on it and it bottlenecked every
transfer it anchored.

Add rule (2.5): when leg 0 is a gross latency/throughput outlier for
adaptHysteresis ticks AND a healthy active alternative exists, DROP leg 0. leg 0
can't be parked to standby (setLegStandby refuses idx 0), but dropping it makes
dropLegsByIndex flush its in-flight window onto a healthy leg, then removeLegs
compacts and promotes the next aux into the primary slot, and self-heal (fired
by the drop) re-dials a replacement into the reserve — a hot-swap of the primary
with the retx buffer rescued. Guarded by the healthy-alternative requirement +
its own hysteresis streak so a good or transiently-spiking primary is never
swapped; if the promoted aux is itself bad the next tick swaps again, each swap
shedding a drag until a healthy leg anchors the group.

bundle.wasm regenerated (TinyGo); parity_test green; new test covers both the
bad-primary swap and the no-swap-on-healthy-primary guard.
@0pcom
0pcom merged commit a3bad8c into skycoin:develop Aug 26, 2026
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