GPU: schedule slow-compiling early pipelines in their own bounded queue #3296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3296"
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 Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-26T16:17:23Z.
Summary
Tracks host pipelines that take
>= 1000 msto compile inslow-pipelines.txtand caps concurrent early compilation of slow pipelines to a quarter of the worker pool (VICTORY_PIPELINE_SLOW=0to disable), leaving the remaining workers free for fast early pipelines and draw-requested pipelines.Root Cause
When the pipeline library is cold or invalidated after a translator/driver update, early pipelines that take several seconds each can occupy all background pipeline workers simultaneously, starving fast pipelines needed by early draws.
Changes
crates/victory-gpu/src/pipeline/library.rs:SLOW_FILE(slow-pipelines.txt),SLOW_MS(1000),slow(key), andnote_time(key, ms), persisted atomically alongsideearly-pipelines.txt.crates/victory-gpu/src/pipeline/make.rs:super::library::note_timeinPending::make.QUEUESinto aQueuesstruct withlists[0](requested),lists[1](early normal), andlists[2](early slow), capping concurrentslow_nowworkers to(workers / 4).max(1)unlessVICTORY_PIPELINE_SLOW=0.pipelines_known_to_take_long_leave_workers_for_the_othersunit test.Testing & Verification
pipelines_known_to_take_long_leave_workers_for_the_othersincrates/victory-gpu/src/pipeline/make.rs.No game files used.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T16:19:43Z.
I reproduced a case where the slow-worker cap leaks on
30dd0df(deterministic queue test, no GPU needed). With cap = 1, queue slow A and B. A draw passes the!p.takencheck for A inenqueuebut has not pushed its urgent entry yet. A worker pops A from the slow queue, setstakenand starts compiling. The draw now pushes the urgent duplicate. A second worker discards that duplicate, but itsp.was_slow.swap(false)also releases the slot owned by the first worker. The nextQueues::pop(1)then returns B while A is still compiling.Could
Queues::popreturn the queue class with the entry, e.g.(Arc<Pending>, bool), and the worker use that local value when decrementingslow_now? A discarded slow entry would still release the reservation it took at pop time. A discarded urgent entry would never release another worker's reservation. The test is to freeze this interleaving and assert that B cannot be popped until A releases its slot.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T16:50:46Z.
I reproduced @yumaste's interleaving with a deterministic queue test on
30dd0df. One slow compile holds the only slot. The urgent duplicate is discarded while that compile is still in progress. The original logic releases its reservation at that point and admits the second slow compile too early.Follow-up
8dff2d5carries the reservation with the popped entry, as suggested. A worker releases exactly the slot its entry reserved. With the same interleaving, the second slow entry stays queued until the first compile completes. The new regression and all fivepipeline::make::testspassed. Strict GPU Clippy passed with default and all features, and policy passed. The queue test uses synthetic entries and does not measure cold-start time.@pushkarreddyy this is directly on your exact head if you want to cherry-pick it. Please retain its Git author, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit. AI-assisted with Codex.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:10:10Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
note_time) and scheduling known-slow early pipelines onto a bounded slow queue keeps worker threads free for normal draws and faster early compiles.cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1(RTX 5090): 24 passed, 0 failed (includingpipelines_known_to_take_long_leave_workers_for_the_others).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-27T04:02:39Z.
@yumaste @andrewpozdnakov7-jpg Thank you for reproducing the
slow_nowreservation leak on urgent duplicate discards and providing the clean fix (8dff2d5). I have cherry-picked8dff2d5(preserving Git authorship) onto the PR branch so each popped entry owns and releases its own slow-slot reservation.@Marvisak Please review and merge this PR once CI is green. Testers on untested GPU models are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
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.