GPU: let the frame-wait test tolerate a loaded scheduler #689

Closed
github-bot wants to merge 1 commit from gh-pr/689/head into gh-pr/689/base
Owner

@⁠iurysf on GitHub · 2026-11-24 06:55 UTC · original
iurysf:frame-test-timing → main · +6 −3 · 1 files · 1 commits · closed without merging

frame::tests::waits_end_on_ticks_and_count_frames fails intermittently under CPU load: 15 of 20 runs failed on main with all 16 cores busy. With this change, 20 of 20 pass under the same load.

Two assertions depended on scheduler timing:

  • The wall-clock bound on the second wait goes from 50 ms to 500 ms. That is still far below the 1 s time-out, so a wait that ends on the time-out instead of the tick is still caught.
  • The flip ticks were checked as exactly consecutive (w[1] == w[0] + 1) and are now strictly rising (w[1] > w[0]). Under load a tick can pass before the next flip wait starts, e.g. ticks [27, 31, 37, 41]. Repeated or backwards ticks are still rejected. This relaxes the test's semantics, so please say if you'd rather keep the exact check some other way.

No production code changed. cargo test -p victory-gpu -- --test-threads=1: all pass. Clippy -D warnings and cargo xtask policy are ok.

AI-assisted.

**@⁠iurysf** on GitHub · 2026-11-24 06:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/689) `iurysf:frame-test-timing` → `main` · +6 −3 · 1 files · 1 commits · closed without merging `frame::tests::waits_end_on_ticks_and_count_frames` fails intermittently under CPU load: **15 of 20 runs failed on main** with all 16 cores busy. With this change, **20 of 20 pass** under the same load. Two assertions depended on scheduler timing: - The wall-clock bound on the second wait goes from 50 ms to 500 ms. That is still far below the 1 s time-out, so a wait that ends on the time-out instead of the tick is still caught. - The flip ticks were checked as exactly consecutive (`w[1] == w[0] + 1`) and are now strictly rising (`w[1] > w[0]`). Under load a tick can pass before the next flip wait starts, e.g. ticks `[27, 31, 37, 41]`. Repeated or backwards ticks are still rejected. This relaxes the test's semantics, so please say if you'd rather keep the exact check some other way. No production code changed. `cargo test -p victory-gpu -- --test-threads=1`: all pass. Clippy `-D warnings` and `cargo xtask policy` are ok. AI-assisted.
waits_end_on_ticks_and_count_frames failed intermittently under CPU load
(15 of 20 runs failed on main, exit 101; 20 of 20 pass after this change).
Two assertions depended on the OS scheduler, not on the frame clock:

- The wall-clock bound on the second wait was 50 ms. A 2 ms tick can take
  longer than that when the scheduler is busy. It is now 500 ms, still well
  below the 1 s time-out, so a wait that stalls for the full time-out is
  still caught.
- The flip ticks had to be exactly consecutive. A late wake can skip ticks
  (the next tick comes from the clock), so the check is now strictly rising:
  it still rejects a tick that repeats or goes backwards.

No production code changed.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:06 +00:00
github-bot closed this pull request 2026-11-26 04:13:06 +00:00
Author
Owner

@⁠iurysf on GitHub · 2026-11-24 07:50 UTC · original

Thanks for the review. For integer ticks, w[1] >= w[0] + 1 and w[1] > w[0] are the same condition, so the check already rejects repeated and backwards ticks. And the assertion message still prints the whole tick list ({flips:?}), so a skipped tick shows up in the failure output. The run that motivated the change had [27, 31, 37, 41] under full CPU load.

As you say, whether a skipped tick under load is legitimate pacer behavior is the real question. If the maintainers would rather keep the exact check, the alternative is to retry the sequence a few times and assert that at least one run is exactly consecutive. That keeps the "one flip per tick" guarantee without failing on a single preempted iteration. I'm happy to switch to that if preferred.

**@⁠iurysf** on GitHub · 2026-11-24 07:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7125427238) Thanks for the review. For integer ticks, `w[1] >= w[0] + 1` and `w[1] > w[0]` are the same condition, so the check already rejects repeated and backwards ticks. And the assertion message still prints the whole tick list (`{flips:?}`), so a skipped tick shows up in the failure output. The run that motivated the change had `[27, 31, 37, 41]` under full CPU load. As you say, whether a skipped tick under load is legitimate pacer behavior is the real question. If the maintainers would rather keep the exact check, the alternative is to retry the sequence a few times and assert that at least one run is exactly consecutive. That keeps the "one flip per tick" guarantee without failing on a single preempted iteration. I'm happy to switch to that if preferred.
Author
Owner

@⁠ErRusso on GitHub · 2026-11-24 11:23 UTC · original

Audit: ✅ Looks good (needs Windows to execute the GPU test)

Reviewed this PR as part of an audit of mergeable PRs.

  • Scope: crates/victory-gpu/src/frame.rs (+6/-3). Two changes: timing assertion relaxed from ≤50ms to ≤500ms (still well before the 1s timeout) and the flip-order assertion relaxed from w[1] == w[0] + 1 to w[1] > w[0], so a late wake that skips ticks doesn't fail the test.
  • Merges cleanly into main.
  • Test note: The GPU crate doesn't compile on Linux (pre-existing #[cfg(windows)] gating gap in resource.rs), so the test couldn't be executed here. On Windows this should pass — the assertion logic is strictly more permissive than before. The next_tick logic between the two tests is unaffected.

No issues found in the diff.

**@⁠ErRusso** on GitHub · 2026-11-24 11:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7130036532) ## Audit: ✅ Looks good (needs Windows to execute the GPU test) Reviewed this PR as part of an audit of mergeable PRs. - **Scope:** `crates/victory-gpu/src/frame.rs` (+6/-3). Two changes: timing assertion relaxed from `≤50ms` to `≤500ms` (still well before the 1s timeout) and the flip-order assertion relaxed from `w[1] == w[0] + 1` to `w[1] > w[0]`, so a late wake that skips ticks doesn't fail the test. - **Merges cleanly** into `main`. - **Test note:** The GPU crate doesn't compile on Linux (pre-existing `#[cfg(windows)]` gating gap in `resource.rs`), so the test couldn't be executed here. On Windows this should pass — the assertion logic is strictly more permissive than before. The `next_tick` logic between the two tests is unaffected. No issues found in the diff.
Author
Owner

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

Superseded by #985, which fixes the same flaky test with tighter per-flip bounds. Closing in its favour. Thanks @⁠catminou4 and @⁠LAKSHYA-cmd-tech for the reviews. AI-assisted.

**@⁠iurysf** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7135133912) Superseded by #985, which fixes the same flaky test with tighter per-flip bounds. Closing in its favour. Thanks @⁠catminou4 and @⁠LAKSHYA-cmd-tech for the reviews. AI-assisted.

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!689
No description provided.