Skip to content

feat(routing-policy): size the adaptive forward mux on upload (bidirectional sizing) - #4138

Merged
0pcom merged 2 commits into
skycoin:developfrom
0pcom:feat/adaptive-bidirectional-sizing
Aug 23, 2026
Merged

feat(routing-policy): size the adaptive forward mux on upload (bidirectional sizing)#4138
0pcom merged 2 commits into
skycoin:developfrom
0pcom:feat/adaptive-bidirectional-sizing

Conversation

@0pcom

@0pcom 0pcom commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

The adaptive preset's on_tick controller sized only the reverse (download) direction: it read RecvBytes deltas and widened/collapsed the mux under sustained download load, while the forward (upload) width stayed pinned at one leg. SentBytes was never read, so an upload-heavy flow could not grow its send mux.

This adds a forward controller that mirrors the reverse one, driven by SentBytes, reusing (not duplicating) the same EWMA smoothing, peak decay, saturated/idle thresholds, hysteresis and cooldown constants. On sustained upload saturation it emits a new RotationAction.AddForwardLeg; the router actuates it forward-only (appendRouteAsymmetric(addFwd=true, addRev=false) via a new addOneAuxSendLeg), so the extra send capacity does not enlarge the reverse/download set. It collapses back to the lean single forward leg when the upload goes idle. A combined desiredActive target folds the forward growth into the convergence target so the reverse park / drop-recovery rules never tear down a forward-grown leg.

When SentBytes is flat the whole forward machine stays dormant, so download-only and idle flows evolve byte-identically to before — the validated steady shape (fwd=1, rev=1 active + 2 standby) is unchanged.

Native/wazero parity: the preset wasm bundle was rebuilt with TinyGo so the native and wazero engines make identical decisions; the parity harness gained an upload sequence (AddForwardLeg verified to fire and round-trip the wire), and go test ./pkg/router/policy/... passes. New engine tests cover upload-widen, download-regression (unchanged), and idle-collapse.

Caveat surfaced in the report: the warm-standby pool is full-duplex, so a forward-only widen must dial a fresh send leg rather than promote a spare; and a send-only leg would black-hole any download the far end mis-spreads onto it — acceptable for an upload-dominant flow and pruned by the existing leg-dataprogress/liveness guards.

0pcom added 2 commits August 23, 2026 15:38
…ctional sizing)

The adaptive preset's on_tick controller sized only the reverse
(download) direction: it read RecvBytes deltas and widened/collapsed the
mux under sustained download load, while the forward (upload) width was
pinned at one leg. SentBytes was never read, so an upload-heavy flow
could not grow the send mux.

Add a forward controller that mirrors the reverse one, driven by
SentBytes: the same EWMA smoothing, peak decay, saturated/idle
thresholds, hysteresis and cooldown constants (reused, not duplicated).
On sustained upload saturation it emits a new RotationAction.AddForwardLeg
that the router actuates forward-only (appendRouteAsymmetric
addFwd=true/addRev=false, via addOneAuxSendLeg), so the extra send
capacity does not enlarge the reverse/download set; it collapses back to
the lean single forward leg when the upload goes idle. A combined
desiredActive target folds the forward growth in so the reverse
park/drop-recovery rules never tear down a forward-grown leg.

When SentBytes is flat the whole forward machine stays dormant, so a
download-only or idle flow evolves byte-identically to before. Rebuilt
the preset wasm bundle so native and wazero make identical decisions;
extended the parity harness with an upload sequence and added engine
tests for upload-widen / download-regression / idle-collapse.
@0pcom
0pcom merged commit a0ef81d into skycoin:develop Aug 23, 2026
11 of 16 checks passed
@0pcom
0pcom deleted the feat/adaptive-bidirectional-sizing branch August 24, 2026 23:45
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