Skip to content

Tests: a tick between the origin polls' zero-time-out asks is asked again - #3080

Open
kotekompotek wants to merge 1 commit into
Marvisak:mainfrom
kotekompotek:tests/origin-poll-tick-boundary
Open

kotekompotek wants to merge 1 commit into
Marvisak:mainfrom
kotekompotek:tests/origin-poll-tick-boundary

Conversation

@kotekompotek

Copy link
Copy Markdown

Summary

CI on #2810 failed frame::tests::waits_end_on_ticks_and_count_frames at frame.rs:235 (left: S_OK, right: TIMEOUT) — a flake, not that PR's change (it only touches host.rs copy ordering; this test passed at its previous head).

The test polls the origin with a zero time-out twice in a row (lines 231 and 235). A wait only times out while the next tick is not due, and the interval here is 2 ms — a host that wakes the thread a whole tick late between the two asks makes the second one return S_OK. Probability per run is the inter-ask gap over the interval, which a loaded CI runner can hit.

  • Each zero-time-out ask now retries (bounded) until one really times out. A hit takes its tick, so the retry sees the following tick a whole interval out — the loop terminates in one extra ask in practice.
  • early == second + 1 becomes early > second: a boundary hit takes a frame token too, so a retry may have bumped early/second further. The consecutive-token invariant (next == early + 1) and the timeout-token semantics are preserved.

The second half of the test (50 ms flip ticks, unbounded waits) is unaffected.

Test plan

Generated with Devin

…gain

waits_end_on_ticks_and_count_frames polls the origin with a zero
time-out twice in a row; a wait only times out while the next 2 ms tick
is not due, and a host that wakes the thread a whole tick late between
the asks (seen in CI: left S_OK, right TIMEOUT) makes the second one
succeed. Each ask now retries until one really does time out; a hit
takes its tick, so the retry sees the following tick a whole interval
out. Frame tokens a boundary hit took are counted in the asserts.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown

Independent verification for my claim #1633 (comment). Test report only; no source review. Disclosure: checks run by Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol).

Tested: PR head 5a4f4697d18376d8004c91061d4b01706e4ce6e9, parent 63bcca43c6a00a758510398fa43096ce7e4f7df0 (current main). Windows 11 x64 (16 logical CPUs), Rust 1.98.1, cargo -j 4 --locked. CPU only; no GPU or device used. Both revisions were run from separately built victory-gpu lib test binaries, frame:: filter (2 tests: waits_begun_together_take_different_ticks, waits_end_on_ticks_and_count_frames), each run capped at 60 s, parent and head interleaved.

Condition Parent Head
Idle machine, 40 runs each 40/40 pass 40/40 pass
Moderate load (12 busy-loop processes on 16 CPUs), 40 runs each 25/40 pass 37/40 pass
Heavy load (32 busy-loop processes, 2x oversubscribed), 60 runs each 1/60 pass 20/60 pass

Failure sites:

  • Parent under load: all failures are waits_end_on_ticks_and_count_frames at the frame.rs zero-time-out assertion (left: 0, right: 1). That is the assertion the PR rewrites. Under moderate load this was 13 of 15 failures, the other 2 being the 10 ms bound at line 271.
  • Head, moderate load: 3 failures, all the before.elapsed() < 10 ms assertion (parent line 271, head line 281). It is an existing assertion this PR does not touch, and it fails at the parent in the same runs. No failure at the changed lines.
  • Head, heavy load: 31 failures are the PR's own ten zero-time-out waits each met a due tick panic. 9 are the 10 ms assertion at line 281. At 2x oversubscription ten consecutive asks all met a due tick, so the retry loop does not make the test immune there.

Conclusion: reproducible, not a one-off flake. The parent's zero-time-out assertion fails often under CPU contention, and the head removes most of it (moderate load: 25/40 to 37/40; heavy load: 1/60 to 20/60). Idle runs were clean in both. The remaining head failures under load come from the PR's retry bound (heavy load only) and from the separate 10 ms elapsed-time assertion, which also fails at the parent. They are timing-sensitive tests under artificial contention, not evidence of a logic regression. I did not test CI-like conditions. Scratch worktree, binaries and cargo target directory were removed afterwards.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Test-only fix for a real flake in frame::tests::waits_end_on_ticks_and_count_frames. With a 2 ms interval, next_tick returns S_OK for a zero-time-out wait once more than a tick has passed since the last one taken, so a thread that wakes late on a loaded runner fails the TIMEOUT assertion. The bounded retry takes the due tick and then times out on the next one. Relaxing early == second + 1 to early > second is correct because each origin hit also bumps FRAME, and next == early + 1 still checks that tokens are consecutive. No change outside the test. CI: passing.


Generated by Claude Code

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib frame:: -- --test-threads=1: 2/2 passed (waits_begun_together_take_different_ticks and waits_end_on_ticks_and_count_frames).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly removes the timing flake when a tick lands between zero-timeout origin polls.

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

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified 5a4f4697 locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings: clean (3.38s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory-gpu --lib --locked frame::: 2 passed, 0 failed (0.31s), plus 20/20 consecutive runs (6.92s) and 40/40 across 8 concurrent workers on the compiled test binary. Production code (frame.rs:1-215) is unchanged.

One test-assertion gap in timed_out(TOKEN_ON_TIMEOUT, &mut early) (crates/victory-gpu/src/frame.rs:236-251): passing the same &mut early across retries can mask a timeout-token regression. Because wait also writes *token on S_OK (frame.rs:156-162), if an earlier retry hits a due tick (S_OK) and updates early, and the next call returns TIMEOUT without writing *token, early keeps the S_OK value and the subsequent early > second && next == early + 1 assertions still pass.

Please reset *token = 0 (or record current() before each attempt) so the test directly asserts that the specific TIMEOUT call itself wrote the incremented frame token (and that the flags == 0 TIMEOUT left *token untouched).

@futurepro62

Copy link
Copy Markdown

NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head 5a4f469 (on its base 63bcca4).

Tested

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@jaschinski97-ops

Copy link
Copy Markdown

Fresh Windows MSVC CI evidence for the zero-timeout origin poll: on main 63bcca43 plus the save-only #2675, frame::tests::waits_end_on_ticks_and_count_frames failed at frame.rs231, observed S_OK(0), expected TIMEOUT(1). The same frame.rs is unchanged in that PR. Current #2677 on the same main passed CI.

Failing job: https://github.com/Marvisak/VIctory/actions/runs/45850563859/job/140015510444 . App tests and both Clippy configurations passed before the workspace stopped at this frame test (230 GPU tests passed, 1 failed, 1 ignored).

This appears to be the same live-clock zero-poll assumption addressed here, rather than a save migration failure. Reporting the existing CI result only; no duplicate implementation or new GPU test run. AI-assisted triage with Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants