[pr-fix][shaders][memory] A pipeline the driver refused for memory is retried by the workers, not by the frame that asks #367
Loading…
Reference in a new issue
No description provided.
Delete branch "Andreww2009/Darner-Opt:claude/pipeline-oom-no-wait"
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?
Contributor role (optional)
What it changes
The problem on main: one player's session (RTX 5080 Laptop 16 GB, driver 621.47, release v2026.12.03.02 = this
main's translator, warm cache, Series X profile, 1440, DLSS Quality, FG 2x) had seven frames of 1641, 1666, 1660,1449, 1698, 1526 and 1550 ms in 17 s, and no other frame over 1 s after entering the world. The log at that moment:
Each long frame ends right after an attempt; attempts are ~2.6 s apart = the 1000 ms pause + 1.4–1.7 s the
driver takes to refuse. In
ready()the pause is honoured (retry_waits), but once it is over a compute dispatchtakes the compute-wait path again (
compute_waits() && compute_room(frame), 3000 ms a frame): it makes the pipelineon its own thread or waits on the build's lock behind the worker. So every refusal is paid by a frame, for as long
as the driver keeps refusing. Only this one pipeline was refused in that session (200 others were made, ~6 800
loaded from the library).
And the driver keeps refusing: made alone in a fresh process (
darner warm --these <its number>, the sametranslator), the driver refused it 3 times out of 3, 1.9–2.1 s each, with
proc_commit_mb=188 vram_used_mb=14 sys_free_mb=56596:So here
E_OUTOFMEMORYis not memory pressure (one pipeline cannot fill the 512 MiB shader heap); the driver willnot build this pipeline at all, and on main each retry stalls a frame for as long as the title asks for the pass.
(Why NVIDIA's compiler refuses this translated shader is a separate issue.)
What this does: new
DARNER_PIPELINE_OOM_NO_WAIT(on by default,0= as before). A pipeline whose compile thedriver refused with
E_OUTOFMEMORY(driver_oom, set byPending::defer) is retried by the workers only; when adraw or dispatch asks for it after its pause, it is dropped at once, as it already is during the pause. The retry
pacing (
retry_at,NEXT_DRIVER_RETRY) is unchanged, andstart()still re-queues it, so an attempt that succeedsis used from the next ask on. Pipelines that were never refused take the same path as before, and so does the first
attempt at any pipeline (nothing knows yet that the driver will refuse it): in the session above the change would
leave the first of the seven frames and take away the six repeats.
The visual cost is the one main already has between attempts: that pipeline's draws/dispatches are skipped until an
attempt succeeds — now also during the attempt itself, instead of the frame standing 1.4–1.7 s for it. For a pipeline
the driver never builds (as here) the pass is missing on main too; only the stalls go.
How it was tested
Tested revision:
f3840d73+ this change (uncommitted at test time; the commit is the same diff, except thatoom_aside's doc comment was reworded after the release build; clippy gate 1 was run again on it, clean).Commands and results (Windows 11 26300, rustc 1.98.1, MSVC 14.44.35207, SDK 10.0.26100.0):
pipeline::make::tests::a_pipeline_the_driver_refused_for_memory_is_not_made_by_the_dispatch_asking:runs itself in two child processes (the switch is read once): unset → the asking dispatch neither makes nor waits
for it and the worker keeps its attempt;
=0→ the dispatch makes it on its own thread, as on main. Passes withthe change; fails with the
oom_asidebranch removed (panicked at ... the dispatch made it itself).pipeline::make::testspass.cargo test -p darner-gpu --lib, three runs: the new test passed in all three; each run had 1–2 failures, all inmodules this change does not touch (
watch::tests::ask_once_by_res_splits_reservations_without_refusalstwice,watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs,host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due,descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync). Each of those four passed alone 3 of 3;the watch ones fail on plain
mainhere too (3 and 1 of 12 runs; #150/#224/#261/#262 are about these).Changes a default: yes, for everyone; it changes something only once the driver has refused a pipeline for memory.
A/B result: one in-game run with the switch flipped every 15 s (
--features ab,DARNER_AB=15,DARNER_PIPELINE_OOM_NO_WAIT),31 min, 123 phases (62 A off / 61 B on), warm cache copy, Series X profile, 1440, DLSS Quality, FG off, no frame cap,
RT off. The refused pipeline was not used in that run (no first bind of
c1eee35dbc50a9ef, noE_OUTOFMEMORY), so itshows only that nothing else changes; in the player's sessions this pipeline came up once in ten.
The long frames of the A/B run (517–1223 ms, both sides) are first builds of new pipelines (
pipe_made1–3,pipe_wait_ms1.0–2.4 s), not refusals.Gates run on that revision:
cargo clippy --workspace --all-targets --locked -- -D warningsclean;cargo clippy --workspace --all-targets --all-features --locked -- -D warningsclean;cargo xtask policy:555 files ok. No CI.
Gameplay: RTX 5080 Laptop 16 GB, driver 621.47; the session with the problem: Series X profile, 1440, DLSS Quality,
FG 2x, RT off; the A/B run as above.
Shader wave sizes tested: not relevant.
Hardware dependence: the change is general (any driver's
E_OUTOFMEMORY); the refusal itself was seen on NVIDIA621.47 (and #100's comment reports such refusals on 635.05).
Coverage gaps: the change has not yet met a refusal in play (the unit test covers the path; the fresh-process run
shows the driver keeps refusing). With the change a worker still retries the refused compile (~2 s of one core
every ~3 s while the title asks for it); stopping after a few refusals while memory is plentiful would be a
follow-up, not part of this PR.
Checklist
main.docs/asset-policy.md.Checked for overlap
warm-bad.txtlists are refused in play; it lists compiles that crashed or hung a warmchild, not a refusal for memory: the warm on this PC refused this pipeline and
warm-bad.txtstayed empty, so thetwo cover different pipelines; it touches
Pending::make, thisready(), andgit apply --checkof #365 on top ofthis branch is clean). #350 (a memory gate before compiles; touches
pipeline/make.rsin other places), #164(NVIDIA shader heap profile). Related report: #100, comment 851686 (RTX 4070 Ti SUPER, NVIDIA dev driver 635.05: the driver's
compiler "consistently returns E_OUTOFMEMORY" for various compute pipelines), so such refusals are not only this
PC's. No issue or PR about frames waiting for the retries (searched open and closed for
E_OUTOFMEMORYand the key).🤖 Generated with Claude Code
Testing this now in-game (head
681aa8e, release build with bench-remote).Setup: RTX 5070 Ti 16 GB, Ryzen 7 7800X3D, 31 GB RAM, 1440p DLAA, DLSS frame generation 2x, hardware RT on. Automated camera flight over the city (same route and save every run, separate home/data/cache folders).
Plan: same build, A/B on the switch: default (on) vs DARNER_PIPELINE_OOM_NO_WAIT=0 (main's behaviour), alternated runs. This PC has never logged the E_OUTOFMEMORY refusal so far, so this run checks mostly that nothing else changes. I'll post fps / p99 / long frames when it's done.
Code review only (read the diff at
681aa8e), nothing built or run.big_asideright above deliberately leaves outp.screenandp.scene_input("a dispatch made only once is lost…, not for the first scene's and the passes over the screen").oom_asidedoesn't, and it covers graphics pipelines too. For a pipeline the driver never builds (your case) nothing changes. Butdriver_oomis also set when the refusal is real memory pressure, and then a retry can succeed a few seconds later. With this change, a refused pass over the screen shows missing until then, and a one-shot scene-input dispatch is lost, wheremainwaited. Adding&& !p.screen && !p.scene_inputtooom_aside, asbig_asidehas, would keep those on the old path.waitersstays 0, and #350's gate would treat the worker's retry as unwaited and hold it behind every waited-on compile. If both land, counting an asked-fordriver_oompipeline as waited would keep its retry from going last.startbefore the branch), the unchanged retry pacing, the first attempt still on the old path, and the two-process test of both switch states.Reviewed with Claude Code (AI-assisted); findings checked by a human before posting.
a248a03 applies the screen and scene-input exclusions from the review. These passes keep the existing wait path after the retry delay, since they may be submitted only once. Other driver-OOM retries still use the workers.
A Windows fixture comparing the exact old and new predicates restored the three protected-pass cases and preserved all 13 controls. I also extended the existing two-process regression for both switch settings. Scoped GPU Clippy including test targets, asset policy and diff check passed. This check used synthetic OOM state. The retry-priority interaction with #350 remains relevant for ordinary worker-only retries.
If you cherry-pick or rebase this commit, please keep the Git author. If you fold it into another commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>Test report for
681aa8e(release build withbench-remote, on mainf3840d7).PC: RTX 5070 Ti 16 GB, NVIDIA driver 621.47, Ryzen 7 7800X3D, 31 GB RAM, Windows 11. Series X profile, 1440p DLAA, DLSS frame generation 2x, hardware RT on.
The refusal reproduces on a desktop card.
darner preloadon a cold cache for this translator (25,789 shaders translated, 7,047 of 7,049 pipelines into the library, 452 s) hit the same pipeline:The driver took about 2.1 s to refuse it (21.36 to 23.50 in the log), with 54 GB of RAM free and 15 MB of VRAM in use. So, as you found, this is not memory pressure: same driver (621.47), a different card (5070 Ti desktop instead of a 5080 Laptop).
In-game A/B (same build, switch only): automated camera flight over the city (
cam-city60, same save and route each run, its own home/data/cache folders, warm cache after the preload). 6 runs alternated: on, off, on, off, on, off (DARNER_PIPELINE_OOM_NO_WAIT=0for off).The refused pipeline was never asked for in these 6 runs (no
c1eee35dbc50a9ef, noE_OUTOFMEMORYin any play log). Becauseoom_aside()only reads the switch oncedriver_oomis set, both arms ran the same code here: this is effectively an A/A run, and the gap above is run-to-run noise on this route, not an effect of the change. So this shows no regression from the change, but it does not show the stalls going away in play; I have not seen that pipeline in a play session on this PC.Not run: the three gates (
cargo clippyx2,cargo test).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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.