Skip to content

fix(dash-spv): ByteLimiter cap runs away on slow peers on refactor/network-mod, starving header sync #1220

Open

Description

@xdustinface

Problem

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:

  1. 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.
  2. 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:

11:27:03 rate=0.8MB/s bind=global global_cap=4541KB  in_flight=10938KB rtt=13997ms base=13997ms
11:28:03 rate=0.3MB/s bind=work   global_cap=94397KB in_flight=15618KB rtt=52025ms base=14205ms
11:31:03 rate=0.6MB/s bind=work   global_cap=89823KB in_flight=46071KB rtt=76245ms base=56576ms

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.

Activity

  1. added 2 commits that reference this issue on Oct 27, 2026
    993f643
    8825d72
  2. xdustinface commented on Oct 28, 2026

    @xdustinface
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions