GPU: two frame waits that pick the same tick no longer both end on it #325

Open
github-bot wants to merge 1 commit from github-bot/gh-325 into main AGit
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 23:34 UTC · original
RenzoWit35:fix/244-flip-wait-claims-its-tick → main · +110 −23 · 1 files · 1 commits · open

Fixes #244.

A wait chose its tick before sleeping and then advanced LAST with fetch_max, ignoring the
previous value, so two concurrent waits (two FLIP waits, or both on the late path) could both
return S_OK on one tick. The wait (now in claim()) ends only if its fetch_max moved LAST
past the previous value. Otherwise it waits for the next tick against the original deadline,
so a retry never lengthens the caller's time-out.

Tests: two concurrent waits end on different ticks (three rounds); three waits aligned on a
tick, with 150 ms time-outs and 100 ms ticks, give exactly one S_OK and two time-outs within
the limit (on main all three ended on the same tick). The frame tests share the global clock,
so they now take a test lock.

Note for review: the existing waits_end_on_ticks_and_count_frames relies on sleeps landing
within a 5 ms tick; on a heavily loaded machine it can fail on main too.

Testing

On Windows 11, MSVC Rust 1.98.1, branch alone on top of main (2119b0e): cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, and cargo test --workspace --locked all pass. The new regression test fails on main and passes here. All nine fix branches for #242-#250 also pass together when merged.

🤖 Generated with Claude Code

**@⁠RenzoWit35** on GitHub · 2026-11-24 23:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/325) `RenzoWit35:fix/244-flip-wait-claims-its-tick` → `main` · +110 −23 · 1 files · 1 commits · open Fixes #244. A wait chose its tick before sleeping and then advanced `LAST` with `fetch_max`, ignoring the previous value, so two concurrent waits (two FLIP waits, or both on the late path) could both return `S_OK` on one tick. The wait (now in `claim()`) ends only if its `fetch_max` moved `LAST` past the previous value. Otherwise it waits for the next tick against the original deadline, so a retry never lengthens the caller's time-out. Tests: two concurrent waits end on different ticks (three rounds); three waits aligned on a tick, with 150 ms time-outs and 100 ms ticks, give exactly one `S_OK` and two time-outs within the limit (on `main` all three ended on the same tick). The frame tests share the global clock, so they now take a test lock. Note for review: the existing `waits_end_on_ticks_and_count_frames` relies on sleeps landing within a 5 ms tick; on a heavily loaded machine it can fail on `main` too. ## Testing On Windows 11, MSVC Rust 1.98.1, branch alone on top of `main` (2119b0e): `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, and `cargo test --workspace --locked` all pass. The new regression test fails on `main` and passes here. All nine fix branches for #242-#250 also pass together when merged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A wait chose its tick before sleeping and then advanced LAST with
fetch_max, ignoring what was there. Two waits for the same event that
picked the tick before either ended (two FLIP waits on two threads, or
both on the late path) both returned S_OK on one tick. The wait now
claims its tick only if fetch_max moved LAST past the previous value;
otherwise it waits for the next tick against the same deadline, so a
retry never lengthens the caller's time-out. The loop is in claim(),
which wait() calls.

Tests: two concurrent waits end on different ticks (three rounds), and
three waits aligned on a tick with a 150 ms time-out at 100 ms ticks give
exactly one S_OK and two time-outs within the limit (all three got the
same tick before). The frame tests share the global clock, so they now
take a lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:40:46 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:16 UTC · original

Duplicate of #281?

**@⁠kaayzouee** on GitHub · 2026-11-25 01:16 UTC · [original](https://github.com/fxceless/victory-fork/pull/325#issuecomment-7149389118) Duplicate of #281?
github-bot force-pushed github-bot/gh-325 from b8d64263e2 to 8193c58d8b 2026-11-26 16:29:25 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/325/head:github-bot/gh-325'
git switch 'github-bot/gh-325'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-325'
git switch 'github-bot/gh-325'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-325'
git switch 'github-bot/gh-325'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-325'
git switch 'main'
git merge --squash 'github-bot/gh-325'
git switch 'main'
git merge --ff-only 'github-bot/gh-325'
git switch 'main'
git merge 'github-bot/gh-325'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.