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

Closed
iurysf wants to merge 1 commit from upstream-pr/689 into main
iurysf commented 2026-11-24 06:55:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T06:55:12Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6576394740 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689). Originally posted by [iurysf](https://github.com/iurysf) on 2026-11-24T06:55:12Z. --- `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.
catminou4 commented 2026-11-24 07:01:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:55:36Z.

Review: COMMENTED


Static review only (victory-gpu doesn't build off Windows, so I can't run the flaky test either way):

  • The 50 ms → 500 ms relaxation is sound: the wait's own timeout is 1 s, so a real hang still fails via S_OK/TIMEOUT before this bound matters; 500 ms only absorbs scheduler jitter on the 2 ms tick. The comment documents exactly that.
  • The tick assertion change (== w[0] + 1 → > w[0]) is the part to think about: it stops verifying that each flip consumes exactly one tick and only verifies monotonicity. If skipping a tick under load is legitimate pacer behavior, this is right; if a skipped tick would indicate a lost frame event, the test no longer catches it. The PR body says 15/20 failed on main under full load — suggesting the strict version was testing scheduler timing, not frame logic — so I'd accept it, but consider asserting w[1] >= w[0] + 1 with the skip case logged, if you want to keep visibility.

Test-only change, no production code touched.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034931277 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#pullrequestreview-6034931277). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:55:36Z. **Review:** COMMENTED --- Static review only (victory-gpu doesn't build off Windows, so I can't run the flaky test either way): - The 50 ms → 500 ms relaxation is sound: the wait's own timeout is 1 s, so a real hang still fails via `S_OK`/`TIMEOUT` before this bound matters; 500 ms only absorbs scheduler jitter on the 2 ms tick. The comment documents exactly that. - The tick assertion change (`== w[0] + 1` → `> w[0]`) is the part to think about: it stops verifying that each flip consumes exactly one tick and only verifies monotonicity. If skipping a tick under load is legitimate pacer behavior, this is right; if a skipped tick would indicate a lost frame event, the test no longer catches it. The PR body says 15/20 failed on main under full load — suggesting the strict version was testing scheduler timing, not frame logic — so I'd accept it, but consider asserting `w[1] >= w[0] + 1` with the skip case logged, if you want to keep visibility. Test-only change, no production code touched.
LAKSHYA-cmd-tech commented 2026-11-24 07:07:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:06:23Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. rame::tests::waits_end_on_ticks_and_count_frames passes cleanly. Increasing the wall-clock tolerance from 50 ms to 500 ms and asserting monotonic tick ordering prevents CI test flakes under loaded multi-threaded test runs.

<!-- greyfinch-sync:Marvisak/VIctory:review:6035034169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#pullrequestreview-6035034169). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T07:06:23Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. rame::tests::waits_end_on_ticks_and_count_frames passes cleanly. Increasing the wall-clock tolerance from 50 ms to 500 ms and asserting monotonic tick ordering prevents CI test flakes under loaded multi-threaded test runs.
iurysf commented 2026-11-24 08:02:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T07:50:19Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7125427238 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7125427238). Originally posted by [iurysf](https://github.com/iurysf) on 2026-11-24T07:50:19Z. --- 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.
mercuryVM commented 2026-11-24 11:03:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T10:27:33Z.

Review: APPROVED


Tested e1c3557 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 43 passed. Clippy shows 1 undocumented_unsafe_blocks warning at host.rs:267, which is already on main and not from this change.

  • Both relaxations still catch what the test is for. 500 ms is half the 1 s time-out, so a wait that ends on the time-out instead of a tick still fails. Strictly rising ticks still reject a flip that reuses another flip's tick, which is the property the following next_tick(FLIP) assertion depends on.
  • Only test code changes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6037539806 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#pullrequestreview-6037539806). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T10:27:33Z. **Review:** APPROVED --- Tested e1c3557 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-gpu -- --test-threads=1` 43 passed. Clippy shows 1 `undocumented_unsafe_blocks` warning at host.rs:267, which is already on main and not from this change. - Both relaxations still catch what the test is for. 500 ms is half the 1 s time-out, so a wait that ends on the time-out instead of a tick still fails. Strictly rising ticks still reject a flip that reuses another flip's tick, which is the property the following `next_tick(FLIP)` assertion depends on. - Only test code changes. AI-assisted (Claude Code).
ErRusso commented 2026-11-24 12:04:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ErRusso on 2026-11-24T11:23:32Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130036532 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7130036532). Originally posted by [ErRusso](https://github.com/ErRusso) on 2026-11-24T11:23:32Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 15:03:14 +00:00
iurysf commented 2026-11-24 15:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T14:54:07Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135133912 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/689#issuecomment-7135133912). Originally posted by [iurysf](https://github.com/iurysf) on 2026-11-24T14:54:07Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!689
No description provided.