GPU: the frame's wait for pipelines is one budget for all recording threads #2111
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2111
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2111"
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?
@r4tedx on GitHub · 2026-11-25 05:11 UTC · original
r4tedx:gpu/pipeline-wait-budget→main· +211 −10 · 3 files · 3 commits · openWhat is wrong
pipeline/make.rslets a draw wait for its host pipeline while the title frame has budget left:BUDGETis 500 ms, documented as "waiting allowed per title frame, over all threads".waitdid not keep to that. It read what was left of the budget when the wait began and added its own time only when it returned:The title records its lists on several threads. A thread that begins to wait while another still waits reads a budget nobody has charged yet and gets all of it, from its own start. So the frame can stand still for nearly twice the budget (a thread that begins just before the first one returns), and its threads wait a whole budget each.
These waits are on the recording threads, outside
Host::execute, so none of the frame line's times holds them. A frame that stood waiting for pipelines only showed as a longer frame.What changes
Waits): time counts while at least one thread waits, once however many do, and not between waits. Waits one after the other share what is left, as before. A wait that ends early because its pipeline was made leaves the rest to later waits, as before. A thread still naming the frame before (it read the frame number, then lost the processor) no longer brings a fresh budget back: onmaina different frame number reset the count....; 12.3 ms/frame of draws waiting for pipelines.A title recording on one thread behaves as on
main.Measured (synthetic, CPU threads only, no GPU and no title)
Four threads call
wait125 ms apart for pipelines that are never made, on the 500 ms budget:main(940d32f)How much this is worth in the title depends on how often several recording threads wait in one frame, which I have not measured: the title was not run. The new number on the frame line is there so that a tester's log shows it.
Tests
No GPU needed:
waits_of_a_frame_share_its_budget: the accounting on given instants (waits that overlap, waits one after the other, a spent budget, a stale frame number, a frame that begins while a wait is under way, the time taken for the frame line while a wait is under way).a_thread_that_waits_while_another_does_gets_no_budget_of_its_own: four real threads waiting on pipelines never made; every wait is over one budget after the first began.Both fail on
main's algorithm.cargo test -p victory-gpu --features diagnosticswithVICTORY_D3D12_WARP=1(software adapter): 148 passed, 0 failed, 2 ignored.cargo clippy -p victory-gpu --all-targetsis clean.Related
main.fxceless/victory-gta6diagnosed the same defect in its own tree (it measured 2.5 s of waiting per frame summed over five recording threads). The idea of looking here is theirs; the code is written formain.AI-assisted (Claude Code). No game data was used.
🤖 Generated with Claude Code
842b0cb) into the pipeline wait budget branch a8316c9de9@upipibi on GitHub · 2026-11-25 05:14 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
0ef11e5.victory-gpu: 143 passed, 2 failed, 2 ignored. The newwaits_of_a_frame_share_its_budgetanda_thread_that_waits_while_another_does_gets_no_budget_of_its_ownpass. The 2 failures are #1744's heap-cap failures onmain. Same asmainon this hardware.Overlap, from reading: #275 (open, conflicting with
main) fixes the same overshoot inpipeline/make.rswith an atomic reserve-and-refundFrameBudget, so concurrent recording threads can't spend the 500 ms twice. It also changes the wake-ups and the library saves. This PR is the narrow version of that fix.AI-assisted (Claude Code).
@r4tedx on GitHub · 2026-11-25 05:52 UTC · original
@catminou4 on slow compiles: the budget is per title frame, as on
main; only how the waits of several threads add up changes. A pipeline that takes longer than the budget to compile behaves as before: its draw waits until the frame's budget is spent and is dropped, and the next frame's first wait gets a whole budget again while the worker keeps compiling. What changes is that a second thread beginning to wait during the first's wait no longer gets a budget of its own (synthetic, four threads 125 ms apart on pipelines never made: the frame stood still 882 ms onmain, 505 ms here). Covered bywaits_of_a_frame_share_its_budget, which includes a spent budget and a frame that begins while a wait is under way.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 10:42 UTC · original · edited 2026-11-26 03:20 UTC
Automated triage for the maintainers.
Thanks for merging
mainin. The new head merges cleanly and is reviewed again. The verdict from before the conflict still holds.In
crates/victory-gpu/src/pipeline/make.rs, the newWaitstype replaces the per-thread budget read inwaitwith one budget per frame. That budget counts time while any thread waits and charges overlapping waits only once. A stale frame number no longer resets it.Waits::takefeeds the newms/frame of draws waiting for pipelinesfigure inMeter(host.rs). Since the rebase, the only change is the three-argument pipeline call in the threaded test.waits_of_a_frame_share_its_budgettests the accounting with fixed instants, which is easy to check by hand.This overlaps #275, the older and broader fix, which no longer merges. This PR is the narrow fix on current
main.Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.
Generated by Claude Code
@r4tedx on GitHub · 2026-11-26 02:58 UTC · original
Merged main
842b0cbinto the branch (mergea8316c9d, no force-push), head noweb868bce. The follow-up commit makes the staggered-waits test build its pipeline the way main's tests now do (three-argument call). Verified on this head:cargo clippyclean;VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1: 248 passed, 0 failed, 1 ignored. Synthetic tests on WARP only, no title data used.AI-assisted
@DenRakEiw on GitHub · 2026-11-25 05:18 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib pipeline::— 17 passed, 0 failedcargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean shared per-frame pipeline wait budget across recording threads. Looks good.
AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 05:48 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Frame's pipeline wait is one budget for all requests — replaces per-request waits; check the budget arithmetic against slow pipeline compiles.
@fuzeofficlal on GitHub · 2026-11-26 15:22 UTC · original · approved these changes
Reviewed
host.rs,pipeline.rs, andpipeline/make.rsateb868bcemerged ontoorigin/main(63bcca43) and verified on RTX 5090 and WARP (VICTORY_D3D12_WARP=1) withVICTORY_D3D12_DEBUG=1.Concurrency & accounting audit
Waits(crates/victory-gpu/src/pipeline/make.rs:188,223,239,253) replaces the racy per-thread budget read with a shared mutex-protected frame deadline (s.since + budget.saturating_sub(s.used)): overlapping recording threads share one deadline and charge wall time once, stale frame numbers (frame < s.frame) cannot reset the budget,take(now)advancess.sinceands.usedtogether so active wait deadlines stay invariant, andsaturating_sub/saturating_duration_sinceavoid underflow.wait_within(pipeline/make.rs:337) uses an RAIIUnderguard soend()always runs even on unwind.pipeline::take_waited_ms(pipeline.rs:268) is gated#[cfg(windows)]and wired intoMeterathost.rs:3077.Verification
cargo run -p xtask -- policy: 191 files ok.cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features): clean.pipeline:: host::withVICTORY_D3D12_DEBUG=1: 55/55 passed on RTX 5090 (skippingdynamic_slots_are_held_until_released) and 59/59 passed on WARP (--features diagnostics, skipping the pre-existingmaincompositor_failure_presents_primary_in_the_same_frameDebug Layer mismatch), includingwaits_of_a_frame_share_its_budget(pipeline/make.rs:495) anda_thread_that_waits_while_another_does_gets_no_budget_of_its_own(pipeline/make.rs:548).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.