You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dash-spv): ByteLimiter cap runs away on slow peers on refactor/network-mod, starving header sync #1220
On refactor/network-mod (#902) at 748816fe, the global in-flight cap runs away upward when peers are slow. Requests then queue tens of seconds deep at the peers, and header sync, which only gets the room the bulk classes leave, slows to a crawl.
Root cause
Both sides of the cap adjustment in ByteLimiter::tick feed on the queue the limiter itself builds:
The base RTT is derived from the queue.rtt() is in_flight / rate, not a measured round trip, and base_rtt is the minimum of that over the last BASE_RTT_TICKS (30s). A standing queue older than 30s becomes the new base, so bdp = rate * base_rtt grows with it, queued = in_flight - bdp stays under high, and the cut branch never fires.
The growth step scales with RTT. Adjustments happen once per period = 2 * rtt / tick, and step = CAP_STEP_BYTES_PER_SEC * peers * since_adjust * tick_s. At a 14s estimated RTT with 3 peers that is about 43 MB per step.
Slow peers raise the queue, which raises the RTT estimate, which raises both the base and the step, which raises the queue.
Evidence
Mainnet full sync, run 1 of a dev vs refactor/network-mod benchmark (2026-10-26), 3 peers delivering 0.3-0.5 MB/s each:
The cap went from 4.5 MB to 94 MB in one minute while the link carried under 1 MB/s. Per-request send-to-answer latency reached 13-25s average (peer latency: ... avg=17259ms max=30372ms). Headers took 546s against dev's 203s in the same round. A better-connected round still showed 27-41 MB in flight at 4-10 MB/s and headers at 166s against dev's 48s.
Fix direction
Measure base RTT from actual request round trips (the per-peer Latency already records send-to-answer times) rather than from in_flight / rate, and bound the additive step independently of RTT.
Reopening: this was closed by the #902 merge, but its fix (993f6436) was reverted by 8825d726 before the merge, including MAX_STEP_SECS, so the runaway is on dev at 8dde9d0c.
At dash-spv/src/network/manager.rs, the base RTT is again the 30s minimum of in_flight / rate (:521, :547), the adjust period is 2 × rtt (:551), the step is multiplied by the ticks since the last adjust (:555), and the limited check at :575 uses that inflated step, so it always passes.
Evidence (testnet, 39eef40d).
The global cap jumped 10.4 to 67.4 MB at t=78s (rate 0.7 MB/s, rtt 15.3s) and 3.9 to 99.1 MB at t=219s (rate 0.2 MB/s, rtt 29.1s), both while the cap was not binding.
A stdlib port of ByteLimiter::tick fed the logged per-peer series reproduces both in one adjustment: 11.2 to 67.9 MB (151 ticks since the last adjust) and 2.9 to 99.6 MB (258 ticks).
With only MAX_STEP_SECS = 2 added back (base still from Little's law), the largest single growth is 3.0 MB and the run peaks stay at 10.9 and 12.8 MB.
Caveat. The model replays real traffic, so it shows the jumps go away, not the resulting throughput. The revert's mainnet bench tested the bound together with the min-RTT base and blamed the base. The bound alone also slows the ramp when rtt is over 1s, which goes against the stated aim that a far peer ramps as fast as a near one. It should be benched on mainnet on its own. A better base RTT signal is still needed to keep in-flight near one bandwidth-delay product. Header requests queued behind the oversized backlog are #1235.
Activity
fix(dash-spv): base the in-flight caps on the measured minimum latency
Revert "fix(dash-spv): base the in-flight caps on the measured minimu…
xdustinface commentedon Oct 28, 2026
Reopening: this was closed by the #902 merge, but its fix (
993f6436) was reverted by8825d726before the merge, includingMAX_STEP_SECS, so the runaway is on dev at8dde9d0c.At
dash-spv/src/network/manager.rs, the base RTT is again the 30s minimum ofin_flight / rate(:521,:547), the adjust period is 2 × rtt (:551), the step is multiplied by the ticks since the last adjust (:555), and thelimitedcheck at:575uses that inflated step, so it always passes.Evidence (testnet,
39eef40d).ByteLimiter::tickfed the logged per-peer series reproduces both in one adjustment: 11.2 to 67.9 MB (151 ticks since the last adjust) and 2.9 to 99.6 MB (258 ticks).MAX_STEP_SECS = 2added back (base still from Little's law), the largest single growth is 3.0 MB and the run peaks stay at 10.9 and 12.8 MB.Caveat. The model replays real traffic, so it shows the jumps go away, not the resulting throughput. The revert's mainnet bench tested the bound together with the min-RTT base and blamed the base. The bound alone also slows the ramp when rtt is over 1s, which goes against the stated aim that a far peer ramps as fast as a near one. It should be benched on mainnet on its own. A better base RTT signal is still needed to keep in-flight near one bandwidth-delay product. Header requests queued behind the oversized backlog are #1235.