Tests: allow the frame clock to skip ticks after a late frame #2263

Open
andrewpozdnakov7-jpg wants to merge 3 commits from upstream-pr/2265 into main
andrewpozdnakov7-jpg commented 2026-11-25 09:22:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T09:22:18Z.


The frame-pacing fixture failed during parallel Windows tests when a thread was scheduled more than 50 ms late or a flip missed a tick. The frame clock reserves a distinct tick for each successful flip. It can skip one when the caller arrives late.

The fixture now keeps the consecutive frame-token assertion and checks that every flip takes a later tick. A delay of three intervals before one flip exercises a missed tick on every run.

On 940d32f with the same delay and the old assertions, all 10 runs failed, for example with flip ticks [4, 5, 9, 10]. With the new assertions, both frame tests passed in all 50 runs. Full victory-gpu on WARP: 146 passed, 0 failed, 2 ignored. Strict Clippy with and without diagnostics and the staged policy check passed.

303be14 also covers the origin poll from the #2729 CI failure. The test now controls elapsed time on its own thread while calling the normal frame API. With the same delayed poll on 013f797 (98578ea combined with main 13f91ca), the old TIMEOUT assertion received S_OK in all 10 attempts. The revised test checks that the late poll consumes the elapsed tick, the next poll times out without changing its token, and the flag still starts an early frame. The flip cases use the same controlled time.

Both frame tests passed in 50 parallel repetitions. The full GPU suite on WARP passed 198 tests with one ignored under each debug setting. Strict Clippy in both feature configurations and asset policy passed.

Please preserve the Git author when reapplying the test. If you fold it into your own commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5488554741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T09:22:18Z. --- The frame-pacing fixture failed during parallel Windows tests when a thread was scheduled more than 50 ms late or a flip missed a tick. The frame clock reserves a distinct tick for each successful flip. It can skip one when the caller arrives late. The fixture now keeps the consecutive frame-token assertion and checks that every flip takes a later tick. A delay of three intervals before one flip exercises a missed tick on every run. On 940d32f with the same delay and the old assertions, all 10 runs failed, for example with flip ticks [4, 5, 9, 10]. With the new assertions, both frame tests passed in all 50 runs. Full victory-gpu on WARP: 146 passed, 0 failed, 2 ignored. Strict Clippy with and without diagnostics and the staged policy check passed. [303be14](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/303be14ec53ab5ca1ce2ea9a0e246a7aa0b785e7) also covers the origin poll from the [#2729 CI failure](https://github.com/Marvisak/VIctory/actions/runs/45684843740/job/139454597062). The test now controls elapsed time on its own thread while calling the normal frame API. With the same delayed poll on 013f797 (98578ea combined with main 13f91ca), the old TIMEOUT assertion received S_OK in all 10 attempts. The revised test checks that the late poll consumes the elapsed tick, the next poll times out without changing its token, and the flag still starts an early frame. The flip cases use the same controlled time. Both frame tests passed in 50 parallel repetitions. The full GPU suite on WARP passed 198 tests with one ignored under each debug setting. Strict Clippy in both feature configurations and asset policy passed. Please preserve the Git author when reapplying the test. If you fold it into your own commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
catminou4 commented 2026-11-25 09:35:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:36Z.

Review: COMMENTED


Tests: frame clock may skip ticks after a late wake; deterministic assertions replace wall-clock bounds. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test-only flake fix, good.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055073634 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#pullrequestreview-6055073634). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:36Z. **Review:** COMMENTED --- Tests: frame clock may skip ticks after a late wake; deterministic assertions replace wall-clock bounds. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test-only flake fix, good.
cloph-dsp commented 2026-11-25 11:05:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T10:29:18Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, head 98578ea, no game data): cargo test -p victory-gpu --lib frame::tests --locked -> 2 tests passed (waits_begun_together_take_different_ticks, waits_end_on_ticks_and_count_frames), exit 0. Only two fetch_update deprecation warnings, unrelated to this change. I did not run the flaky assertion in a loop or on a loaded machine, so the anti-flake claim is not independently stress-tested here. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only unit tests). No game data, assets or extracted content used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159762383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#issuecomment-7159762383). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T10:29:18Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, head 98578ea, no game data): `cargo test -p victory-gpu --lib frame::tests --locked` -> 2 tests passed (`waits_begun_together_take_different_ticks`, `waits_end_on_ticks_and_count_frames`), exit 0. Only two `fetch_update` deprecation warnings, unrelated to this change. I did not run the flaky assertion in a loop or on a loaded machine, so the anti-flake claim is not independently stress-tested here. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only unit tests). No game data, assets or extracted content used.
Marvisak commented 2026-11-25 14:07:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:31:39Z.


