GPU: prioritize pipeline work requested by draws #546

Closed
melon0918 wants to merge 1 commit from upstream-pr/546 into main
melon0918 commented 2026-11-24 04:43:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by melon0918 on 2026-11-24T04:43:05Z.


Change

Compile pipelines needed by a draw or dispatch ahead of speculative early work. A first request promotes a pipeline that is still in the early queue. Workers claim each pipeline once and preserve FIFO order within each priority. The same frame wait budget applies to the request.

#275 addresses wait accounting and cache saves. This change addresses which pending job a worker takes next.

Verification

  • Windows 10 22H2, RX 7900 XT, and the app-local Agility SDK. The victory-gpu diagnostics suite passed 46 tests with one existing ignored test. The queue regression checks promotion, FIFO order within each priority, and single processing of a promoted entry. The asset policy passed.
  • One paired offline title test on a compatibility integration stack. Both runs used the same diagnostic executable and separate copies of the same starting application cache. A test-only mode reproduced FIFO ordering. These are medians across 21 samples per mode in the first 120 seconds after the first indexed rectangle submission in the opening scene.
Measure FIFO Prioritize requested jobs
Recorded draws per frame 10 1,721
Draws dropped for a missing host pipeline per frame 2,040 1,359
Pipelines still being made 1,532 1,122
Frames per second 1.3 0.9

The reviewed captures show opening credits and 2D imagery. Live 3D rendering remains unverified. The prioritization run recorded substantially more draws at a lower median frame rate and encountered device removal. The queue measurements are evidence of scheduling behavior.

AI-assisted contribution. All test data and captures stayed local.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6574781322 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/546). Originally posted by [melon0918](https://github.com/melon0918) on 2026-11-24T04:43:05Z. --- ## Change Compile pipelines needed by a draw or dispatch ahead of speculative early work. A first request promotes a pipeline that is still in the early queue. Workers claim each pipeline once and preserve FIFO order within each priority. The same frame wait budget applies to the request. #275 addresses wait accounting and cache saves. This change addresses which pending job a worker takes next. ## Verification - Windows 10 22H2, RX 7900 XT, and the app-local Agility SDK. The `victory-gpu` diagnostics suite passed 46 tests with one existing ignored test. The queue regression checks promotion, FIFO order within each priority, and single processing of a promoted entry. The asset policy passed. - One paired offline title test on a compatibility integration stack. Both runs used the same diagnostic executable and separate copies of the same starting application cache. A test-only mode reproduced FIFO ordering. These are medians across 21 samples per mode in the first 120 seconds after the first indexed rectangle submission in the opening scene. | Measure | FIFO | Prioritize requested jobs | | --- | ---: | ---: | | Recorded draws per frame | 10 | 1,721 | | Draws dropped for a missing host pipeline per frame | 2,040 | 1,359 | | Pipelines still being made | 1,532 | 1,122 | | Frames per second | 1.3 | 0.9 | The reviewed captures show opening credits and 2D imagery. Live 3D rendering remains unverified. The prioritization run recorded substantially more draws at a lower median frame rate and encountered device removal. The queue measurements are evidence of scheduling behavior. AI-assisted contribution. All test data and captures stayed local.
mercuryVM commented 2026-11-24 12:03:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:51:44Z.

Review: APPROVED


Tested a8bf0d3 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 44 passed, including draws_promote_early_pipelines_without_claiming_them_twice. With --features diagnostics, 46 passed. Clippy's 1 warning is the existing one in host.rs.

  • Every state change happens under QUEUE's lock: push raises queue_state and pop stores MAKING. A pipeline promoted from early to requested is therefore claimed once. Its stale early entry is skipped by the == EARLY filter in pop, and the test covers that sequence.
  • The lock-free fast path in start (load() >= priority) can only return early for a state that is already at least as high, so it never loses a promotion.
  • WAITING/PEAK count a pipeline once, on its first queueing, not on promotion, which matches the old accounting.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038681250 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/546#pullrequestreview-6038681250). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:51:44Z. **Review:** APPROVED --- Tested a8bf0d3 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-gpu -- --test-threads=1` 44 passed, including `draws_promote_early_pipelines_without_claiming_them_twice`. With `--features diagnostics`, 46 passed. Clippy's 1 warning is the existing one in host.rs. - Every state change happens under `QUEUE`'s lock: `push` raises `queue_state` and `pop` stores `MAKING`. A pipeline promoted from early to requested is therefore claimed once. Its stale early entry is skipped by the `== EARLY` filter in `pop`, and the test covers that sequence. - The lock-free fast path in `start` (`load() >= priority`) can only return early for a state that is already at least as high, so it never loses a promotion. - `WAITING`/`PEAK` count a pipeline once, on its first queueing, not on promotion, which matches the old accounting. AI-assisted (Claude Code).
geiyiliyabumo commented 2026-11-24 12:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T11:43:30Z.


Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver 32.0.32029.2010, Rust 1.98.1), cleanly merged onto main (ffe310e):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: PASS
  • cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings: PASS
  • cargo test -p victory-gpu --locked: 51 passed, 0 failed, 1 ignored (including new pipeline::make::tests::draws_promote_early_pipelines_without_claiming_them_twice)

