Repository navigation
Net: bound a never-pausing peer's cancel latency by what the transport controls (fixes the bench's failing unit suite) - #1380
Merged
Conversation
…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
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>
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The daily local build bench's
testsrow (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). Everytestsrow since then is empty.runreturns 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 assertedrunreturned 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:(PASS_BUDGET + READ_CHUNK) / frame + 2. A pass with no budget would deliver tens of thousands (the peer writes for 10 s);Still proves
That a peer which never pauses cannot hold off a cancel: verified by mutation,
PASS_BUDGET = 1 << 40makes 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
Not run locally (CI gates the PR): full
make check.🤖 Generated with Claude Code