Skip to content

Net: bound a never-pausing peer's cancel latency by what the transport controls (fixes the bench's failing unit suite) - #1380

Merged
GLinnik21 merged 1 commit into
mainfrom
lane/unit-test-speed
Nov 14, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
lane/unit-test-speed

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What was wrong

The daily local build bench's tests row (the unit suite) has failed since 2026-11-10 with one test: ws::transport::tests::a_peer_that_never_pauses_cannot_hold_off_a_cancel (3-core virtualised macOS runner, failing in all 3 rounds of each daily run, so it is deterministic there, not a flake). Every tests row since then is empty.

run returns after the cancel once the pass in flight has read its byte budget (PASS_BUDGET, 1 MiB, about 1045 of the test's 1004-byte frames) and called the callback for each. The test's callback sleeps 200 us per message, and the test asserted run returned within one second of the cancel. So it measured its own cost: about 0.3 s where the sleep takes ~250 us, over a second where a coarse timer stretches 200 us to 1+ ms. The transport was doing exactly what it should.

Reproduced here before the fix: with the callback at 1.5 ms (a timer-coarse runner), the unchanged assertion fails after 2.3 s.

The change

Test only (rust-modules/net/src/ws/transport_tests.rs). The one-second wall-clock bound is replaced by the two things the transport controls:

  • the messages delivered after the cancel was raised are at most one pass: (PASS_BUDGET + READ_CHUNK) / frame + 2. A pass with no budget would deliver tens of thousands (the peer writes for 10 s);
  • the time spent outside the callback between the cancel and the return, the going-away close included, is under one second.

Still proves

That a peer which never pauses cannot hold off a cancel: verified by mutation, PASS_BUDGET = 1 << 40 makes the new test fail (on the message count, after 10.4 s). Verified to pass at a 200 us callback (0.33 s) and at a 1.5 ms callback (2.28 s), where the old assertion fails.

Gates

make test-crate C=plx_net
test result: ok. 336 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 20.80s

Not run locally (CI gates the PR): full make check.

🤖 Generated with Claude Code

…t controls

`a_peer_that_never_pauses_cannot_hold_off_a_cancel` asserted that `run` returned within one second
of the cancel while its own callback slept 200 us per message. The pass in flight when the cancel is
raised reads up to `PASS_BUDGET` (1 MiB, about 1045 of these frames) and calls the callback for each,
so the measured time was the test's own cost: ~0.3 s where the sleep takes 250 us, but over a second
where a coarse timer turns 200 us into 1+ ms. It failed on every run of the daily macOS bench's unit
suite from 2026-11-10 (the first run after #1283), a 3-core virtualised runner. With the callback at
1.5 ms the unchanged assertion fails here too (2.3 s) while the transport behaves identically.

The test now asserts the two things the transport controls: the messages delivered after the cancel
are at most one pass (`PASS_BUDGET` plus the chunk that crossed it, over the frame size; a peer
written for ten seconds would deliver tens of thousands), and the time spent outside the callback
between the cancel and the return, the going-away close included, is under a second. Verified:
passes at a 200 us and at a 1.5 ms callback; fails (after 10 s, on the message count) with
`PASS_BUDGET` raised to 1 << 40.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GLinnik21
GLinnik21 merged commit 5ca2777 into main Nov 14, 2026
27 of 29 checks passed
@GLinnik21
GLinnik21 deleted the lane/unit-test-speed branch November 14, 2026 03:44
GLinnik21 added a commit that referenced this pull request Nov 14, 2026
Brings in #1380 (net transport test change); nothing in it touches the
hostsim suite or the files this branch edits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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