Skip to content

GPU: prioritize pipeline work requested by draws - #546

Closed
melon0918 wants to merge 1 commit into
Marvisak:mainfrom
melon0918:fix/prioritize-requested-pipelines
Closed

melon0918 wants to merge 1 commit into
Marvisak:mainfrom
melon0918:fix/prioritize-requested-pipelines

Conversation

@melon0918

@melon0918 melon0918 commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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.

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…ed by draws

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
… pipeline the title creates (on Marvisak#546's queue)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simnJS added a commit to MiamiGame/XTP that referenced this pull request Nov 24, 2026
… over

VIctory #546 builds the pipelines draws ask for before those started
early. fb3db31 already queues first uses ahead of early starts
(pipeline/make.rs), which is most of #546's measured gain on VIctory
(draws dropped for a missing pipeline 2,040 -> 1,359 per frame, against a
single queue). What #546 adds, and is taken here:
- A pipeline taken by a worker is MAKING, under the queues' lock. A first
  use of a pipeline a worker is already making no longer queues it again:
  before, a second worker took the duplicate and waited on the first's
  compile (OnceLock), one worker fewer for up to seconds.
- An early entry whose pipeline was promoted, or taken, is passed over
  when it comes out, instead of being handed to a worker that finds it
  finished.
- Without workers, the pipeline is made by the caller, once.
- #546's queue test; the two tests that read the state now allow a
  worker to have taken the pipeline already (MAKING).

Ported from Marvisak/VIctory#546 (head a8bf0d3) by melon0918
@Mumogg

Mumogg commented Nov 24, 2026 •

Copy link
Copy Markdown

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).

justr4mzi pushed a commit to justr4mzi/VIctory that referenced this pull request Nov 24, 2026
Below normal, the world's busy threads starved the workers: on an RTX 4050 Laptop (16 logical processors) pipelines were made at 236 a minute at the start screen and 7 a minute once in the world, with about 1,700 waiting. Draws whose pipelines are not made yet are dropped, so the world stayed black for the whole 17-minute run. At normal priority (with Marvisak#546 and Marvisak#1129 also applied) the same run made 100-300 a minute in the world and drew up to 1,475 draws a frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nazmi pushed a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
Below normal, the world's busy threads starved the workers: on an RTX 4050 Laptop (16 logical processors) pipelines were made at 236 a minute at the start screen and 7 a minute once in the world, with about 1,700 waiting. Draws whose pipelines are not made yet are dropped, so the world stayed black for the whole 17-minute run. At normal priority (with Marvisak#546 and Marvisak#1129 also applied) the same run made 100-300 a minute in the world and drew up to 1,475 draws a frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ade80d2)
(cherry picked from commit bfe79fb3be43b5f518c1703a7aecf295be66686b)
@Marvisak

Copy link
Copy Markdown
Owner

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.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants