GPU: two frame waits that wake together take two ticks #357
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!357
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/357/head"
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?
@JordanFableFur on GitHub · 2026-11-24 23:50 UTC · original
JordanFableFur:fix/frame-flip-tick-race→main· +48 −7 · 1 files · 2 commits · closed without mergingWhat
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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:50 UTC · original · edited 2026-11-24 23:55 UTC
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.
@JordanFableFur on GitHub · 2026-11-25 00:32 UTC · original
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.@kaayzouee on GitHub · 2026-11-25 01:17 UTC · original
Duplicate of #281?
@JordanFableFur on GitHub · 2026-11-25 01:46 UTC · original
Closing — #281 fixes the same issue (#244) and was opened first, with the same claim-and-retry shape. Thanks for flagging.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:55 UTC · original
On
crates/victory-gpu/src/frame.rsline 165 (outdated):With 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 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:55 UTC · original
On
crates/victory-gpu/src/frame.rsline 157 (outdated):When 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 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:55 UTC · original
On
crates/victory-gpu/src/frame.rsline 163 (outdated):In 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 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:55 UTC · original
On
crates/victory-gpu/src/frame.rsline 285 (outdated):When 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 👍 / 👎.
Pull request closed