Make the scheduler delivery-bound assertion deterministic - #103
Open
RenKoya1 wants to merge 1 commit into
Open
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
RenKoya1
force-pushed
the
fix/scheduler-concurrency-test-flake
branch
from
August 9, 2026 17:09
107af8d to
5cd8ac3
Compare
`maxActiveCallbacks` was asserted to equal DELIVERY_CONCURRENCY, but the observed peak depends on how the four delivery lanes interleave: each lane does startHook -> authorize -> callback over RPC, and the callback only holds for 10ms. On a fast machine the lanes drift apart and the peak lands at 2 or 3, failing the test (reproducible on macOS/arm64). Hold the first five rounds of callbacks until a full set of lanes has arrived, so the peak is the runner's bound rather than RPC timing. The barrier waits on a count that is guaranteed to arrive, so it adds no wall-clock assumption of its own, and the tail round of one is excluded.
RenKoya1
force-pushed
the
fix/scheduler-concurrency-test-flake
branch
from
August 9, 2026 23:36
5cd8ac3 to
c5fbf7b
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
ScheduleDriver > bounds callback concurrency and immediately continues a due backlogassertsmaxActiveCallbacks === DELIVERY_CONCURRENCY, but the observed peak is a function of timing rather than of the bound: each of the fourrunBoundedlanes runsstartHook -> authorizeObservation -> onScheduleover RPC, and the callback only holds for 10ms. When the lanes drift apart the peak lands below 4 even though the runner never exceeds it.Reproducible on macOS/arm64 (M-series):
Rather than weaken the assertion to an upper bound — which would stop proving the bound is reached — this holds each callback until a full set of lanes has arrived, so the peak is the runner's bound and not RPC scheduling.
The batch of 20 delivers as exactly five full rounds of four, so the barrier waits on a count that is guaranteed to arrive and needs no timeout of its own; the tail round of one is excluded by the
limitargument. The barrier is off by default, leaving every other test untouched.Verification
Four consecutive runs of
schedule-driver.test.ts, alternated on the same machine with nothing else running:mainpnpm testfor the package is 102 passed / 3 skipped, andpnpm types:checkis clean.Unrelated, and untouched here:
permanently fences mutations and cleans revoked storage in bounded alarm passesoccasionally exceeds the 5s vitest timeout under CPU contention (it showed up onmainrun 4 above, and on this branch too when the whole monorepo suite runs in parallel). That is a separate load sensitivity, not the assertion this PR is about.