GPU tests: verify frame waits without scheduler assumptions #978

Open
github-bot wants to merge 1 commit from github-bot/gh-978 into main AGit
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 14:34 UTC · original
avt0m4t48:test/frame-waits-clock → main · +23 −13 · 1 files · 1 commits · open

The frame-wait test can fail when the runner is descheduled. It expects a wait to finish within 50 ms of wall time and every flip to use an adjacent 5 ms tick. The frame clock can legitimately skip ticks when work is delayed. This was also reported in #970.

Keep checking the actual wait calls, timeouts, frame tokens, and strict increase in flip ticks. Move the exact timing assertions to a test of the existing next-tick calculation using fixed elapsed times. It covers phase, an early wake and a missed tick.

The original fixture failed with either a 65 ms pause at the upper wall-clock bound or 20 ms pauses before flip waits. The patched tests passed with both controls. A mutation that ignored the previous tick failed the new clock test. Both tests passed on native Windows in the default and legacy late-wait modes. The asset policy passed.

This covers the sequential tests. The concurrent title-wait behavior addressed by #325 is separate.

Windows verification

AI-assisted using Codex.

**@⁠avt0m4t48** on GitHub · 2026-11-25 14:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/978) `avt0m4t48:test/frame-waits-clock` → `main` · +23 −13 · 1 files · 1 commits · open The frame-wait test can fail when the runner is descheduled. It expects a wait to finish within 50 ms of wall time and every flip to use an adjacent 5 ms tick. The frame clock can legitimately skip ticks when work is delayed. This was also reported in #970. Keep checking the actual wait calls, timeouts, frame tokens, and strict increase in flip ticks. Move the exact timing assertions to a test of the existing next-tick calculation using fixed elapsed times. It covers phase, an early wake and a missed tick. The original fixture failed with either a 65 ms pause at the upper wall-clock bound or 20 ms pauses before flip waits. The patched tests passed with both controls. A mutation that ignored the previous tick failed the new clock test. Both tests passed on native Windows in the default and legacy late-wait modes. The asset policy passed. This covers the sequential tests. The concurrent title-wait behavior addressed by #325 is separate. [Windows verification](https://github.com/avt0m4t48/victory-fork/actions/runs/45634545885) AI-assisted using Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:01 +00:00
Author
Owner

@⁠HailLucifer666 on GitHub · 2026-11-25 15:20 UTC · original

Same flake, independently measured tonight on Windows 10: 1 failure in 12 whole-binary runs at four-way process load, 0 in 16 serial, 0 in 24 with the test run alone. Your reading is right, and I want to add one mechanism note plus an alternative I have ready but have not opened as a PR, so you are not asked to review two things at once.

Why it fails. The assertion is before.elapsed() <= 50 ms wrapped around two 2 ms waits, plus "every flip lands on the adjacent tick". Both are claims about the machine waking up on time. Nothing in frame fails; the test measures the scheduler.

What I did differently. frame now gets its time and its sleeping from one swappable ClockSource — Instant::now and thread::sleep in the title, a hand-driven clock in tests — so the assertions become exact numbers about the arithmetic instead of wall clock:

  • each origin wait ends on the tick after the last one;
  • two 2 ms waits cost exactly 4 ms, and a timeout_ms = 0 poll after them costs none;
  • four flips are four consecutive ticks;
  • the whole run costs exactly 21 ms — and it is 21, not 26, because the first flip ends immediately when the clock is already past its tick, which is the late-wait shortcut doing its job. The sum makes that visible instead of leaving it as a comment.

The test then finishes in 0.00 s and never sleeps. Probes: make the next tick the current tick (elapsed / interval + 1 → elapsed / interval) → fails 16 ms vs 21 ms; sleep 1 us short of the tick → fails 3.999 ms vs 4 ms.

The trade, plainly. Mine adds a seam to shipping code (frame.rs, two functions and one OnceLock); yours touches tests only. Yours removes the unsound assertion; mine replaces it with a stronger one. If the owner prefers test-only, take yours and I will not open mine — say the word either way and I'll follow your call rather than adding a second PR to the queue.

One thing worth keeping from the current test whichever version lands: assert!(LAST[0] >= 2) and the "a poll costs no time" check are the parts that catch a real regression. The 50 ms and tick-adjacency checks are the parts that cannot.

**@⁠HailLucifer666** on GitHub · 2026-11-25 15:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/978#issuecomment-7166689137) Same flake, independently measured tonight on Windows 10: **1 failure in 12** whole-binary runs at four-way process load, **0 in 16** serial, **0 in 24** with the test run alone. Your reading is right, and I want to add one mechanism note plus an alternative I have ready but have **not** opened as a PR, so you are not asked to review two things at once. **Why it fails.** The assertion is `before.elapsed() <= 50 ms` wrapped around two 2 ms waits, plus "every flip lands on the adjacent tick". Both are claims about the machine waking up on time. Nothing in `frame` fails; the test measures the scheduler. **What I did differently.** `frame` now gets its time and its sleeping from one swappable `ClockSource` — `Instant::now` and `thread::sleep` in the title, a hand-driven clock in tests — so the assertions become exact numbers about the arithmetic instead of wall clock: - each origin wait ends on the tick after the last one; - two 2 ms waits cost exactly 4 ms, and a `timeout_ms = 0` poll after them costs none; - four flips are four consecutive ticks; - the whole run costs exactly **21 ms** — and it is 21, not 26, because the first flip ends immediately when the clock is already past its tick, which is the late-wait shortcut doing its job. The sum makes that visible instead of leaving it as a comment. The test then finishes in 0.00 s and never sleeps. Probes: make the next tick the current tick (`elapsed / interval + 1` → `elapsed / interval`) → fails 16 ms vs 21 ms; sleep 1 us short of the tick → fails 3.999 ms vs 4 ms. **The trade, plainly.** Mine adds a seam to shipping code (`frame.rs`, two functions and one `OnceLock`); yours touches tests only. Yours removes the unsound assertion; mine replaces it with a stronger one. If the owner prefers test-only, take yours and I will not open mine — say the word either way and I'll follow your call rather than adding a second PR to the queue. One thing worth keeping from the current test whichever version lands: `assert!(LAST[0] >= 2)` and the "a poll costs no time" check are the parts that catch a real regression. The 50 ms and tick-adjacency checks are the parts that cannot.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/978/head:github-bot/gh-978'
git switch 'github-bot/gh-978'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-978'
git switch 'github-bot/gh-978'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-978'
git switch 'github-bot/gh-978'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-978'
git switch 'main'
git merge --squash 'github-bot/gh-978'
git switch 'main'
git merge --ff-only 'github-bot/gh-978'
git switch 'main'
git merge 'github-bot/gh-978'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.