GPU: a pipeline waited for in vain is not waited for again #3071

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

@⁠ntgata1-dotcom on GitHub · 2026-11-26 06:21 UTC · original
ntgata1-dotcom:pipeline-give-up → main · +55 −2 · 1 files · 1 commits · open

What is wrong

Draws wait for a host pipeline that is being made, for up to BUDGET (500 ms) per frame. If the host compiler takes seconds for a pipeline, or never finishes it, that wait is paid again in every frame that draws with the pipeline, not just the first.

Under Wine with vkd3d-proton (GE-Proton11-14, RX 9070 XT, RADV), 22 of the shader pack's 27,160 pipelines never finished in translate --cache --pipelines. In the world, the frame line showed dropped 1.0/frame without a host pipeline: being made in every frame.

Thread stacks taken in the world (VICTORY_STACKS, four dumps over two minutes, diag build) show the cost. In 3 of the 4 dumps, one recording thread was in pipeline::make::ready (called from draw::State::dispatch), and every other title thread was waiting on the title's own objects. No title thread was running.

What changes

Once a single wait for a pipeline has lasted 100 ms (GIVE_UP) without the pipeline being made, later draws don't wait for it. The pipeline is still made in the background, and its draws are dropped until it's ready. That is what already happens once a frame's budget is spent. The first wait is unchanged, so a pipeline made within 100 ms behaves as before. VICTORY_PIPELINE_GIVE_UP=0 restores the old behaviour.

This is separate from #2111 (one budget correctly shared across recording threads) and #275 (an adaptive budget). Those bound the wait per frame; this one stops paying it again for the same pipeline. It touches the same function as #2111, so whichever lands second needs a small rebase.

Tested

  • In game: same machine and save, the first mission's opening cutscene, diag builds with a warm cache from translate --cache --pipelines. The only difference between the two runs is this change. Both also had two local changes that aren't in this PR: queues on a worker thread, and a wineserver with its memory views in a tree. World frame times, grouped by draw count:

    Draws per frame before after
    1,000–2,500 731 ms 344 ms
    2,500–4,000 851 ms 490 ms
    4,000+ 888 ms 593 ms

    The log showed two pipelines given up on, each after a 500 ms first wait.

  • New test: a_pipeline_waited_for_in_vain_is_not_waited_for_again passes under Wine, with and without diagnostics.

  • Clippy: clean for x86_64-pc-windows-msvc, with and without --all-features.

  • Not run on Windows. CI runs the Windows tests.

AI-assisted (Claude Code); numbers from my own runs.

