GPU frame test: tolerate a late wake-up instead of requiring consecutive flips #985

Closed
github-bot wants to merge 6 commits from gh-pr/985/head into gh-pr/985/base
Owner

@⁠Makto94 on GitHub · 2026-11-24 14:40 UTC · original
Makto94:fix/frame-test-oversleep → main · +56 −16 · 1 files · 6 commits · closed without merging

What and why

frame::tests::waits_end_on_ticks_and_count_frames (victory-gpu) requires four flips on consecutive 5 ms ticks. When the CPU is loaded, the flip wait oversleeps and the next flip correctly lands on a later tick ([38, 45, 52, 59]), so the test fails.

Scope: this reproduces locally under CPU load (e.g. cargo test --workspace on a busy machine). It did not appear in the 28 most recent failed CI runs upstream.

The test now keeps its own clock instead of trusting next_tick. For each flip:

  • it lands on a new tick, not before the tick due when the wait was called, and not after the ticks that passed during the call;
  • the wait does not end before its tick (1 ms tolerance; the smallest margin measured was 17 µs idle);
  • at least one flip lands exactly on the expected tick.

Only the test changes.

How it was tested

Windows 11, test binary run directly; load = 16 busy-loop processes.

idle under load
before passes 30/30 fail
after 20/20 pass 40/40 pass, plus 12/12 in parallel batches

Mutants in next_tick/wait, each failing 3/3 with this test: tick +1 → +2, +1 → +0, sleep(wait / 2), sleep(0). The old test missed +0 and both sleep mutants. Both clippy commands from CI and cargo test -p victory-gpu --locked pass.

🤖 Generated with Claude Code

**@⁠Makto94** on GitHub · 2026-11-24 14:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/985) `Makto94:fix/frame-test-oversleep` → `main` · +56 −16 · 1 files · 6 commits · closed without merging ## What and why `frame::tests::waits_end_on_ticks_and_count_frames` (victory-gpu) requires four flips on consecutive 5 ms ticks. When the CPU is loaded, the flip wait oversleeps and the next flip correctly lands on a later tick (`[38, 45, 52, 59]`), so the test fails. Scope: this reproduces locally under CPU load (e.g. `cargo test --workspace` on a busy machine). It did not appear in the 28 most recent failed CI runs upstream. The test now keeps its own clock instead of trusting `next_tick`. For each flip: - it lands on a new tick, not before the tick due when the wait was called, and not after the ticks that passed during the call; - the wait does not end before its tick (1 ms tolerance; the smallest margin measured was 17 µs idle); - at least one flip lands exactly on the expected tick. Only the test changes. ## How it was tested Windows 11, test binary run directly; load = 16 busy-loop processes. | | idle | under load | |---|---|---| | before | passes | 30/30 fail | | after | 20/20 pass | 40/40 pass, plus 12/12 in parallel batches | Mutants in `next_tick`/`wait`, each failing 3/3 with this test: tick `+1` → `+2`, `+1` → `+0`, `sleep(wait / 2)`, `sleep(0)`. The old test missed `+0` and both sleep mutants. Both clippy commands from CI and `cargo test -p victory-gpu --locked` pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a loaded machine (the full workspace test run) the flip wait oversleeps
the 5 ms interval and the next flip lands a few ticks later, so the test
failed 30 of 30 runs under CPU load. It now checks that each flip ends on
a new tick, no earlier than the tick due when the wait was called, and no
later than the ticks that passed during the call.
On a loaded machine (the full workspace test run) the flip wait oversleeps
the 5 ms interval and the next flip lands a few ticks later, so the test
failed 30 of 30 runs under CPU load. It now checks that each flip ends on
a new tick, no earlier than the tick due when the wait was called, and no
later than the ticks that passed during the call.
The previous revision compared each flip with next_tick, the function
under test, so an off-by-one there went unnoticed. The test now keeps
its own clock: each flip must land on a new tick, not before the one due
when the wait was called and not after the ticks that passed during it;
at least one flip must land exactly on the expected tick, and no wait may
end before its tick (1 ms tolerance).
The previous revision compared each flip with next_tick, the function
under test, so an off-by-one there went unnoticed. The test now keeps
its own clock: each flip must land on a new tick, not before the one due
when the wait was called and not after the ticks that passed during it;
at least one flip must land exactly on the expected tick, and no wait may
end before its tick (1 ms tolerance).
# Conflicts:
#	crates/victory-gpu/src/frame.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:15:53 +00:00
github-bot closed this pull request 2026-11-26 04:15:53 +00:00
Author
Owner

@⁠iurysf on GitHub · 2026-11-24 14:54 UTC · original

