Skip to content

GPU tests: verify frame waits without scheduler assumptions - #978

Open
avt0m4t48 wants to merge 1 commit into
fxceless:mainfrom
avt0m4t48:test/frame-waits-clock
Open

avt0m4t48 wants to merge 1 commit into
fxceless:mainfrom
avt0m4t48:test/frame-waits-clock

Conversation

@avt0m4t48

Copy link
Copy Markdown

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.

@HailLucifer666

Copy link
Copy Markdown

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.

KomanderDG88 added a commit to KomanderDG88/VIniVIdiVIci that referenced this pull request Nov 25, 2026
…tchdog switches and three test fixes listed

The fork now follows victory-fork through a merge of its 3973179. The table
of what the fork adds gains fxceless#955 (pipeline workers, off by default), the
opt-in title watchdog hook from fxceless#959 (off by default, not used in the
measurement recorded here) and the three test fixes fxceless#963, fxceless#952 and fxceless#978.
English and Spanish.

Co-Authored-By: Claude Fable 5.2 <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.

2 participants