GPU: prevent concurrent frame waits from consuming the same tick (#244) #281
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/281"
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 adritoyalser on 2026-11-24T23:11:54Z.
Fixes #244.
Summary
crates/victory-gpu/src/frame.rs(wait), check the previous value returned bylast(kind).fetch_max(tick, Ordering::AcqRel)so only one waiter can claim a given tick.tick(or a later one), recomputenext_tick(kind)and retry against the caller's originaldeadline(started.checked_add(limit)), so retries never extend the requested timeout.diagnostics,PaceUsand theframe waitdebug log now record actualstarted.elapsed()across any retry iterations rather than the single-attemptwait.min(limit).frame::tests:concurrent_flip_waits_consume_distinct_ticks: two barrier-synchronizedFLIPwaits both returnS_OKand advanceLAST[2]by at least 2.concurrent_flip_retry_does_not_extend_timeout: two barrier-synchronizedFLIPwaits with a 200 ms interval (started after both threads align at the first barrier) and 285 ms timeout produce exactly oneS_OKand oneTIMEOUTwithLAST[2]advancing by 1.Verification
cargo test -q -p victory-gpu --lib --locked frame::tests(3 passed, 0 failed)cargo clippy -q -p victory-gpu --all-targets --locked -- -D warnings(0 warnings)cargo clippy -q -p victory-gpu --all-targets --all-features --locked -- -D warnings(0 warnings)Imported from fxceless/victory-fork. Originally posted by ErRusso on 2026-11-24T23:19:09Z.
Review: CHANGES_REQUESTED
Reviewed at
3e9cbe1against2119b0e.The tick-claim fix is correct:
fetch_max's previous value is the right claim test, and the retry loop is bounded bystarted + limit, so it cannot extend the caller's timeout. I built the head forx86_64-pc-windows-gnuand ranframe::testsunder Wine: 3/3 passed, and each new concurrency test passed 50/50 stress runs.Requesting changes for one test-robustness issue:
concurrent_flip_retry_does_not_extend_timeoutuses a 60 ms interval and an 85 ms timeout. If both threads are first scheduled more than 60 ms afterset_interval(a loaded Windows CI runner), both compute the second tick at 120 ms, which is outside the 85 ms deadline, and both returnTIMEOUT. The test then fails its "exactly oneS_OK" assertion. Widen the margin (for example 200 ms interval / 285 ms timeout) or make the clock injectable.Non-blocking:
PaceUsnow records actual elapsed time rather thanwait.min(limit). That is arguably more accurate, but it changes diagnostics semantics; please confirm it is intentional or note it in the description.let _ = tick;is only needed becausetickis used solely by the diagnostics log;_tickor a cfg-scoped use would be clearer.\tick,\next_tick,rame::tests), likely escaped tabs/newlines.Imported from fxceless/victory-fork. Originally posted by adritoyalser on 2026-11-24T23:21:41Z.
Thanks for the thorough review @ErRusso! Addressed all points:
concurrent_flip_retry_does_not_extend_timeoutto a 200 ms interval / 285 ms timeout and movedset_intervalinside the first barrier phase so thread-spawn delay cannot eat into the first tick window.tickto_tickand droppedlet _ = tick;.PaceUsintentionally records actual elapsed time (started.elapsed()) across retries.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.