d3d12: a pipeline a frame waits for goes before those asked for earlier (D3D12-PIPELINE-WAIT-QUEUE) #2622
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2622"
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 ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T18:40:15Z.
Claimed in the coordination issue as: D3D12-PIPELINE-WAIT-QUEUE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7249422163)
Depends on: #2601 (it touches the same function; this change avoids its lines, and
git merge-treemerges the two cleanly)What and why
When a draw's host pipeline is not made yet,
ready()queues it at the back of the requested list, and the frame then waits for it up to the frame's budget (LEONIDA_PIPELINE_WAIT_MS; the launcher sets 10,000 ms).I measured this on an RTX 3080 (main
7daa4a4a5, first visit to the world, empty pipeline cache, 8 workers):This change adds a queue state,
AWAITED, betweenREQUESTEDandMAKING:Queue::promotemoves that entry to the front of its list, after those awaited before it. That is the requested list, or the screen list for passes over the screen.WAITINGdoes not count it again, and a make a worker has already started is not interrupted.LEONIDA_PIPELINE_AWAIT_FIRST=0keeps the order asked, as before.What the claim also proposed and this change does not do: skipping a wait that "cannot succeed". The only build time the runtime records per pipeline is the cold compile, in the slow map.
leonida warm --usedputs those pipelines in the driver's cache before the game starts, so a rule based on that time would skip waits that would have succeeded.Frames on a cold cache can still wait up to the frame's budget. The waits now succeed, so a frame may spend its budget on several pipelines it then draws, rather than on one it drops. The budget setting bounds that, as before. The measurements below show both sides of this.
Tested
On Windows 11, from
d3d12\:pipeline::make::tests. They fail onmain, wherepromote/AWAITEDdo not exist and the order is first in, first out.an_awaited_pipeline_is_made_before_those_asked_earlieran_awaited_early_pipeline_is_claimed_oncean_awaited_pass_over_the_screen_goes_first_among_themcargo test -p leonida-gpu --locked: 540 passed. Thepipeline::maketests also pass with--features diagnostics.cargo clippy -p leonida-gpu --all-targets --locked: nothing inmake.rs.rustfmtwithd3d12/rustfmt.toml: nothing in the changed lines.clippy -D warningsandcargo fmt --checkare already red onmainin other files.git diff --checkis clean, and so ischeck_no_game_data.py.REQUESTEDtoAWAITEDtoMAKINGhappens underQUEUE, and the lock order and wakeups are unchanged.WAIT_MS=10000(launcher default)WAIT_MS=1000Reading: no wait expires any more. With a 1 s budget, 25 % fewer draws are dropped, the worst frame drops 73 % fewer, and the slowest second is 7 times faster. With the launcher's 10 s budget, drops stay about the same, but more frames wait several pipelines up to the budget. That is the budget's doing: this change makes no wait longer, it only lets more of them succeed. Both sides drained the queue (about 1,600 pipelines) in the same time, about 80 s.
Not yet measured: a real cold driver cache. Two in-game A/B runs on other machines (RTX 4070 and RTX 3090, the latter with the driver's cache cleared) are planned with this branch; their numbers will follow in a comment.
GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300.
AI-assisted: yes
Checklist
mainand merges cleanly (also with the open pull requests onmake.rs: #2569, #2588, #2601).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T18:47:37Z.
Independent native Windows 11 + AMD Radeon RX 7900 XTX (
gfx1100, driver32.0.32029.2010, Windows 1110.0.26200) check offfd3681b2merged cleanly ontomain4755667f5(no game files):main4755667f5):cargo test -p leonida-gpu --lib -- --test-threads=4->544 passed; 0 failed; 47 ignored(12.27 s).#2622(ffd3681b2) +main4755667f5:cargo test -p leonida-gpu --lib -- --test-threads=4->547 passed; 0 failed; 47 ignored(13.86 s, +3 newpipeline::maketests, 0 regressions, 0 new compiler warnings).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/pipeline/make.rs: clean.AI-assisted: Antigravity (Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T18:48:51Z.
Independent check of
ffd3681bwith #260123360208onmain7c330c76. The three new priority tests passed in a Windows x64diagcross-build under Wine 11.22.I found a wait-budget gap under queue contention. A test-only hook after the actual
wait()reserves its frame budget let the fixture holdQUEUEfor 240 ms with an 80 ms frame budget. Three runs per arm, one pending pipeline, no worker or GPU work.QUEUE, mspromote(p)wait()currently starts its timer afterpromote(p)acquiresQUEUE. Movinglet started = Instant::now()just above theif await_first()block kept priority promotion and all three priority tests intact. It also charged the lock delay against the condition-variable wait. The frame still waited for the lock holder in the forced-contention fixture.This is a synthetic lock-contention test. AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T19:41:59Z.
RUN - D3D12-PIPELINE-WAIT-QUEUE A/B (PROVISIONAL) - OreoFR, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.
Build
ffd3681b2on mainbd643e46e, diag profile, oneleonida.exefor every run. A =AWAIT_FIRST=0, B = PR default. Cold pipeline cache per run (fresh data folder); launcher defaults in both arms (frame generation 2x,LEONIDA_WINDOWS_BAR_MB=3072). About 4 min in the world per run, measured from the first frame line with 100+ draws.Verdict: the change does what it says on expired waits, with no regression seen (no device loss, no new crash in B). It brings no fps or stutter gain on an 8 GB 4070 Laptop at the default budget.
This run was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by hardly-relevant on 2026-11-29T20:51:34Z.
RUN · VERIFY-2622-RTX4080-LAPTOP · PROVISIONAL (A/B/A′)
Windows 11 build 26300, RTX 4080 Laptop GPU (12 GB, profile M), NVIDIA 621.40, 32 GB RAM, Balanced power plan. One diagnostics build from main
dd87aa405(includes #2601), with #2622 atffd3681b2, #2623 for stall captures, and #2613 for frame-time statistics. Series X 2560×1440, 2× frame generation capped at 28 shown FPS,LEONIDA_PIPELINE_WAIT_MS=1000,LEONIDA_LOG=info. Each run started from a copy of the original save and a precompiled application cache. The NVIDIA driver cache was kept across runs.Dropped work includes draws, dispatches and indirect executions. The tester reported the same save and a roughly matched driving route for A and B. They waited near spawn for the first backlog to clear in A, could drive immediately in B, and reported that A′ felt much closer to B. All three runs exited normally. A′ logged one pipeline-library save failure due to disk space near exit. Its telemetry and stall capture were retained.
Verdict. B improved on the initial A, and A′ reproduced B’s low backlog with promotion off. The driver cache could warm across runs, time before world entry varied substantially, and the driving route was approximate. The size of the promotion benefit on this machine remains unresolved.
Queue-lock timing. The tested code starts its timer after promotion can acquire the queue lock. Our rolling stall capture did not identify waits on that lock, so this gameplay test cannot establish whether that extra delay occurred. The synthetic contention test isolates that case.
AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T03:15:12Z.
Thanks for the checks and the runs.
wait()started its timer afterpromote()had taken the queue's lock, so a lock delay came on top of the frame's budget. Fixed in61c5b18d8: the timer now starts before the promotion. The three priority tests still pass (cargo test -p leonida-gpu --locked pipeline::make: 10 passed). The branch merges cleanly withmain1d22590b9and with #2569 and #2588.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T17:14:16Z.
RUN · VERIFY-2622-RTX4060 · by MoonEyes (another person than the author) on head
46688881emerged withmainbe454caa4. Windows 11 Pro 26300, RTX 4060 8 GB,-SeriesS -FrameGen 2, diag build, warm pipeline cache.cargo test -p leonida-gpu --lib --locked: 574 passed, 0 failed.AI-assisted (Claude Code).
Correction (same run): the pipeline cache was not warm. The build was the first with #2710, so the shaders were translated again (780 s before the title) and frames stayed under 5 fps until about 350 s after the start; from then on about 250 s of steady frames (median 16.7 fps shown, other work on the PC). The title was in the world from about 160 s, and nothing failed over the whole 616 s.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T17:48:07Z.
RUN - cold-cache A/B (Verified by OreoFR), MEASURED on expired waits, PROVISIONAL on the rest - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.
08e42a516; B = main + this PR at46688881e(git merge --no-ff, clean), diag build ofleonida.exe.play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, the launcher's 10 s wait budget. Each run stands, then walks with W held fromlift 3(game actions) for 150 s, about 6.5 min in the world. Order A B B A, then one more pair B A: 3 runs per arm.-Datafolder with nocache-2\pipelines, so no pipeline library or book.leonida.exestarted from a new folder. A probe without the game showed that the NVIDIA driver's cache keys its entries on the executable's path: the same file copied to a new path compiled cold (34 ms against 0.4 ms warm).This run was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T17:51:21Z.
Merging. Head
46688881emerges cleanly withmainafb511541and does not force a rebase of #2566. Run in the game of 480 s without device loss on RTX 4060 and six cold-cache runs on RTX 4070 Laptop (expired waits 36-37 to 0-1, no regression seen, no visible gain either) on this head; cargo test 574 passed. Merged by MoonEyes.AI-assisted (Claude Code).