**@⁠ntgata1-dotcom** on GitHub · 2026-11-26 06:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071) `ntgata1-dotcom:pipeline-give-up` → `main` · +55 −2 · 1 files · 1 commits · open ## What is wrong Draws wait for a host pipeline that is being made, for up to `BUDGET` (500 ms) per frame. If the host compiler takes seconds for a pipeline, or never finishes it, that wait is paid again in **every frame** that draws with the pipeline, not just the first. Under Wine with vkd3d-proton (GE-Proton11-14, RX 9070 XT, RADV), 22 of the shader pack's 27,160 pipelines never finished in `translate --cache --pipelines`. In the world, the frame line showed `dropped 1.0/frame without a host pipeline: being made` in every frame. Thread stacks taken in the world (`VICTORY_STACKS`, four dumps over two minutes, diag build) show the cost. In 3 of the 4 dumps, one recording thread was in `pipeline::make::ready` (called from `draw::State::dispatch`), and every other title thread was waiting on the title's own objects. No title thread was running. ## What changes Once a single wait for a pipeline has lasted 100 ms (`GIVE_UP`) without the pipeline being made, later draws don't wait for it. The pipeline is still made in the background, and its draws are dropped until it's ready. That is what already happens once a frame's budget is spent. The first wait is unchanged, so a pipeline made within 100 ms behaves as before. `VICTORY_PIPELINE_GIVE_UP=0` restores the old behaviour. This is separate from #2111 (one budget correctly shared across recording threads) and #275 (an adaptive budget). Those bound the wait per frame; this one stops paying it again for the same pipeline. It touches the same function as #2111, so whichever lands second needs a small rebase. ## Tested - **In game:** same machine and save, the first mission's opening cutscene, diag builds with a warm cache from `translate --cache --pipelines`. The only difference between the two runs is this change. Both also had two local changes that aren't in this PR: queues on a worker thread, and a wineserver with its memory views in a tree. World frame times, grouped by draw count: | Draws per frame | before | after | |---|---|---| | 1,000–2,500 | 731 ms | 344 ms | | 2,500–4,000 | 851 ms | 490 ms | | 4,000+ | 888 ms | 593 ms | The log showed two pipelines given up on, each after a 500 ms first wait. - **New test:** `a_pipeline_waited_for_in_vain_is_not_waited_for_again` passes under Wine, with and without `diagnostics`. - **Clippy:** clean for `x86_64-pc-windows-msvc`, with and without `--all-features`. - Not run on Windows. CI runs the Windows tests. AI-assisted (Claude Code); numbers from my own runs.
Draws wait for a pipeline being made, up to 500 ms a frame over all
threads. A pipeline the host's compiler takes seconds for, or never
finishes (some do under vkd3d-proton: 22 of the pack's 27,160 here), so
cost every frame the whole budget. In the world on Linux the title's
threads all stood behind one such wait: a recording thread in
pipeline::make::ready, every other title thread on the title's own
objects, in each of the stack dumps taken, with "dropped 1.0/frame
without a host pipeline: being made" every frame.

Once one wait for a pipeline has lasted 100 ms in vain, later draws do
not wait for it: it is still made in the background and its draws are
dropped until then, as they are once the budget is spent.
VICTORY_PIPELINE_GIVE_UP=0 waits as before.

The test makes a pipeline nothing makes and waits for it twice: the
first wait lasts at least 100 ms, the second returns at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:28:05 +00:00
Author
Owner

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

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64:

  • Diff review: Adding Pending::given_up and setting it when a wait exceeds GIVE_UP (100 ms) without the pipeline finishing (toggleable via VICTORY_PIPELINE_GIVE_UP=0) prevents a slow or hung pipeline compile from burning the entire frame wait budget on every subsequent frame while still letting background compilation complete.
  • cargo test -p victory-gpu --features diagnostics pipeline::make::tests -- --test-threads=1: 4 passed, 0 failed (including a_pipeline_waited_for_in_vain_is_not_waited_for_again).
  • cargo clippy -p victory-gpu --features diagnostics --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 06:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071#pullrequestreview-6069495369) · **approved these changes** Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - Diff review: Adding `Pending::given_up` and setting it when a wait exceeds `GIVE_UP` (100 ms) without the pipeline finishing (toggleable via `VICTORY_PIPELINE_GIVE_UP=0`) prevents a slow or hung pipeline compile from burning the entire frame wait budget on every subsequent frame while still letting background compilation complete. - `cargo test -p victory-gpu --features diagnostics pipeline::make::tests -- --test-threads=1`: 4 passed, 0 failed (including `a_pipeline_waited_for_in_vain_is_not_waited_for_again`). - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 06:33 UTC · original · approved these changes

Verified: BUDGET=500ms so a single wait can reach the 100ms GIVE_UP mark; given_up only sets when the pipeline is still unmade after the wait (made.get().is_none() gate), swap() keeps the once-only info log, and later draws return immediately. Opt-out env var preserved. Test exercises first-wait burn + later-frame skip.

**@⁠kotekompotek** on GitHub · 2026-11-26 06:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071#pullrequestreview-6069543839) · **approved these changes** Verified: BUDGET=500ms so a single wait can reach the 100ms GIVE_UP mark; given_up only sets when the pipeline is still unmade after the wait (made.get().is_none() gate), swap() keeps the once-only info log, and later draws return immediately. Opt-out env var preserved. Test exercises first-wait burn + later-frame skip.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:12 UTC · original · approved these changes

Tested natively on Windows 11 x64 (rustc 1.98.1, RTX 5090 + WARP; note CI workflow run #45767613588 is currently action_required awaiting first-time contributor approval rather than failing):

  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default and --all-features): clean.
  • cargo test -p victory-gpu --lib --locked -- pipeline::make::tests --test-threads=1: 3 passed, 0 failed (including a_pipeline_waited_for_in_vain_is_not_waited_for_again).
  • cargo test -p victory-gpu --lib --features diagnostics --locked -- pipeline::make::tests (WARP, both --test-threads=1 and default parallel threads): 4 passed, 0 failed.
  • cargo xtask policy: 191 files ok.

The core given_up latch (made.get().is_none() gate, once-only swap(true) log, background compilation still running, VICTORY_PIPELINE_GIVE_UP=0 opt-out) works cleanly and solves the repeated per-frame stall.

Two small non-blocking refinements worth considering:

  1. Queue backlog vs. slow compile (pipeline/make.rs:54-56): started.elapsed() includes time spent waiting in QUEUES before any worker picks up p. During a large first-frame burst (1,000+ pipelines queued across 2–8 below-normal-priority workers), a fast pipeline waiting >100 ms in the queue can be permanently marked given_up before compilation even starts. Gating given_up on p.taken.load(Ordering::Relaxed) (so a pipeline is only given up on once a worker has actually started compiling it) avoids false positives from queue congestion while still catching slow/hung compiles.
  2. Release DONE mutex before logging (pipeline/make.rs:53-62): dropping held right after the while loop avoids holding the global DONE lock across tracing::info! formatting/I/O while workers are trying to acquire DONE for notify_all().

LGTM once CI is approved to run.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071#pullrequestreview-6070505853) · **approved these changes** Tested natively on Windows 11 x64 (`rustc 1.98.1`, RTX 5090 + WARP; note CI workflow run #45767613588 is currently `action_required` awaiting first-time contributor approval rather than failing): - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default and `--all-features`): clean. - `cargo test -p victory-gpu --lib --locked -- pipeline::make::tests --test-threads=1`: 3 passed, 0 failed (including `a_pipeline_waited_for_in_vain_is_not_waited_for_again`). - `cargo test -p victory-gpu --lib --features diagnostics --locked -- pipeline::make::tests` (WARP, both `--test-threads=1` and default parallel threads): 4 passed, 0 failed. - `cargo xtask policy`: 191 files ok. The core `given_up` latch (`made.get().is_none()` gate, once-only `swap(true)` log, background compilation still running, `VICTORY_PIPELINE_GIVE_UP=0` opt-out) works cleanly and solves the repeated per-frame stall. Two small non-blocking refinements worth considering: 1. **Queue backlog vs. slow compile (`pipeline/make.rs:54-56`)**: `started.elapsed()` includes time spent waiting in `QUEUES` before any worker picks up `p`. During a large first-frame burst (1,000+ pipelines queued across 2–8 below-normal-priority workers), a fast pipeline waiting >100 ms in the queue can be permanently marked `given_up` before compilation even starts. Gating `given_up` on `p.taken.load(Ordering::Relaxed)` (so a pipeline is only given up on once a worker has actually started compiling it) avoids false positives from queue congestion while still catching slow/hung compiles. 2. **Release `DONE` mutex before logging (`pipeline/make.rs:53-62`)**: dropping `held` right after the `while` loop avoids holding the global `DONE` lock across `tracing::info!` formatting/I/O while workers are trying to acquire `DONE` for `notify_all()`. LGTM once CI is approved to run.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:23 UTC · original

Automated triage for the maintainers.

Verdict: needs work. The problem is real: pipeline::make::wait pays up to BUDGET every frame for a pipeline that never finishes. The fix in wait (Pending::given_up after one wait of GIVE_UP = 100 ms) is small. But it changes what every Windows run does by default, and the only evidence is from Wine/vkd3d-proton with two other local changes.

What it needs:

  • A Windows run (loading and the first world frames, where 1,200+ pipelines are queued at once) compared with main. Give the number of pipelines given up and the draws dropped. A wait there can last 100 ms just from queueing behind other pipelines, not because the pipeline is slow. With this change, that pipeline's draws in the following frames are dropped instead of waited for.
  • The switch documented: VICTORY_PIPELINE_GIVE_UP needs a row in the README's switch table. It's read directly here; crate::switch::on is the repo's helper for on/off switches.

CI: not run on this head yet (needs a maintainer's approval for this contributor).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071#issuecomment-7186535476) <!-- victory-triage v1 head=e86ad60084fd49122e5c4d32daff9b2d9fe4f92b verdict=needs-work at=2026-11-26T08:18:50Z --> Automated triage for the maintainers. **Verdict: needs work.** The problem is real: `pipeline::make::wait` pays up to `BUDGET` every frame for a pipeline that never finishes. The fix in `wait` (`Pending::given_up` after one wait of `GIVE_UP` = 100 ms) is small. But it changes what every Windows run does by default, and the only evidence is from Wine/vkd3d-proton with two other local changes. What it needs: - **A Windows run** (loading and the first world frames, where 1,200+ pipelines are queued at once) compared with main. Give the number of pipelines given up and the draws dropped. A wait there can last 100 ms just from queueing behind other pipelines, not because the pipeline is slow. With this change, that pipeline's draws in the following frames are dropped instead of waited for. - **The switch documented:** `VICTORY_PIPELINE_GIVE_UP` needs a row in the README's switch table. It's read directly here; `crate::switch::on` is the repo's helper for on/off switches. CI: not run on this head yet (needs a maintainer's approval for this contributor). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 16:35 UTC · original

Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), 63bcca4 + this PR:

  • pipeline::make::tests::a_pipeline_waited_for_in_vain_is_not_waited_for_again passes on the hardware adapter (0.51 s).
  • cargo test -p victory-gpu --lib: 232 passed / 0 failed / 1 ignored.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 16:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3071#issuecomment-7197853791) Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), `63bcca4` + this PR: - `pipeline::make::tests::a_pipeline_waited_for_in_vain_is_not_waited_for_again` passes on the hardware adapter (0.51 s). - `cargo test -p victory-gpu --lib`: 232 passed / 0 failed / 1 ignored. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. Synthetic only. AI-assisted.
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/3071/head:github-bot/gh-3071'
git switch 'github-bot/gh-3071'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3071'
git switch 'github-bot/gh-3071'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3071'
git switch 'github-bot/gh-3071'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3071'
git switch 'main'
git merge --squash 'github-bot/gh-3071'
git switch 'main'
git merge --ff-only 'github-bot/gh-3071'
git switch 'main'
git merge 'github-bot/gh-3071'
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!3071
No description provided.