Skip to content

feat(task): hold a plateau and probe it again - #216

Draft
greenhat616 wants to merge 2 commits into
feat/hardening-46-wrapupfrom
feat/hardening-47-adaptive-window
Draft

greenhat616 wants to merge 2 commits into
feat/hardening-46-wrapupfrom
feat/hardening-47-adaptive-window

Conversation

@greenhat616

Copy link
Copy Markdown
Owner

PR-B of the concurrency window redesign (T31; design §9.2, §14.33; decisions D28–D31). Stacked on #211, which is its base.

Why

DoublingStrategy set a plateau flag after a doubling that gained under 10 %, and never cleared it: the task never probed again when bandwidth came back, and nothing refilled after a plateau (§14.14). A doubling to the limit could also wait without end for runners that could not come back (§14.18).

What

  • C40 feat(task): hold a plateau and probe it again
    • Mode::{Ramp, Hold { h, reprobe_at }} replaces the flag. A gainless doubling holds the runner count before it; the hold refills up to h without judging.
    • At reprobe_at, a probe doubles from the runners active then (D31, confirmed 2026-11-16): base b = active ≥ h, goal min(2b, limit_cap), made only if it adds at least ⌈b/2⌉, judged by the one-tick 10 % rule against the speed at b. Gain → ramp; no gain → hold b, wait doubled (30 s up to 300 s); inconclusive → wait unchanged.
    • Every pending growth has a deadline (connect_timeout + 5 × GROW_INTERVAL, 40 s by default): an unjudged ramp doubling is dropped, an unjudged probe is inconclusive.
    • A verdict and a probe's baseline are taken only on a stable tick: the same runner attempts at both samples and an unchanged planner population counter. The search for a stable baseline is bounded by the same deadline.
    • The growth side passes want to the limit controller (max_connections while ramping, h in a hold, the probe's goal while it is pending); cap = min(limit_cap, want, max_connections) and free = cap.saturating_sub(active).
    • The runners of a gainless doubling are not stopped (D28); they finish their chunks.
  • C41 bench(task): add the silent limit and the plateau scenarios: s5_silent_limit_4 (Close and Hang), s6_plateau_then_more_bandwidth, s1_max32_long, a full re-run of the table (§14.17).

Bench (10 runs each, median)

Scenario Time Notes
s6 plateau, then more bandwidth 44.16 s before D31: 50.57 s, no probe
s1_max32_long (256 MiB) 24.28 s 16 → 32 judged gainless, hold
s5 silent limit 4, Close 53.04 s at most 4 served
s5 silent limit 4, Hang 84.99 s limit never lowered: hung connects time out after the healthy peers finished, so they are uncorroborated; fixed in a follow-up PR on top

Other scenarios are within the spread of §14.20.

Not done

  • Stopping the runners of a gainless doubling (follow-up F8).
  • A hold whose limit leaves less than ⌈b/2⌉ room is not probed (Q8).
  • Falling bandwidth at a ramped level is not detected (F4).
  • A download whose runners change every tick probes only when a stable tick appears; each search lasts at most 40 s.

Verification

fmt, clippy -D warnings and cargo test --workspace --all-features on each commit (1052 passed, 0 failed, 1 ignored at C41); cargo bench --no-run. Reviewed by codex over four rounds (single backend).

A doubling that gains less than 10% no longer stops the growth for the
rest of the download. The growth holds the runners it doubled from: it
refills up to them by splits and adds nothing while more are active.
Once its wait has passed, it probes from the runners active then, at
least the hold, by doubling towards the limit: the runners a gainless
doubling added may run to the end of the download. A gain resumes the
ramp; no gain holds the runners the probe started from and doubles the
wait from 30 s up to 300 s. The runners a gainless doubling added are
not stopped: they finish their chunks.

The growth now tells the limit controller how many connections it
wants: all of them while ramping, the hold, or a pending probe's goal.
Runners are only created up to that, and a hold above the limit asks
for recovery steps. The endgame hedge stays gated by the limit alone.

Every pending growth ends at a deadline of the connect timeout plus
five grow intervals: a doubling to the limit whose runners never come
back is dropped instead of freezing the growth, and a probe is
inconclusive.

Design notes in §14.33 (D28 to D31, G11); §14.14 and §14.18 mark the
permanent plateau as superseded.
The growth bench gains three scenarios. s5_silent_limit_4 runs over
HTTP, the reqwest adapter against the limited server of the tests
crate, which serves four connections at once and closes or never
answers the others; it has its own table of the connections the server
turned away and when. s6_plateau_then_more_bandwidth raises the
server's bandwidth during a hold, with a new adapter option that
raises the total speed limit some time after the first stream.
s1_max32_long runs s1_max32 on 256 MiB, long enough for the doubling
from 16 to 32 to be judged. The table also counts holds and probes.

Design §14.17 has the new numbers in place of the label that marked
the old ones as measured before the limit controller.
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