Repository navigation
d3d12: a pipeline a frame waits for goes before those asked for earlier (D3D12-PIPELINE-WAIT-QUEUE) - #2622
Conversation
…er (D3D12-PIPELINE-WAIT-QUEUE) A draw whose host pipeline is not made queues it at the back of the requested list, and its frame then waits for it up to the frame's budget. On the first visit to the world about 1,700 pipelines were queued at once, 562 of them took over a second each, and with the launcher's 10 s budget every frame waited the whole budget for a pipeline a thousand others stood before, then dropped its draws anyway: 0.35 fps for three and a half minutes (RTX 3080, 8 workers). A new queue state, AWAITED, sits between REQUESTED and MAKING. When a frame starts waiting for a pipeline that is still in the queue, the entry moves to the front of its list (passes over the screen in theirs), after those awaited before it, so the next free worker makes it. It moves at most once, is never claimed twice, and WAITING does not count it again; makes already running are not interrupted. LEONIDA_PIPELINE_AWAIT_FIRST=0 keeps the order asked. Frames on a cold cache 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 instead of one it drops. The budget setting bounds that, as before.
|
Independent native Windows 11 + AMD Radeon RX 7900 XTX (
AI-assisted: Antigravity (Gemini 4 Neon). |
|
Independent check of I found a wait-budget gap under queue contention. A test-only hook after the actual
This is a synthetic lock-contention test. AI-assisted with OpenAI Codex. |
|
RUN - D3D12-PIPELINE-WAIT-QUEUE A/B (PROVISIONAL) - OreoFR, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11. Build
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). |
|
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
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. |
…its for (review) wait() started its timer after promote() took the queue's lock, so time spent waiting for that lock came on top of the frame's budget: in a synthetic contention test (queue held 240 ms, 80 ms budget) a frame waited 320 ms. The timer now starts before the promotion, so the lock delay is part of the budget (240 ms in the same test, the lock holder's time itself). Reported with the test by merzleckeier.
|
Thanks for the checks and the runs.
|
|
RUN · VERIFY-2622-RTX4060 · by MoonEyes (another person than the author) on head
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. |
|
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.
This run was AI-assisted (Claude Code, oreofr-agent). |
|
Merging. Head AI-assisted (Claude Code). |
… 1D wave-base (ProjectLeonida#2685), NaN-exact, by_due texture queue, unlocked pool growth (ProjectLeonida#2693), pipeline wait queue (ProjectLeonida#2622)
Claimed in the coordination issue as: D3D12-PIPELINE-WAIT-QUEUE (#2570 (comment))
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: runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569, GPU: pipeline workers get a 64 MB stack for the driver's compiler #2588, d3d12: keep pipeline wait budgets from moving backward #2601).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)