Supporting data: on Windows 11 with all 16 cores busy, this test failed 15 of 20 runs on main for us (the flip ticks came out as e.g. [27, 31, 37, 41]). Your per-flip bounds (a new tick each time, no earlier than due, no later than the ticks that passed during the call) keep more of the guarantee than our #689, which only checked that the ticks rise. I am closing #689 in favour of this one. AI-assisted.

**@⁠iurysf** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/985#issuecomment-7135133250) Supporting data: on Windows 11 with all 16 cores busy, this test failed **15 of 20** runs on main for us (the flip ticks came out as e.g. `[27, 31, 37, 41]`). Your per-flip bounds (a new tick each time, no earlier than due, no later than the ticks that passed during the call) keep more of the guarantee than our #689, which only checked that the ticks rise. I am closing #689 in favour of this one. AI-assisted.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 14:54 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d31567c: cargo test -p victory-gpu passes, 50 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/985#issuecomment-7135156893) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d31567c: `cargo test -p victory-gpu` passes, 50 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:58 UTC · original · edited 2026-11-24 15:08 UTC

The test at d31567c passed under ordinary Wine scheduling. A 60 ms pause after the due-tick sample but before the timer started exposed one remaining false failure: due tick 4, flip tick 16, one elapsed tick counted. Starting the timer immediately before the sample passed the same delayed control while keeping the per-flip assertions.

Update: 211d365 covers this interval with its independent clock. Its focused test passed on Wine 11.22 unchanged and with one 60 ms pause immediately after the first due-tick sample, including the exact-tick check. We closed the follow-up as superseded.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/985#issuecomment-7135260873) · edited 2026-11-24 15:08 UTC The test at d31567c passed under ordinary Wine scheduling. A 60 ms pause after the due-tick sample but before the timer started exposed one remaining false failure: due tick 4, flip tick 16, one elapsed tick counted. Starting the timer immediately before the sample passed the same delayed control while keeping the per-flip assertions. Update: 211d365 covers this interval with its independent clock. Its focused test passed on Wine 11.22 unchanged and with one 60 ms pause immediately after the first due-tick sample, including the exact-tick check. We [closed the follow-up as superseded](https://github.com/Makto94/VIctory/pull/1#issuecomment-7135507746).
Author
Owner

@⁠jamesn-xt on GitHub · 2026-11-24 16:36 UTC · original

Independent reproduction on Windows 11 x64, Ryzen 5 5600 / 32 GiB RAM, pinned Rust 1.98.1, while a separate WARP workload was active.

Before #985, cargo test -p victory-gpu --features diagnostics --locked -- --nocapture --test-threads=1 failed only frame::tests::waits_end_on_ticks_and_count_frames: the four flip ticks were [15, 16, 17, 19]. Result: 63 passed, 1 failed, 1 ignored. The skipped tick is consistent with the absolute-clock behavior described here.

After merging head 211d365, the same command with WARP/debug enabled passed: 64 passed, 1 ignored, while the separate WARP workload continued. One before/after observation, not a stress-test success-rate claim. No runtime pacing code was changed by this PR.

The surrounding local integration includes #211, #89 and #492 plus the capture-directory change from #1146; these were unchanged between the two test runs. The reproducible integration branch now also includes #206: https://github.com/jamesn-xt/VIctory/tree/test/rtx4080-target-formats . Synthetic test results only; no retail logs or captures attached.

**@⁠jamesn-xt** on GitHub · 2026-11-24 16:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/985#issuecomment-7137931038) Independent reproduction on Windows 11 x64, Ryzen 5 5600 / 32 GiB RAM, pinned Rust 1.98.1, while a separate WARP workload was active. Before #985, `cargo test -p victory-gpu --features diagnostics --locked -- --nocapture --test-threads=1` failed only `frame::tests::waits_end_on_ticks_and_count_frames`: the four flip ticks were `[15, 16, 17, 19]`. Result: 63 passed, 1 failed, 1 ignored. The skipped tick is consistent with the absolute-clock behavior described here. After merging head `211d365`, the same command with WARP/debug enabled passed: 64 passed, 1 ignored, while the separate WARP workload continued. One before/after observation, not a stress-test success-rate claim. No runtime pacing code was changed by this PR. The surrounding local integration includes #211, #89 and #492 plus the capture-directory change from #1146; these were unchanged between the two test runs. The reproducible integration branch now also includes #206: https://github.com/jamesn-xt/VIctory/tree/test/rtx4080-target-formats . Synthetic test results only; no retail logs or captures attached.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:29 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/985#issuecomment-7148562223) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!985
No description provided.