Repository navigation
GPU: a frame wait takes its tick before it sleeps - #174
Conversation
frame::wait marked the tick it waited for as taken (LAST) only after the sleep, outside the clock's lock, so two threads waiting for one event kind at once both got the same tick and both returned on it, against the module's once-per-tick rule (an origin wait then begins two frames in one interval). next_tick now takes the tick under the clock's lock when the wait comes within its time-out; a time-out takes none, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
No game data used. |
|
The Static review, not built or run. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review note: merged onto current ( From building only; I have no copy of the title. |
The previous commit dropped the tick next_tick returns, but the diagnostics build's tracing::debug! still names it (E0425). Bind it again; it is unused without the feature, so that lint is allowed there. Reported by Sunkiller-qc and r4tedx. cargo check -p victory-gpu passes with and without --features diagnostics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Sunkiller-qc and @r4tedx, you are right. Fixed on the new head |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 882664e on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed), including waits_begun_together_take_different_ticks.
The race is real. next_tick chose the tick under the clock lock, but LAST was only bumped after the sleep, with the lock released, so two concurrent waits for one kind could both end on tick T (two FRAME increments for the origin). Taking the tick inside next_tick when wait <= limit, and taking none on a time-out, fixes it.
Interaction with #319, which touches the same function. #319 adds an early return to next_tick for a late non-origin wait (return (passed, Duration::ZERO)) and relies on wait to mark that tick afterwards. This PR removes the mark in wait and adds its own mark only at the end of next_tick, so with both applied the early-return path never takes its tick. Merging this onto a branch with #319 confirms it: frame::tests::waits_end_on_ticks_and_count_frames fails at frame.rs:254 (the LAST == flipped + 1 check). Git reports no textual conflict, so this would slip through.
Fix for whichever lands second: in #319's early-return branch, take the tick before returning, i.e. last(kind).fetch_max(passed, Ordering::Relaxed); return (passed, Duration::ZERO);. Its limit check is trivially true, since the wait is zero.
Approving this PR's own change. I have not merged it into our fork, which already has #319.
AI-assisted (Claude Code).
Applied as the net diff of upstream PR Marvisak#174 (head 882664e), 2 commits: 882664e,810f4422.
…ied together Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485 Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts. One change of mine: three of the PRs each add a `mod tests` at the end of pipeline/host.rs, so the merge defines `tests` three times (E0428). The second and third are named `library_tests` and `blend_tests`; nothing else changes. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (367 passed, 6 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ame wait bundle Taken from the bundle: 64 MB stacks for pipeline workers (#1129), no blending on integer render targets (#1152), root signature flag fallback (#626), read-only depth read states (#485, on our stored rtvs/dsv and bind_targets), enhanced texture barrier translation (#642, on our recording_list so continuation segments get it), indirect mesh dispatch (#24), the frame wait taking its tick before it sleeps (#174), and the make.rs unit tests (#1203). Kept from our side: - pipeline/make.rs: early() starts every compute pipeline at creation (b4e8419); the per-pipeline wake pair, per-frame budget, wait_compute and copystat counters. The bundle's the_wait_budget_is_spent_once_per_frame test is dropped (written for its fixed BUDGET; our FrameBudget tests cover it); a_pipeline_is_made_once now holds the tests' serial lock. - indirect.rs: our whole file (#40's overflow-safe clamp, DXC fallback for Wine, rectangle pass). #1279's structured-buffer clamp and its readback test (written for the old bound/done API) are left out. - draw.rs: NOT_MADE counter, user_dword, typed table nulls (table_view_props, mirror_for_draw); the depth test calls readable() directly since our tables() needs a host pipeline. - frame.rs: our `_tick` (the diagnostics log already names it). - list.rs: execute_indirect's DISPATCH_SINGLE mapping in one place; our tests beside the bundle's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Heads-up: #319 ( #174 moves taking the tick ( if kind != ORIGIN && passed > last_tick && passed > c.first {
last(kind).fetch_max(passed, Ordering::Relaxed);
return (passed, Duration::ZERO);
}Whichever of the two lands second needs this. It is in |
|
Automated triage for the maintainers. Merge candidate. In Note for whoever merges: #319 adds an early return in CI: no check runs on the head commit. Generated by Claude Code |
The
frame.rsmodule doc says each event kind (origin, vblank, flip) happens once per tick, so two waits for the same kind never end on the same tick.waitpicked the next tick innext_tickunder the clock's lock, but marked it as taken (LAST[kind]) only afterstd::thread::sleep, with the lock released. Two threads waiting for one kind at the same time therefore both read the sameLAST, both got tick T, and both returnedS_OKon it. For the origin, that begins two frames (FRAME+= 2) in one interval.next_ticknow takes alimit(the wait's time-out). When the tick comes within it,next_tickrecords the tick under the clock's lock, before anyone sleeps. A wait that times out takes no tick, as before. Sequential waits behave as before.Testing
cargo test --workspace: 265 passed, 4 ignored (need external files). Includes 1 new test,waits_begun_together_take_different_ticks: twonext_tickcalls before any sleep get different ticks, and a timed-out call leavesLASTalone. It fails on the old behaviour ("1 after 1"), checked by putting it back.cargo clippy --workspace --all-targets: no new warnings. The two that remain (xmem.rsandhost.rs:267) are onmain.cargo xtask policy: pass.rustfmt --checkonframe.rs: clean.🤖 Generated with Claude Code