pipeline/make: stop holding draws on compilemem gate waits #4471
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4471"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-11-30T20:46:51Z.
Related: #4176
What it changes
With
VICTORY_PIPELINE_WAIT_ALLenabled (on by default), missing graphics pipelines wait up to the 10 sscreen_budgetper frame. When system commit drops below the 4 GB hard floor (Verdict::Commit) or free physical memory drops below the 1 GB soft floor (Verdict::Throttle), three defects invictory-gpucaused multi-second draw-wait stalls (down to ~0.5 FPS while shaders were compiling or deferred):Draws waited up to 10 s while workers were parked in
compilemem::begin():WAIT_WORKER(10 s) underVerdict::Commitwhen another compile is running, and unboundedly underVerdict::Throttle. While parked incompilemem::begin(),Pending::defer()has not run yet (retry_at == 0,queue_state == MAKING), sowait_for_pipeline()held the recording thread until timeout. When eligible workers saturated onVerdict::CommitorVerdict::Throttle, additionalREQUESTEDdraws also stalled up to 10 s (or 500 ms forQueue::requested).Pendinggate-wait state (MEM_NONE/MEM_THROTTLED/MEM_COMMIT_BLOCKED) via a thread-local RAII guard (MemWaitGuard) insidePending::make_with()(clearingmem_waitonly afterdefer()storesretry_atandNOT_QUEUED, leaving zero window), and tracks activeVerdict::Commit/Verdict::Throttlewaiters incompilemem::GATE_WAITERSpaired withWorkerCounters(all_busyandrequested_busy, unwind-safe viaWorkerBusyGuard) viaSeqCstordering.!screens_only: general + asked-only) separately alongside total workers inWorkerCounters(enter_and_notify): becauseSCREEN_WORKERSonly popQueue::screenand neverQueue::requested, compute andVICTORY_PIPELINE_WAIT_ALL=0graphics draws are treated as worker-saturated (and woken vianotify_waiters()) as soon as all non-screen workers are busy, even whenSCREEN_WORKERSare idle.MEM_COMMIT_BLOCKEDor when all eligible workers are busy with a commit-blocked compile; ordinaryVICTORY_PIPELINE_WAIT_ALLgraphics draws (and non-screen compute) also exit immediately onMEM_THROTTLEDor soft-throttle worker saturation, while truescreen || characterpasses keep waiting under soft RAM throttle so one-shot lighting/bake passes are not dropped, and free eligible workers continue serving warm library hits.WAIT_WORKERand worker admission floors incompilemem/memguard/residencyare unchanged.Inline compute under commit/throttle pressure and post-deferral recovery (
3534ce31,62b6e987):p.make()even whilecompilememwas commit-blocked, soft-throttled, or the pipeline's worker was parked incompilemem::begin(), stalling 1,000 ms (WAIT_OTHER) incompilemem::begin()or blocking unboundedly onp.building.lock().ready()now checksmem_gate_allows_inline_compute(mem_wait, p.screen || p.character, commit_blocked, throttle_blocked)and falls back from inline computep.make()towait()wheneverp.mem_wait != MEM_NONE,compilemem::commit_blocked()is active, orcompilemem::throttle_blocked()is active for non-screen/non-character compute (preservingscreen || characteranti-flash behavior when no worker is parked on that pipeline).deferred_before = retry_at != 0bypass inready()while preservingretry_atfordriver_oomrate-limiting andwait_for_pipeline()'s idle-exit guard. During the retry cooldownstart()still returnsfalseso draws do not block; once the cooldown expires and memory recovers, previously deferred pipelines (includingscreen || characterpasses and inline compute) wait/build normally again, whilemem_gate_stops(),mem_gate_allows_inline_compute(), andwait_for_pipeline()still exit immediately if the compile-memory gate blocks or the retry defers again.start()->ready()TOCTOU and idlememguard-deferred wait race:start()previously returned()when skipping aretry_waits()pipeline; if the cooldown expired beforeready()'s!p.retry_waits()check,ready()enteredwait()whilequeue_state == NOT_QUEUED, andwait_for_pipeline()only exited idleNOT_QUEUEDdeferrals whendriver_oomwas set.start()now returnsbool(whether the pipeline is queued/making),retry_atandqueue_statehandoffs useAcquire/Releaseordering, andwait_for_pipeline()exits on any idleNOT_QUEUEDpipeline withretry_at != 0(covering bothmemguardanddriver_oomdeferrals).How it was tested
62b6e987(rebased ontoorigin/main5fabb46eaf), plus earlier 12-minute (720.7 s in-world) live soak on RTX 3060 Ti 8 GB / 32 GB RAM (Series S, DLSS Quality, FSR 3 frame generation, ray tracing off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12).wait_for_pipeline/screen_budget(10 s) when a worker parked incompilemem::begin(), when an idlememguard-deferred pipeline's cooldown had expired, whenQueue::requestedwaited behind saturated non-screen workers whileSCREEN_WORKERSwere idle, or when inline compute enteredp.make()under commit/throttle pressure.wait_for_pipeline()andready()exit immediately without timeout oncompilememgate waits (MEM_COMMIT_BLOCKED, soft-throttle for ordinary wait-all draws and non-screen compute, eligible-worker saturation) and idlememguard-deferred pipelines, while previously deferredscreen || characterpasses and inline compute resume normal waits/builds once the cooldown expires and memory recovers.cargo testpassed for the crates it touches: yes (on62b6e987, base5fabb46eaf)cargo test --locked -p victory-gpu --lib -- pipeline::make compilemem --test-threads=1: 61 passed, 0 failed (plus 5/5 consecutive parallel runs passed, 61/61 each, including newrequested_queue_saturation_ignores_idle_screen_workersand expandedinline_compute_skips_build_when_gate_blockstests).cargo test --locked -p victory-gpu --lib(full parallel): 1105 passed, 0 failed, 66 ignored.cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand--all-features: 0 warnings/errors in touched files (origin/main5fabb46ecurrently has 5 pre-existing clippy errors inhost/{font,menu,panel}.rsfrom#4634, tracked in#4679/#4707).cargo xtask policy: 464 files ok (--staged: 1 files ok).Checked for overlap
#4754(closed on5fabb46eciting#2392+#2188):#2392reduces hard-commit deferrals by counting pagefile growth as available commit and#2188exitswait_for_pipeline()oncePending::defer()has run, but neither covers: (1) unbounded worker waits underVerdict::Throttle(soft physical-RAM floor /upload_refused, which never defers on workers), (2) the up-to-10 sWAIT_WORKERwait incompilemem::begin()beforePending::defer()runs underVerdict::Commit, (3) inline compute blocking oncompilemem::begin()(WAIT_OTHER= 1 s) orp.building.lock()under commit/throttle pressure, or (4) thestart()->ready()TOCTOU and idlememguard-deferred (!driver_oom) wait races.#3398is conflicting/dirty and superseded by#2188/#2469; it does not covercompilememgate waits or the non-driver_oomunqueued race.#2886lowers the commit floor after 3 put-offs (starved_compile) without fixing draw waits while workers are parked incompilemem::begin()or theready()/wait_for_pipeline()races.#3426caps waits to 100 ms only on 1 Hzresidency::pressured()and altersresidency.rscommit-growth accounting.#3347changes policy by disablingcompilememin gameplay rather than fixing thepipeline/makedraw-wait interaction.#3788caps totalwaits_as_screen()wait per pipeline across frames (orthogonal/complementary).#4255reorders waited-on screen passes ahead of FIFO inQueue::screen(orthogonal/complementary).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T22:38:43Z.
One behaviour change in
ready()that I think goes further than the description says (crates/victory-gpu/src/pipeline/make.rs:713):retry_atis set indefer()and never cleared again outside tests, sodeferred_beforestays true for the rest of that pipeline's life. After the first memory deferral, no laterready()waits for it or makes a compute pipeline inline. Its draws are dropped until a worker finishes it, and that includesscreen || characterpasses, which the description says keep waiting under soft throttle. A full-screen pass dropped for a few frames shows up as a flash, which is the kind of A-B-A flicker we count.If the aim is only to stop draws stalling on the retry cycle, a narrower fix would be to skip the wait only while
p.mem_wait != MEM_NONEor the gate is commit-blocked (whichmem_gate_stopsalready handles), or to clearretry_atonce the retry has been queued. Then a pipeline that was deferred once is treated like any other after memory recovers.(The CI failure is main's clippy errors that #4484 fixes; the new tests have not run in CI yet.)
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T03:09:20Z.
@IRennie74 Thanks for catching that sticky
retry_at/deferred_beforebug inready()!Rebased onto
7d93ee0759and pushed5adb194cto address it:deferred_before = p.retry_at.load(Ordering::Acquire) != 0gate fromready(), while keepingretry_atintact fordriver_oomrate-limiting (retry_blocked()/NEXT_DRIVER_RETRY) andwait_for_pipeline()'s idle-exit guard.start(p, REQUESTED)still returnsfalse(preserving the TOCTOU fix); once the cooldown expires and memory recovers,screen || characterpasses wait normally (including under soft throttle) and compute pipelines resume inline builds instead of dropping frames, whilemem_gate_stops(),mem_gate_allows_inline_compute(), andwait_for_pipeline()still exit immediately if the compile-memory gate is blocked or the retry defers again.screen_and_character_passes_wait_normally_after_memory_deferral_recovers,compute_pipeline_builds_inline_again_after_memory_deferral_recovers, andready_does_not_block_on_retry_of_memguard_deferred_pipeline_when_gate_blocks) —cargo test -j 2 -p victory-gpu --locked --lib -- pipeline::make compilemem --test-threads=1passes 60/60, and clippy passes with 0 warnings on7d93ee0759.One live cold-compile soak note: under soft physical-RAM throttle, true full-screen passes can still hit multi-second waits when queued behind ordinary
wait_alldraws inQueue::screenFIFO or across repeated per-frame screen budgets. Those two pieces are already tracked in #4255 (FIFO priority for waited-on passes) and #3788 (cross-frame screen wait cap), so I intentionally kept them out of #4471 to avoid conflicts and preserve thescreen || characteranti-flash guarantee. Updated bullet 2 of the PR description to match5adb194c.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T11:00:22Z.
Rebased onto
origin/main(5fabb46eaf) and pushed62b6e987to close two remaining edge cases incrates/victory-gpu/src/pipeline/make.rs:Queue::requestedworker saturation with idleSCREEN_WORKERS: Tracked non-screen workers (!screens_only: general + asked-only) separately alongside total workers viaWorkerCountersand an unwind-safe RAIIWorkerBusyGuard(enter_and_notify), waking waiting draws vianotify_waiters()after theSeqCstincrements when eitherQueue::requestedorQueue::screensaturates under a commit or throttle block. BecauseSCREEN_WORKERSonly popQueue::screen, compute andVICTORY_PIPELINE_WAIT_ALL=0graphics draws no longer burn the 500 mswait_budget()per frame when all non-screen workers are busy whileSCREEN_WORKERSsit idle.Verdict::Throttle): Tightenedmem_gate_allows_inline_compute()to also reject inline compute builds whencompilemem::throttle_blocked()is active for non-screen/non-character compute passes, preventing recording-thread stalls incompilemem::begin()(WAIT_OTHER= 1 s) or unbounded blocking onp.building.lock()while preservingscreen || characteranti-flash behavior when no worker is already parked on that pipeline.WorkerCounters::enter_and_notify+wait_for_pipeline_with()saturation wakeup and unwind-safety tests, plus liveready_with_gate()soft-throttleMEM_NONEinline compute fallback vsscreencompute anti-flash tests.Also updated the PR title (removing the stale "and memory-deferred retries" suffix) and added an overlap note in the PR body explaining the remaining gaps after
#4754/#2392+#2188.Verification on
62b6e987:cargo test --locked -p victory-gpu --lib -- pipeline::make compilemem --test-threads=1:61 passed, 0 failed(plusVICTORY_PIPELINE_COMPUTE_WAIT=0,VICTORY_PIPELINE_WAIT_ALL=0,VICTORY_PIPELINE_WAIT_FREE=1,VICTORY_PIPELINE_ASKED_WORKERS=2,VICTORY_CHARACTER_WAIT=1,VICTORY_PIPELINE_WAIT_MS=0, and--features diagnostics:61/61passed).cargo test --locked -p victory-gpu --lib(full parallel):1105 passed, 0 failed, 66 ignored.cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand--all-features:0warnings/errors in touched files (pipeline/make.rs,pipeline.rs,compilemem.rs; only the 5 pre-existingmain#4634errors inhost/{font,menu,panel}.rs).cargo xtask policy:464 files ok(--staged:1 files ok).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T12:33:51Z.
Live runtime verification on updated
WorkerBusyGuardhead62b6e987(RTX 3060 Ti 8 GB (ReBAR off, driver621.40), 32 GB RAM, Windows 11, Series S, DLSS Quality, FSR 3 FG, RT off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12— 5-minute (300 sin-world,357 stotal) live validation on a combined 15-PR release build overorigin/main(5fabb46eaf).):300 sin-world (357 stotal) with0crashes,0nvlddmkmevents, and0Victory errors.Free RAM 373–482 MB,residency: host memory pressureactive) alongside+3,054newly translated shaders (12,262 -> 15,316),0a pass over the screen was waitedstalls were logged; steady-state held20.61 FPS(47.80 msmedian,70.15 msp99).+31 s,+151 s,+285 s) verified clean (no dropped full-screen pass flashes).Caveat: combined 15-PR release build over a 5-minute opening/cell sequence;
FreeCommitstayed above6.4 GB, so hardVerdict::Commitsaturation was not triggered during this run (covered by the 61 unit tests inpipeline::make/compilemem).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:41:06Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed