Repository navigation
Time the stall window test instead of counting polls - #10987
Conversation
'a healthy read resets the stall window' fails on windows-latest on PRs that touch nothing near it. Seen on #10950 at 65/55, 64/43 and 62/50 reads, ratios of 1.18, 1.49 and 1.24 against a 1.25 bar, so the same healthy code both passed and failed inside one run. The measurement is the problem. The window is defined in time: the source keeps a lastHealthy stamp and gives up at Date.now() - lastHealthy >= stallMs. The test counted READS, which is that quantity divided by the cost of one poll, and poll cost is the noisiest thing in reach on a shared runner, about 1ms on Linux against about 15ms on Windows. The reset point was derived from a previous run's read count too, so any drift between the two runs moved the thing being measured as well as the measurement. Best-of-three and then majority-of-three were both attempts to average that away. Neither shrank the spread, because the spread is the measurement. So time the loop, and fire the healthy read on a clock rather than at a read index. The reset lands halfway through the window whatever a poll costs, and the signal becomes a difference rather than a ratio: the loop should outlast the plain one by about half a window. Jitter is bounded by one poll interval, ~15ms at worst against a 200ms signal. One sample of each now does what six could not, so the test is also 2.5x faster: 3285ms to 1282ms. Not vacuous, which the version it replaces admitted it was on Linux. Dropping the lastHealthy refresh from the source makes it fail here with 'it bought -1ms (400ms with a reset against 401ms without)'.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Subtracting two separately scheduled runs re-imports the noise the previous commit set out to escape. An unrelated stall of 100ms or more is well within what a shared runner does, and it breaks the comparison in both directions: a stall during the baseline fails healthy code, and a stall during the other run passes code that never refreshes lastHealthy. The claim that jitter is bounded by one poll interval covered poll scheduling, not OS or event-loop stalls. So use one run and assert what the source actually promises: the window restarts at the healthy read, so the loop must survive a further full window from THAT moment. Both sides of the bound come from the same run, and a stall can only make the total larger, so the bound is one-sided and delay cannot fail healthy code. A stall can still hide a missing reset by inflating the total, so the run records the longest gap between two reads and skips when that gap gets close to the signal. A run that cannot tell the two apart reports no evidence rather than a verdict. One run rather than two also makes it 600ms, against 1282ms for the previous version and 3285ms for the one before that. Failure output is now exact rather than statistical: 'the loop ended 400ms in, having reported progress at 200ms, so it should have run to at least 600ms'. Verified by dropping the lastHealthy refresh, and passing 5 of 5 under 240 busy processes on a 192-core box.
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
* Time the stall window test instead of counting polls 'a healthy read resets the stall window' fails on windows-latest on PRs that touch nothing near it. Seen on unslothai#10950 at 65/55, 64/43 and 62/50 reads, ratios of 1.18, 1.49 and 1.24 against a 1.25 bar, so the same healthy code both passed and failed inside one run. The measurement is the problem. The window is defined in time: the source keeps a lastHealthy stamp and gives up at Date.now() - lastHealthy >= stallMs. The test counted READS, which is that quantity divided by the cost of one poll, and poll cost is the noisiest thing in reach on a shared runner, about 1ms on Linux against about 15ms on Windows. The reset point was derived from a previous run's read count too, so any drift between the two runs moved the thing being measured as well as the measurement. Best-of-three and then majority-of-three were both attempts to average that away. Neither shrank the spread, because the spread is the measurement. So time the loop, and fire the healthy read on a clock rather than at a read index. The reset lands halfway through the window whatever a poll costs, and the signal becomes a difference rather than a ratio: the loop should outlast the plain one by about half a window. Jitter is bounded by one poll interval, ~15ms at worst against a 200ms signal. One sample of each now does what six could not, so the test is also 2.5x faster: 3285ms to 1282ms. Not vacuous, which the version it replaces admitted it was on Linux. Dropping the lastHealthy refresh from the source makes it fail here with 'it bought -1ms (400ms with a reset against 401ms without)'. * Tighten the comments added by this PR * Assert the stall window against the mechanism, not a second run Subtracting two separately scheduled runs re-imports the noise the previous commit set out to escape. An unrelated stall of 100ms or more is well within what a shared runner does, and it breaks the comparison in both directions: a stall during the baseline fails healthy code, and a stall during the other run passes code that never refreshes lastHealthy. The claim that jitter is bounded by one poll interval covered poll scheduling, not OS or event-loop stalls. So use one run and assert what the source actually promises: the window restarts at the healthy read, so the loop must survive a further full window from THAT moment. Both sides of the bound come from the same run, and a stall can only make the total larger, so the bound is one-sided and delay cannot fail healthy code. A stall can still hide a missing reset by inflating the total, so the run records the longest gap between two reads and skips when that gap gets close to the signal. A run that cannot tell the two apart reports no evidence rather than a verdict. One run rather than two also makes it 600ms, against 1282ms for the previous version and 3285ms for the one before that. Failure output is now exact rather than statistical: 'the loop ended 400ms in, having reported progress at 200ms, so it should have run to at least 600ms'. Verified by dropping the lastHealthy refresh, and passing 5 of 5 under 240 busy processes on a 192-core box. * Tighten the comments this PR added
Frontend unit tests (Windows)fails on PRs that touch nothing near it. Most recently #10950, which changes GGUF export token fallback:Those are ratios of 1.18, 1.49 and 1.24 against a 1.25 bar. The same healthy code both passed and failed inside a single run, and round three missed by half a read.
The measurement is what is wrong, not the threshold
The stall window is defined in time.
settleWhenLoadEndskeeps alastHealthystamp and gives up atDate.now() - lastHealthy >= stallMs.The test counted reads. A read count is that same quantity divided by the cost of one poll, and poll cost is the noisiest thing within reach on a shared runner: about 1ms here, about 15ms on
windows-latest, and varying run to run on both. Worse, the reset point was a read index derived from the previous run's count, so drift between the two runs moved the thing being measured as well as the measurement. The baselines in the failure above range from 43 to 55 reads, a 28 percent spread, within one test.The file's own history shows two attempts to average that away: one sample became best-of-three, which became majority-of-three. Neither shrank the spread, because the spread is the measurement.
Timing it instead
Measure how long the loop survives, and fire the healthy read on a clock rather than at a read index. The reset then lands halfway through the window whatever a poll costs, and the signal becomes a difference rather than a ratio: a loop whose window restarted halfway should outlast the plain one by about half a window.
Jitter is bounded by one poll interval, so about 15ms at worst against a 200ms signal. One sample of each now does what six rounds could not, which also makes the test 2.5x faster, 3285ms to 1282ms.
Not vacuous
The version this replaces said in its own comment that it was vacuous on Linux, where 30ms of 1ms polls cleared the old bar whether or not the window was ever reset. This one is not. Dropping the
lastHealthyrefresh frommodel-lifecycle-events.tsfails it here:Healthy code buys about 200ms against a 100ms bar; the broken source buys 0. The old test decided the same question on 1.18 against 1.25.
Verification
tests/background-load-notice.test.ts: 11 passed, five runs in a row.Whole frontend suite, with and without this change: 5645 tests, 5405 passed, 240 failed, identical both ways. Those 240 are a local
node_modulesgap, not this branch.Tests only, no production code.