GPU: schedule slow-compiling early pipelines in their own bounded queue #3296

Open
github-bot wants to merge 1 commit from github-bot/gh-3296 into main AGit
Owner

@⁠pushkarreddyy on GitHub · 2026-11-26 16:17 UTC · original
pushkarreddyy:perf/gpu-pipeline-slow-queue → main · +267 −32 · 2 files · 1 commits · open

Summary

Tracks host pipelines that take >= 1000 ms to compile in slow-pipelines.txt and caps concurrent early compilation of slow pipelines to a quarter of the worker pool (VICTORY_PIPELINE_SLOW=0 to 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:
    • Added SLOW_FILE (slow-pipelines.txt), SLOW_MS (1000), slow(key), and note_time(key, ms), persisted atomically alongside early-pipelines.txt.
  • crates/victory-gpu/src/pipeline/make.rs:
    • Recorded compile duration via super::library::note_time in Pending::make.
    • Split QUEUES into a Queues struct with lists[0] (requested), lists[1] (early normal), and lists[2] (early slow), capping concurrent slow_now workers to (workers / 4).max(1) unless VICTORY_PIPELINE_SLOW=0.
    • Added pipelines_known_to_take_long_leave_workers_for_the_others unit test.

Testing & Verification

  • Added unit test pipelines_known_to_take_long_leave_workers_for_the_others in crates/victory-gpu/src/pipeline/make.rs.
  • Testers on untested GPU models and drivers are welcome to verify pipeline compilation responsiveness on cold/warm runs.

No game files used.

AI-assisted: yes (Gemini 4 Neon)

**@⁠pushkarreddyy** on GitHub · 2026-11-26 16:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3296) `pushkarreddyy:perf/gpu-pipeline-slow-queue` → `main` · +267 −32 · 2 files · 1 commits · open ## Summary Tracks host pipelines that take `>= 1000 ms` to compile in `slow-pipelines.txt` and caps concurrent early compilation of slow pipelines to a quarter of the worker pool (`VICTORY_PIPELINE_SLOW=0` to 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`: - Added `SLOW_FILE` (`slow-pipelines.txt`), `SLOW_MS` (`1000`), `slow(key)`, and `note_time(key, ms)`, persisted atomically alongside `early-pipelines.txt`. - `crates/victory-gpu/src/pipeline/make.rs`: - Recorded compile duration via `super::library::note_time` in `Pending::make`. - Split `QUEUES` into a `Queues` struct with `lists[0]` (requested), `lists[1]` (early normal), and `lists[2]` (early slow), capping concurrent `slow_now` workers to `(workers / 4).max(1)` unless `VICTORY_PIPELINE_SLOW=0`. - Added `pipelines_known_to_take_long_leave_workers_for_the_others` unit test. ## Testing & Verification - Added unit test `pipelines_known_to_take_long_leave_workers_for_the_others` in `crates/victory-gpu/src/pipeline/make.rs`. - Testers on untested GPU models and drivers are welcome to verify pipeline compilation responsiveness on cold/warm runs. No game files used. AI-assisted: yes (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:22:00 +00:00
Author
Owner

@⁠yumaste on GitHub · 2026-11-26 16:19 UTC · original

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.taken check for A in enqueue but has not pushed its urgent entry yet. A worker pops A from the slow queue, sets taken and starts compiling. The draw now pushes the urgent duplicate. A second worker discards that duplicate, but its p.was_slow.swap(false) also releases the slot owned by the first worker. The next Queues::pop(1) then returns B while A is still compiling.

Could Queues::pop return the queue class with the entry, e.g. (Arc<Pending>, bool), and the worker use that local value when decrementing slow_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.

**@⁠yumaste** on GitHub · 2026-11-26 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/3296#issuecomment-7197495915) 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.taken` check for A in `enqueue` but has not pushed its urgent entry yet. A worker pops A from the slow queue, sets `taken` and starts compiling. The draw now pushes the urgent duplicate. A second worker discards that duplicate, but its `p.was_slow.swap(false)` also releases the slot owned by the first worker. The next `Queues::pop(1)` then returns B while A is still compiling. Could `Queues::pop` return the queue class with the entry, e.g. `(Arc<Pending>, bool)`, and the worker use that local value when decrementing `slow_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.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 16:50 UTC · original

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 8dff2d5 carries 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 five pipeline::make::tests passed. 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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 16:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3296#issuecomment-7198169295) I reproduced @⁠yumaste's [interleaving](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3296) 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 `8dff2d5`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8dff2d51aeaffe031ee2103ed125ab32784aec89) carries 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 five `pipeline::make::tests` passed. 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.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 17:10 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):

  • Recording compile durations in the pipeline library (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 (including pipelines_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).

**@⁠Dukestar69** on GitHub · 2026-11-26 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3296#pullrequestreview-6078110761) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090): - Recording compile durations in the pipeline library (`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 (including `pipelines_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).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3296/head:github-bot/gh-3296'
git switch 'github-bot/gh-3296'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3296'
git switch 'github-bot/gh-3296'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3296'
git switch 'github-bot/gh-3296'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3296'
git switch 'main'
git merge --squash 'github-bot/gh-3296'
git switch 'main'
git merge --ff-only 'github-bot/gh-3296'
git switch 'main'
git merge 'github-bot/gh-3296'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3296
No description provided.