Automated triage for the maintainers.

Merge candidate (test-only). The head moved to 303be14 (main merged in, plus a new test commit). The frame tests in crates/victory-gpu/src/frame.rs no longer depend on scheduling: next_tick gets a #[cfg(test)] hook (tests::elapsed) that lets a test set the elapsed time on its own thread, and both frame tests take a shared CLOCK_TEST lock. I traced the new exact assertions against next_tick on main: the late origin poll at 6 ms takes the passed tick, the next zero-timeout poll times out without a token, the flips at 5/10/20/25 ms land on ticks +0/+1/+3/+4, and the late flip at 40 ms takes the latest passed tick, with the next one 5 ms out. These are the behaviours the doc comment on next_tick describes, so the tests check the intended contract, not just the current output. The release build is unaffected. CI check passes on this head and the branch merges cleanly.

Reply to the author: the controlled-time version is an improvement over the earlier sleep-based one, and it covers the origin-poll failure from the linked CI run. The verdict stays merge-candidate.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163905210 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#issuecomment-7163905210). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:31:39Z. --- <!-- victory-triage v1 head=303be14ec53ab5ca1ce2ea9a0e246a7aa0b785e7 verdict=merge-candidate at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Merge candidate (test-only).** The head moved to `303be14` (main merged in, plus a new test commit). The frame tests in `crates/victory-gpu/src/frame.rs` no longer depend on scheduling: `next_tick` gets a `#[cfg(test)]` hook (`tests::elapsed`) that lets a test set the elapsed time on its own thread, and both frame tests take a shared `CLOCK_TEST` lock. I traced the new exact assertions against `next_tick` on `main`: the late origin poll at 6 ms takes the passed tick, the next zero-timeout poll times out without a token, the flips at 5/10/20/25 ms land on ticks +0/+1/+3/+4, and the late flip at 40 ms takes the latest passed tick, with the next one 5 ms out. These are the behaviours the doc comment on `next_tick` describes, so the tests check the intended contract, not just the current output. The release build is unaffected. CI `check` passes on this head and the branch merges cleanly. Reply to the author: the controlled-time version is an improvement over the earlier sleep-based one, and it covers the origin-poll failure from the linked CI run. The verdict stays merge-candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 20:06:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T19:37:26Z.


303be14 also covers the origin poll from the #2729 CI failure. The test now controls elapsed time on its own thread while calling the normal frame API. With the same delayed poll on 013f797 (98578ea combined with main 13f91ca), the old TIMEOUT assertion received S_OK in all 10 attempts. The revised test checks that the late poll consumes the elapsed tick, the next poll times out without changing its token, and the flag still starts an early frame. The flip cases use the same controlled time.

Both frame tests passed in 50 parallel repetitions. The full GPU suite on WARP passed 198 tests with one ignored under each debug setting. Strict Clippy in both feature configurations and asset policy passed.

