GPU: graphics pipelines are made before compute ones, and compute never takes every worker #3025
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!3025
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3025"
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?
@Luislariosss on GitHub · 2026-11-26 03:42 UTC · original
Luislariosss:perf/pipeline-order→main· +169 −14 · 1 files · 1 commits · openProblem
In Grand Theft Auto VI's world about 180 compute pipelines take the host driver 3.7 s each on average (up to 24 s; the other compute pipelines take 0.1 s). Queued strictly by first use, they held every pipeline worker for minutes while the scene's graphics pipelines — which compile in milliseconds — waited behind them, and their draws were dropped until a pipeline was ready.
Change
crates/victory-gpu/src/pipeline/make.rs: the worker queues are split into four, taken in this order — graphics a draw waits for, compute a dispatch waits for, then those started early — and compute never holds more than all workers but one (if only one worker could be spawned, compute takes it, else nothing compute would ever be made). The count of compute compilations lives under the same lock as the queues, and the slot is given back through a guard, so a panic in the compiler cannot keep it and a worker about to sleep cannot miss the wake-up.Measurement (Ryzen 5 9600X, RX 9060 XT)
One 360 s run before and one after, same build profile and cache state:
232 tests, clippy clean.
Risk
When no graphics pipeline is queued, peak compute compilation is one worker lower, so a compute-only queue drains a little more slowly.
47069285a5to5abc4cd1fd@pickles976 on GitHub · 2026-11-26 03:49 UTC · original · edited 2026-11-26 19:06 UTC
Updated Wine verification:
018b56ac28fa6024eb142921acc03d4e43ccb177The two previously reported scheduler gates are now covered on this Wine host. Clean detached production head; 6 passed, 0 failed/ignored, 0.00 s after fresh 8.80 s compilation from
VIctory-pr3025-evening:a_pipeline_in_two_queues_takes_one_slotpasses: duplicate urgent/early entries reserve only one compute slot. It uses eight available workers, so the cap cannot conceal a second reservation. Source review confirms the claim now happens viataken.swap(true)insidenext, under the queue lock, beforecompute_busyincrements; the worker immediately ownsComputeSlot.a_compute_stream_is_queued_as_computepasses for a single compute stage withSome(graphics).Environment: Linux, Wine 11.0, Rust 1.98.1 Windows MSVC target, 16 GiB host, single test thread, 9 GiB memory / 512 MiB swap cgroup and 180 s timeout. These fixtures exercise CPU scheduling and a no-shader worker path, not real driver compilation or shader execution. No source modifications, no silently skipped fixture, no title launch. The earlier failing heads were not rerun.
This supersedes my earlier duplicate-reservation warning for this head, not the historical results below. It does not prove a loading-time/RAM improvement or a rendered world on this machine. Keep the duplicate and compute-stream regressions when rebasing or combining with slow-pipeline scheduling; #3296's reservation ownership is a separate implementation and needs separate evidence.
Evidence:
.compat-runtime/logs/verify-pr3025-fixed-wine-scheduling.log. AI-assisted verification/source review (OpenAI GPT-6 Astra).Earlier verification, preserved for historical refs:Updated verification, 2026-11-26 —
5abc4cd1fdedc81850a424592c583e38c0330fdd: isolated queue-order test now passes; duplicate-slot race remains.Same Linux / Wine 11.0 / 16 GiB / RTX 4060 Laptop host (CPU-only tests). Fresh
Compiling victory-gpu .../VIctory-pr3025-updated/...provenance for both runs, MemoryMax=9G / MemorySwapMax=512M.cargo test -p victory-gpu --lib graphics_go_first_and_compute_leaves_a_worker -- --nocapture --test-threads=11 passed, 0 failed, 0 ignored. Source review also confirms the normal compute completion now reachesWAITING.fetch_sub.next()andtakenoperations fails 0/1, withcompute_busy = 1, expected 0 after all modeled work completes. Probe restored afterward; no production edits. This is a forced interleaving with local queues and a modeled release branch, not a threaded end-to-end worker/GPU execution.Remaining interleaving (three workers is enough): enqueue the same
Arc<Pending>in wanted-compute queue 1 and early-compute queue 3. A callsnext(&mut queues, 3)and unlocks before itstaken.swap. B callsnextand also seestaken == false, reserving the second slot. A's swap wins; B's swap loses andcontinues before constructingComputeSlot. Only A returns its reservation; the duplicate's reservation leaks. Moving the preliminarytaken.loadintonextdoes not close the gap between dequeue and claim.Suggested minimal owner fix remains: construct
ComputeSlot(compute)immediately after dequeue, beforep.taken.swap(...)/continue, so every reserved slot has a guard even when the duplicate loses. Alternatively claim atomically innextbefore reserving and remove the second claim. Add coverage for the dequeue/dequeue/claim schedule, not only a duplicate whosetakenwas already set before dequeue. This finding is independent of the compute-only-stream classification concern raised by the other reviewer.Logs (local):
.compat-runtime/logs/verify-pr3025-updated-wine-priority.log,verify-pr3025-updated-wine-duplicate-probe.log. Wrapper supplies--locked --target x86_64-pc-windows-msvc. No title, memory-peak, GPU, or FPS claim. AI-assisted verification/report: omp, OpenAI Codex GPT-6 Astra.Historical report for the old head (retained for comparison):
Blocking isolated regression on the 16 GiB Wine 11.0 laptop (RTX 4060 Laptop GPU present, but this test does not use the GPU). Clean exact head
47069285a59c58c2ab4a30651b26ea868457dbd1; fresh-compiled Windows target;cargo test -p victory-gpu --lib graphics_go_first_and_compute_leaves_a_worker -- --nocapture --test-threads=1fails 0/1 atpipeline/make.rs:455: observedgraphics a draw waits for,compute a dispatch waits for,early graphics; expected alsoearly compute. In the isolated processWORKERSis set to 2;nextreserves the one compute slot, and the test repeatedly callsnextwithout simulating that the previous compute has finished/released its slot. The reported 232-suite pass may depend on a different globalWORKERSinitialization; the isolated result and source establish the issue. Log:.compat-runtime/logs/verify-pr3025-wine-graphics-priority.log(not attached).Two additional source-verified runtime accounting errors at
make.rs:389-406, independent of the fixture: (1) when a compute item is newly taken,p.make()finishes, thenif compute { continue; }skipsWAITING.fetch_sub(1), so queued compute increaseswaiting()permanently anddrained()may never run. (2)next()incrementscompute_busybefore thep.taken.swapcheck, but for an already-taken duplicate compute queue entry noComputeSlot(compute)is constructed, so its slot is never returned; subsequent compute work can starve with two workers. Suggest constructing the RAIIComputeSlot(compute)unconditionally immediately after dequeue, then checkingtaken; on newly taken work, callp.make(), drop the slot and run the existingWAITING.fetch_sub/cache save path for both graphics and compute. Update the test to model completion/release of the first compute slot before expecting another compute to be popped, ideally with an explicit worker-count parameter rather than a process-global OnceLock.No retail title trial: this head currently fails its own targeted test and the two accounting paths risk indefinite preparation. No claim about GPU or frame times here.
@steven-seagull27 on GitHub · 2026-11-26 03:53 UTC · original
The reserved worker preserved a real cold draw on RTX 5080 and WARP for
CreateComputePipelineState. Compute-only pipeline-state streams still occupied all eight workers at47069285. The difference comes fromqueue_indexusingp.graphics.is_none(). The stream constructor setsSome(graphics)even for a stream containing only a compute shader. The host compiler correctly recognized all eight resulting PSOs as compute.I queued eight valid synthetic compute pipelines as early starts and held their CPU compilation at a test barrier. A guest
DrawInstanced(3, 1, 0, 0)then requested a fresh graphics PSO and wrote one D32 pixel. The barrier opened after that first draw returned. Two warm draws used separate pixels, one after resetting the list. Both adapters gave the same results.63bcca4347069285Both warm pixels were 0.25 and the untouched control was 0.50 throughout. On the PR, the stream case waited 507–510 ms for the first draw. With stage-based classification it took 11.2 ms on RTX and 10.5 ms on WARP in this setup. These waits include the artificial CPU backlog.
I also measured the accounting paths identified in the Wine review. On the PR, all eight ordinary compute PSOs finished and the graphics PSO rendered. After promoting one queued early start, the idle pool still reported
WAITING=8andcompute_busy=1. The cherry-pick gives0/0for both constructor paths. It shares the stage check withHostPipeline::new, returns the slot on duplicate entries, and makes the isolated queue test independent of the global worker count. Cherry-pickc24afb9· Earlier queue review@Luislariosss on GitHub · 2026-11-26 04:12 UTC · original
Thanks for the review — all three points were real and are fixed in
5abc4cd:compute_busyleaked on a promoted duplicate.nextnow skips entries whosetakenis already set, so a pipeline queued twice never takes a slot;takenis only swapped once and the slot is released through a guard on the way out, a panic in the compiler included.WAITINGnever went down for compute. The decrement (and sodrained(), which saves the cache) now runs for every entry a worker really made, compute or graphics; the duplicate entry returns before touching it, sinceenqueuecounted it once.--all-features/two workers.nexttakes the worker count as an argument instead of reading the global (so the test does not depend on other tests),Pending::newgets its diagnostics argument, and the test now also checks that the early compute entry is left queued while one compute is being made, and that a single worker does take compute.cargo test -p victory-gpu --locked: 232 passed.--all-features: 247 passed.cargo clippy --all-targets --all-features -- -D warnings: clean.@steven-seagull27 on GitHub · 2026-11-26 05:48 UTC · original
Verified your
5abc4cdfixes the accounting on RTX 5080 and WARP. After eight ordinary compute builds and a queued promotion, bothWAITINGandcompute_busyreturned to zero. The first graphics draw rendered on both adapters.The compute-only pipeline-state stream still took all eight workers. With the same controlled CPU backlog, the first draw waited 505 ms on RTX and 506 ms on WARP and left its D32 pixel at the clear value (0.50). Both subsequent warm draws wrote 0.25. The stream constructor supplies
Some(graphics)even for a single compute stage, soqueue_indexputs it in the graphics queue.Cherry-pick
145b380directly on your new head makes the queue use the host compiler’s stage check. With that commit, seven workers entered compute compilation and the first draw wrote 0.25 through both constructor paths on both adapters. All five queue tests passed, including the new stream case.@Marvisak on GitHub · 2026-11-26 06:16 UTC · original
Automated triage for the maintainers.
The four-queue ordering and the cap on compute workers in
crates/victory-gpu/src/pipeline/make.rsare a reasonable answer to the measured backlog, and theWAITINGaccounting now runs for compute too. Two problems remain at this head:next()incrementscompute_busywhen it dequeues an entry whosetakenis still false, butwork()only creates theComputeSlotguard afterp.taken.swap(true). If the samePendingsits in queue 1 and queue 3, two workers can dequeue both entries before either swaps. The loser then hitscontinuewithout a guard, and its slot is never given back. With 2 workers that is enough to stop compute compilation entirely. Fix: createComputeSlot(compute)right afternext()returns, before thetaken.swap/continue. Or claimtakeninsidenext()under the queue lock and drop the second swap. Please add a test for the dequeue/dequeue/claim order.queue_indexusesp.graphics.is_none(), but the stream path passesSome(graphics)even when the only shader is compute.HostPipeline::new(pipeline/host.rs) decides compute by stage ([cs] if cs.stage == "compute"). So stream-created compute PSOs bypass the cap, and the problem this PR targets can come back through that path. Please classify by the shader stages, asHostPipeline::newdoes.The added doc comment on
Queuesis long and specific to one measurement. A one-line rule (graphics first, compute keeps one worker free) would fit the repo's short-docs rule better.CI:
checkpassing.Generated by Claude Code
5abc4cd1fdto018b56ac28@fuzeofficlal on GitHub · 2026-11-26 03:56 UTC · original · requested changes
Reviewed
47069285againstmain(63bcca43). There are three concrete bugs incrates/victory-gpu/src/pipeline/make.rs:Promoted duplicate compute queue entries permanently leak a
compute_busyslot (make.rs:319-322,383-387)queues[3]) and later promoted by a waiting dispatch (queues[1]), both entries remain queued.next()already incrementedqueues.compute_busy += 1. Thenp.taken.swap(true, Ordering::Relaxed)returnstrue, soif !takenis skipped andComputeSlot(compute)is never constructed —compute_busyis never decremented.compute_busy + 1 < 2), a single promoted compute pipeline permanently lockscompute_busy == 1and blocks all subsequent compute pipeline builds indefinitely.let _slot = ComputeSlot(compute);immediately after dequeue (before checkingtaken) prevents the leak.Completed compute pipelines never decrement
WAITINGor triggerdrained()(make.rs:224-226,388-399)enqueueincrementsWAITINGfor both graphics and compute pipelines on first queue, butwork()hasif compute { continue; }at line 388 beforeWAITING.fetch_sub(1, Ordering::Relaxed)at line 397.WAITINGstays permanently non-zero anddrained()can never fire. Removing the earlyif compute { continue; }(with_slotconstructed beforeif p.taken.swap(true, ...) { continue; }) lets both pipeline kinds share completion bookkeeping cleanly.Unit test fails
--all-featuresCI and fails in isolation on 2 workers (make.rs:54-58,407-428)Pending::new(Vec::new(), None)omits the#[cfg(feature = "diagnostics")] skip_hashes: &[String]argument, causing the current--all-featuresCI failure.graphics_go_first_and_compute_leaves_a_workerinitializes the process-globalWORKERSOnceLockto2and pops fromnext(&mut queues)without ever releasingcompute_busy: after popping"compute a dispatch waits for",compute_busyis1, socompute_free(1 + 1 < 2) becomesfalse,"early compute"is never popped, and the iterator yields only 3 items while the assertion expects 4. Passingworkers: usizeintonext(queues, workers)also keeps the test isolated from globalWORKERSstate and lets you test slot release and duplicate-entry behavior directly.@kotekompotek on GitHub · 2026-11-26 04:39 UTC · original · approved these changes
LGTM — verified the queue ordering (gfx-now 0, compute-now 1, gfx-early 2, compute-early 3), compute_free keeps ≥1 slot for graphics without starving compute at 1 worker, taken dedups multi-queue entries, ComputeSlot returns the slot even on a compiler panic. Real fix for the 180×3.7s compute stall.
@Luislariosss on GitHub · 2026-11-26 11:26 UTC · original
Both points of the triage are fixed in the new head:
next()now claims the entry withtaken.swap(true)under the queues' lock; an entry whose pipeline is already claimed is skipped there, so only the worker that claims it counts a compute slot.work()no longer swaps: it holds theComputeSlotguard from the start, which gives the slot back on a panic too. New testa_pipeline_in_two_queues_takes_one_slot: one pipeline in queues 1 and 3, the first dequeue claims it and counts one slot, the second finds nothing.queue_indexclassifies by stage the wayHostPipeline::newdoes (graphics.is_none(), or a singlecomputestage), so a stream withSome(graphics)and one compute stage goes to the compute queues. New testa_compute_stream_is_queued_as_compute. Same finding as @steven-seagull27's measurement on RTX and WARP; thanks for it.The doc comment on
Queuesis down to one line.cargo test -p victory-gpu --locked: 234 passed;--all-features: 249 passed;cargo clippy --all-targets -- -D warningsclean with and without--all-features.@andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:14 UTC · original
The combined test on #3353 keeps your exact
018b56ahead. It checks that the urgent presentation draw is chosen first while a compute slot is occupied, and that the duplicate early start cannot claim the pipeline again.4a59f2ealso makes workers read the published pool size after initialization. A worker can otherwise start beforeWORKERS.get_or_initreturns and keep a local limit based on a pool size of one.The scheduler/presentation tests passed with both feature configurations. If you take the queue resolution or regression, please preserve its Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>when folding it into another commit.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.