GPU: two frame waits that wake together take two ticks #357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/357"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from fxceless/victory-fork. Originally posted by JordanFableFur on 2026-11-24T23:50:32Z.
What
Two waits for one event kind could both end on the same tick: each computed the next tick, slept, and raised
lastwithfetch_maxwithout looking at what it returned, so both reportedS_OKon one tick — an event happening once per tick handed two waiters the same one.A wait now claims its tick through
fetch_max's previous value. One that lost the race waits again on the next tick, with what it has already slept taken off its time-out, so the caller's deadline does not stretch and the retry does not extend it.Fixes #244.
Testing
A regression starts two flip waits together and asserts both return
S_OKand that the next tick after the run is the one after both (each took its own tick). The existing single-waiter test is unchanged and passes.Validated on Windows CI (fork-run of the repository workflow): clippy both builds and the full test suite pass: https://github.com/JordanFableFur/victory-fork/actions/runs/45513129011
AI use: written with Codex and Claude Code (GPT-5.2 Codex); reviewed and posted with my approval. No game files were used.
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:55:36Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
267a784b0eℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:50:45Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
267a784ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:55:36Z.
Code review location:
crates/victory-gpu/src/frame.rs; line 165With three waits for the same kind targeting tick N, the two initial losers both retry tick N+1. This second
fetch_maxignores its previous value, so both retries returnS_OKeven though only one claims that tick; a synchronized three-waiter probe produced three successes whileLASTadvanced by only two ticks. This can also occur with two threads if the first winner starts another wait. Keep the ownership check in a retry loop until a tick is actually claimed or the deadline expires.Useful? React with 👍 / 👎.
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:55:36Z.
Code review location:
crates/victory-gpu/src/frame.rs; line 157When the initial sleep wakes late, subtracting its requested duration leaves more retry time than the caller actually has. For example, with a 30 ms timeout, a requested 20 ms sleep that wakes at 25 ms leaves only 5 ms, but this calculation allows another 10 ms sleep and returns
TIMEOUTat 35 ms. A controlled timing probe reproduces that overrun without any oversleep on the retry itself. Use an absolute deadline and recompute the remaining duration from elapsed time before sleeping again.Useful? React with 👍 / 👎.
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:55:36Z.
Code review location:
crates/victory-gpu/src/frame.rs; line 163In the Windows
diagnosticspath, a losing waiter executes this additional sleep, but the laterC::PaceUsupdate still uses only the outerwait.min(limit). Consequently, two simultaneous waits that sleep for approximately three intervals are reported as sleeping for only two incopystat's per-frame summary, hiding the added pacing cost from performance measurements. Accumulate the retry sleep, including the retry-timeout branch, in the reported total.Useful? React with 👍 / 👎.
Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:55:36Z.
Code review location:
crates/victory-gpu/src/frame.rs; line 285When both waits incorrectly finish on a single tick,
endis simply that tick, andnext_tick(FLIP)can still returnend + 1because it schedules afterLAST[2]. This assertion therefore does not establish that the waits claimed distinct ticks; running the added test block against the pre-changewaitimplementation still passes. Synchronize the starts and observe the claimed ticks or their progression so the regression test rejects the original race.Useful? React with 👍 / 👎.
Imported from fxceless/victory-fork. Originally posted by JordanFableFur on 2026-11-25T00:32:57Z.
All four findings addressed in
f005ddd:fetch_max's previous value each time, so three synchronized waiters take three ticks.limit.saturating_sub(slept)per attempt), so a late wake does not stretch the caller's time-out.C::PaceUs(slept.min(limit)).LASTmoved exactly two on across two barrier-synchronized waits, which the pre-change code fails.Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:17:54Z.
Duplicate of #281?
Imported from fxceless/victory-fork. Originally posted by JordanFableFur on 2026-11-25T01:46:18Z.
Closing — #281 fixes the same issue (#244) and was opened first, with the same claim-and-retry shape. Thanks for flagging.
Pull request closed