Please retain the Git author if you reapply the test. If you fold it into another commit, please add Co-authored-by: andrewpozdnakov7-jpg [email protected].

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172550467 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#issuecomment-7172550467). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T19:37:26Z. --- [303be14](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/303be14ec53ab5ca1ce2ea9a0e246a7aa0b785e7) also covers the origin poll from the [#2729 CI failure](https://github.com/Marvisak/VIctory/actions/runs/45684843740/job/139454597062). The test now controls elapsed time on its own thread while calling the normal frame API. With the same delayed poll on 013f797 (98578ea combined with main 13f91ca), the old TIMEOUT assertion received S_OK in all 10 attempts. The revised test checks that the late poll consumes the elapsed tick, the next poll times out without changing its token, and the flag still starts an early frame. The flip cases use the same controlled time. Both frame tests passed in 50 parallel repetitions. The full GPU suite on WARP passed 198 tests with one ignored under each debug setting. Strict Clippy in both feature configurations and asset policy passed. Please retain the Git author if you reapply the test. If you fold it into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.
fuzeofficlal commented 2026-11-26 19:24:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:24:10Z.

Review: APPROVED


Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test --locked -p victory-gpu --lib frame:: (10 consecutive runs) — 10/10 passed (2 passed, 0 failed per run, 0.01s)
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings
  • cargo xtask policy — ok (191 files ok)

Review notes

  • #[cfg(not(test))] production timing in next_tick is unchanged (c.start.elapsed().as_nanos()), and the #[cfg(test)] ELAPSED override + CLOCK_TEST mutex removes scheduling flakiness across both tests while explicitly covering the skipped-tick late-wake behavior.
  • Minor non-blocking notes:
    • Because ELAPSED is thread_local! and waits_begun_together_take_different_ticks calls next_tick sequentially on one thread (and waits_end_on_ticks_and_count_frames no longer checks wall-clock sleep duration), real Instant progress and multi-thread contention are not directly timed here.
    • Comment/formatting nits: the doc comment at frame.rs:306-308 still mentions (two threads), the loop comment at frame.rs:271-273 describes a timed-out origin poll while the mocked timestamps return S_OK, and two assert_eq! lines around frame.rs:296 exceed rustfmt line width.
<!-- greyfinch-sync:Marvisak/VIctory:review:6079495965 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#pullrequestreview-6079495965). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:24:10Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`63bcca43`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test --locked -p victory-gpu --lib frame::` (10 consecutive runs) — **10/10 passed** (**2 passed, 0 failed** per run, `0.01s`) - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings - `cargo xtask policy` — ok (`191 files ok`) ### Review notes - `#[cfg(not(test))]` production timing in `next_tick` is unchanged (`c.start.elapsed().as_nanos()`), and the `#[cfg(test)]` `ELAPSED` override + `CLOCK_TEST` mutex removes scheduling flakiness across both tests while explicitly covering the skipped-tick late-wake behavior. - Minor non-blocking notes: - Because `ELAPSED` is `thread_local!` and `waits_begun_together_take_different_ticks` calls `next_tick` sequentially on one thread (and `waits_end_on_ticks_and_count_frames` no longer checks wall-clock sleep duration), real `Instant` progress and multi-thread contention are not directly timed here. - Comment/formatting nits: the doc comment at `frame.rs:306-308` still mentions `(two threads)`, the loop comment at `frame.rs:271-273` describes a timed-out origin poll while the mocked timestamps return `S_OK`, and two `assert_eq!` lines around `frame.rs:296` exceed `rustfmt` line width.
Dukestar69 commented 2026-11-26 23:08:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:08:25Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Allowing the frame clock test to tolerate skipped ticks after a late frame eliminates flaky timing failures cleanly.
  • cargo test -p victory-gpu --lib frame:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081356594 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2265#pullrequestreview-6081356594). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T23:08:25Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Allowing the frame clock test to tolerate skipped ticks after a late frame eliminates flaky timing failures cleanly. - `cargo test -p victory-gpu --lib frame:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2265:upstream-pr/2265'
git switch 'upstream-pr/2265'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2265'
git switch 'upstream-pr/2265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2265'
git switch 'upstream-pr/2265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2265'
git switch 'main'
git merge --squash 'upstream-pr/2265'
git switch 'main'
git merge --ff-only 'upstream-pr/2265'
git switch 'main'
git merge 'upstream-pr/2265'
git push origin 'main'
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!2263
No description provided.