Diff review (crates/victory-gpu/src/pipeline/make.rs): very clean state machine (NOT_QUEUED -> EARLY -> REQUESTED -> MAKING) serialized under QUEUE:

  • Promoting an EARLY entry to REQUESTED pushes it to requested without double-incrementing WAITING, and pop() skips promoted entries left in early (queue_state != EARLY) so no pipeline is ever compiled twice.
  • Workers drop QUEUE before p.make(), and the no-workers fallback (!workers()) builds inline safely without touching WAITING.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130465068 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/546#issuecomment-7130465068). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T11:43:30Z. --- Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver `32.0.32029.2010`, Rust `1.98.1`), cleanly merged onto `main` (`ffe310e`): - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: PASS - `cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings`: PASS - `cargo test -p victory-gpu --locked`: **51 passed, 0 failed, 1 ignored** (including new `pipeline::make::tests::draws_promote_early_pipelines_without_claiming_them_twice`) Diff review (`crates/victory-gpu/src/pipeline/make.rs`): very clean state machine (`NOT_QUEUED -> EARLY -> REQUESTED -> MAKING`) serialized under `QUEUE`: - Promoting an `EARLY` entry to `REQUESTED` pushes it to `requested` without double-incrementing `WAITING`, and `pop()` skips promoted entries left in `early` (`queue_state != EARLY`) so no pipeline is ever compiled twice. - Workers drop `QUEUE` before `p.make()`, and the no-workers fallback (`!workers()`) builds inline safely without touching `WAITING`. *AI-assisted; synthetic tests only, no game files.*
Mumogg commented 2026-11-24 18:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Mumogg on 2026-11-24T17:57:19Z.


A data point for why this is needed even once library loads run in parallel (#1000), from Linux (RTX 5070 Ti, driver 615.78.08, Wine 11.22 Staging, vkd3d-proton from GE-Proton11-14; r4tedx integration/testers update 9, diagnostics build, warm cache with 1,167 pipelines on the early list).

One caveat first: I could not run this PR's code on that tree. make.rs conflicts with #275, which the testers tree carries (the per-pipeline wait pair and the frame budget), so what I ran is a local change with the same idea: two queues, a pipeline a frame asks for goes to the urgent one even if it is already waiting in the early one, workers drain urgent first. A rebase of this PR over #275 would let testers run the real thing.

Warm start, same cache, at world entry:

draws dropped per frame as "being made" draws run per frame
loads outside the library's lock only 3,610 to 5,406 167 to 511
plus the two-level queue 174 to 226 at entry, 2 to 4 a few minutes later 1,482 to 3,354

With only the lock fixed, the frame's own pipelines still sat behind several hundred early compute pipelines, each a multi-second load here.

(AI-assisted, Claude Code; runs on my machine.)

Edit: the Wine version was 11.22 Staging, not 11.21 (the system had updated before these runs).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139946280 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/546#issuecomment-7139946280). Originally posted by [Mumogg](https://github.com/Mumogg) on 2026-11-24T17:57:19Z. --- A data point for why this is needed even once library loads run in parallel (#1000), from Linux (RTX 5070 Ti, driver 615.78.08, Wine 11.22 Staging, vkd3d-proton from GE-Proton11-14; r4tedx `integration/testers` update 9, diagnostics build, warm cache with 1,167 pipelines on the early list). One caveat first: I could not run this PR's code on that tree. `make.rs` conflicts with #275, which the testers tree carries (the per-pipeline wait pair and the frame budget), so what I ran is a local change with the same idea: two queues, a pipeline a frame asks for goes to the urgent one even if it is already waiting in the early one, workers drain urgent first. A rebase of this PR over #275 would let testers run the real thing. Warm start, same cache, at world entry: | | draws dropped per frame as "being made" | draws run per frame | |---|---|---| | loads outside the library's lock only | 3,610 to 5,406 | 167 to 511 | | plus the two-level queue | 174 to 226 at entry, 2 to 4 a few minutes later | 1,482 to 3,354 | With only the lock fixed, the frame's own pipelines still sat behind several hundred early compute pipelines, each a multi-second load here. (AI-assisted, Claude Code; runs on my machine.) *Edit: the Wine version was 11.22 Staging, not 11.21 (the system had updated before these runs).*
upstream-sync closed this pull request 2026-11-25 01:04:10 +00:00
Marvisak commented 2026-11-25 01:07:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:24:38Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Already in main: make.rs has a queue for pipelines draws wait for ahead of the early starts, with promotion of a still-queued early entry and single processing (enqueue, test draws_go_ahead_of_early_starts).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148480265 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/546#issuecomment-7148480265). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:24:38Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Already in main: make.rs has a queue for pipelines draws wait for ahead of the early starts, with promotion of a still-queued early entry and single processing (enqueue, test draws_go_ahead_of_early_starts). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!546
No description provided.