GPU: a pipeline waited for in vain is not waited for again #3071
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3071
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3071"
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?
@ntgata1-dotcom on GitHub · 2026-11-26 06:21 UTC · original
ntgata1-dotcom:pipeline-give-up→main· +55 −2 · 1 files · 1 commits · openWhat 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 showeddropped 1.0/frame without a host pipeline: being madein 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 inpipeline::make::ready(called fromdraw::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=0restores 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: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_againpasses under Wine, with and withoutdiagnostics.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.
@Dukestar69 on GitHub · 2026-11-26 06:27 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:Pending::given_upand setting it when a wait exceedsGIVE_UP(100 ms) without the pipeline finishing (toggleable viaVICTORY_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 (includinga_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).
@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.
@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 currentlyaction_requiredawaiting 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 (includinga_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=1and default parallel threads): 4 passed, 0 failed.cargo xtask policy: 191 files ok.The core
given_uplatch (made.get().is_none()gate, once-onlyswap(true)log, background compilation still running,VICTORY_PIPELINE_GIVE_UP=0opt-out) works cleanly and solves the repeated per-frame stall.Two small non-blocking refinements worth considering:
pipeline/make.rs:54-56):started.elapsed()includes time spent waiting inQUEUESbefore any worker picks upp. 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 markedgiven_upbefore compilation even starts. Gatinggiven_uponp.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.DONEmutex before logging (pipeline/make.rs:53-62): droppingheldright after thewhileloop avoids holding the globalDONElock acrosstracing::info!formatting/I/O while workers are trying to acquireDONEfornotify_all().LGTM once CI is approved to run.
@Marvisak on GitHub · 2026-11-26 08:23 UTC · original
Automated triage for the maintainers.
Verdict: needs work. The problem is real:
pipeline::make::waitpays up toBUDGETevery frame for a pipeline that never finishes. The fix inwait(Pending::given_upafter one wait ofGIVE_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:
VICTORY_PIPELINE_GIVE_UPneeds a row in the README's switch table. It's read directly here;crate::switch::onis 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
@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_againpasses 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.
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.