Repository navigation
GPU: a pipeline waited for in vain is not waited for again - #3071
ntgata1-dotcom wants to merge 1 commit into
Conversation
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 <noreply@anthropic.com>
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64:
- Diff review: Adding
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
left a comment
There was a problem hiding this comment.
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.
…w classes & single-timeout PSO wait Keep Xbox Series X (XboxScarlettAnaconda = 7) while eliminating 95% VRAM-spill storms on <=10.5 GiB GPUs: - Raise default VRAM steering reserve on 8-10.5 GiB discrete GPUs to 1,792 MiB (<=6 GiB stays 512 MiB). - Enable boot-time auto 1-mip drop on >=1024px streamed 2D BCn textures (MipLevels >= 4) on <=10.5 GiB GPUs, escalating to 2-mip drop on >=2048px (MipLevels >= 5) above 76% VRAM. - Cap default XSystemGetAppMemoryUsageLimit() to Series X retail limit (13,824 MiB, clamped to host RAM if smaller) while keeping LEONIDA_TITLE_MEMORY_MB override and XSystemGetDeviceType() = 7. - Fix RT-PLACED-DEFER-STAGED shared-zero image deferral when implicit_cast / view_formats_ are attached (canonicalized view_formats in ZeroShape). - Add emergency OOM relief + retry in DeviceState::allocate() (reclaim retired slabs/arena/deferred deletions, trim staging/slab pools, evict stale title windows, spillable HOST_VISIBLE retry fallback; adapted from avatarmanz/VIctory-7900XTX#92 & fxceless/victory-fork#1082, GPL-3.0). - Skip refresh_shadows() on internal staging flushes and skip shader-only title-window shadow scans on non-shader copy/barrier/clear submissions while keeping explicit slot-133 buffer shadows coherent. - Enforce Vulkan BC image-view compatibility classes (adapted from ubiquitarianism/leonida#2223, GPL-3.0, author GGandCo) and never re-wait on a PSO whose wait already timed out once (adapted from Marvisak/VIctory#3071, GPL-3.0, author ntgata1-dotcom).
fuzeofficlal
left a comment
There was a problem hiding this comment.
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 (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_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:
- Queue backlog vs. slow compile (
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. - Release
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.
|
Automated triage for the maintainers. Verdict: needs work. The problem is real: What it needs:
CI: not run on this head yet (needs a maintainer's approval for this contributor). Generated by Claude Code |
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 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.