Skip to content

D3D12.X: the builds a submit waits for do not take turns among the big compiles - #2141

Closed
Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:fix/submit-builds-lane
Closed

Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:fix/submit-builds-lane

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

State on 25 November: #2118 is rebased on main 426a5a7 (b7d0ef2); this branch is still on #2118's earlier head and conflicts. main has since merged ae00ec7, which lets two builds the title waits for run at once and no more, so the numbers below, measured before it, do not say what this lane adds now. It stays a draft until that is measured again.

Stacked on #2118; its own commit is the last one, 1a18762.

Big driver compiles on the workers go one at a time (BIG_COMPILES), each once the commit headroom it asks for is free (#1774). With #2118 a pipeline whose call was put off to the submit is one the title needs for this frame. Here its build takes a lane of its own, four at once, so those builds run together, each still waiting for its headroom. From cold driver caches a retail title finished 69 compute builds of 3 s or more in the 211 s after its world start with both, against 31 with #2118 alone and 34 without either (Linux, 1 run each). Scheduling under #2088; part of #505 and #1833.

Beside #2098. #2098 scales BIG_COMPILES' slots with the CPUs, so the workers' big builds already run several at once. With it merged this lane's four should be its number, not a second one: if it merges first I rebase onto it and measure again. Not measured with #2098 in.

What is in it

  • real.rs: SUBMIT_COMPILES, a lane of four, which compile_slots gives a build that pso_async::build_is_needed_by_submit(). Programs of 4 MiB or more stay in GIANT_COMPILES, one at a time. A build already waiting for its turn when its call is put off stays there.
  • pso_async.rs: build_is_needed_by_submit, read from the flag D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118's need_by_submit sets; test a_build_knows_a_submit_needs_it.

Tested

compute builds of 3 s or more finished after the first #101 their build-seconds per second of them on title threads most at once queue.Wait timeouts dispatches skipped
without either 34 1.56 21 4 0 0
#2118 alone 31 2.01 8 4 0 0
with the lane 69 4.70 3 7 0 0
  • Three more runs of forms with this lane finished 76, 70 and (stopped at 232 s) 59 such builds. The title is not past its world start in any of them.
  • On Windows by fewmet (the comment below; RTX 3060 12 GB, 32 GB RAM, default compile threads, cold driver caches, 300 s, 5 runs of cbc296a and 2 of 1a18762): such builds finished 7, 12, 7, 8, 7 against 17, 10; most at once 2–3 against 7, 4; peak commit 44.8–45.5 GB against 46.6, 47.1 GB; least available memory 5.3–6.9 GB against 4.8, 4.6 GB; 0 queue.Wait timeouts, 0 dispatches skipped, no removal or crash in the seven. So on a 32 GB machine D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118 and the lane together cost about 1.5 to 2 GB of commit at the peak and left 4.6 GB available; D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118 alone was not run there.
  • Native Windows (NVIDIA GeForce RTX 2070 SUPER 8 GB, driver 621.01, Ryzen 7 5700X3D, Windows 11 Pro 26200, rustc 1.100.0), on 1a18762: the pso_async::, list_x::, title_list::, bind::, alloc_pool:: and real:: tests in debug, 95 passed, 0 failed; scripts/smoke.ps1 1560 frames against main cbc296a's 1568, 60 60 60 on both, 0 removals, 0 crashes, peak commit 14488 MB against 14458 MB. On the earlier form 33424af: the pso_async::, list_x::, title_list::, bind:: and alloc_pool:: tests in debug, 48 passed; scripts/smoke.ps1 1539 frames against main cbc296a's 1568, 60 60 60 on both, 0 removals, 0 crashes, peak commit 14485 MB against 14458 MB.

Regression run
Under Wine on Linux, as in #2118 (peak commit reads 0 MB there; exit: 0x89 is the wrapper ending Wine).

main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 4060 Ti 8GB
title: 1253b9d5
seconds: 60
exit: 0x89
frames shown: 1416 (PresentX 1416)
presents per 2 s (last 3): 60 50 35
device removals: 0
crashes: 0
peak commit: 0 MB

PR:

xcl-smoke v1
commit: 1a18762674cab845df8b6a4df3f89e11711f4d83
gpu: NVIDIA GeForce RTX 4060 Ti 8GB
title: 1253b9d5
seconds: 60
exit: 0x89
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

AI use

  • Claude Code (Claude Fable 5.2) wrote the change and the test, made the runs and wrote this description.

…bind

A compute pipeline that is not built yet was waited for at its bind: the
title's thread stood in SetPipelineState, built the pipeline itself, and
only then reached the next one. A title that binds many unbuilt compute
pipelines in one frame got them one after another.

SetPipelineState now binds what is there. A Dispatch, or an
ExecuteIndirect that dispatches, whose pipeline is still being built
ends the list's segment, as a mid-list Wait after a Write64 does, and
gets a closed segment of its own between that one and the next: a
translated dispatch sets everything it needs itself (root signature,
the six views, the pipeline), so it can be recorded later than the
calls around it. The title's threads go on recording, and the pipelines
the frame binds next reach the workers while this one is built. At
ExecuteCommandLists (and KickoffX) each such segment is reset and its
call recorded through the same wait the bind made (XCL_PSO_WAIT_MS
still bounds it). A dispatch whose pipeline fails to build is skipped
and counted, as before.

While a submit stands in that wait, the lists it carries and their
Write64 signals are not on the queue yet, and another queue's GPU wait
for one of them ran into the 5 s watchdog and was released on the CPU
(3 lines a run). The watchdog's clock now stands while a bind or submit
is held for a build.

A put-off pipeline goes before the workers' queue: behind a start-up
backlog the submit thread would build them itself, one after another,
where several title threads built at once before (a debug build on
Windows stopped presenting on its first screen that way).

At the submit the next four of its put-off pipelines are marked wanted
as it goes, the leave a title thread's own build has today, so about as
many are in the driver at once as the title's threads had there before.

The segments of a title list record on an allocator of that list's own,
because the title's may be recording another list by the submit; it is
not released while the GPU may still run from it. They share one
argument arena: a block each filled the coherent window.

A recording takes 256 extra segments (32 before), two for each such
call. Past that, on a list that cannot be split, and under predication
the call waits where it is, as before. The console-list replay, Reset,
ClearState and KickoffX's re-open wait where they did.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…g compiles

Big driver compiles on the workers go one at a time (BIG_COMPILES), each
once the commit headroom it asks for is free. A pipeline whose call was
put off to the submit is one the title needs for this frame: its build
now takes a lane of its own, four at once, and still waits for its
headroom. Programs of 4 MiB or more stay in their lane, one at a time.

From cold driver caches, with four compile threads, a retail title
finished 69 compute builds of 3 s or more in the 211 s after its world
start with this and the commit below it, against 31 with that commit
alone and 34 without either (Linux, 1 run each).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@fewmet

fewmet commented Nov 25, 2026

Copy link
Copy Markdown

Tested 1a18762 (this PR on #2118's fb1a905) against its base cbc296a on native Windows, in the retail title (1.0.2.1), on a machine with less memory than the runs above.

Hardware: RTX 3060 12 GB (32-lane waves), driver 32.0.16.1062 (610.62), Ryzen 7 5800X, 32 GB RAM (commit limit 56 246 MB with the page file), Windows 11 Pro build 26300, rustc 1.100.0, DXC 1.8.2502.11 from the Windows SDK. Each commit built with cargo build --release -p xcl in its own worktree and target folder.

Tested

  • On 1a18762, debug: cargo test --workspace -- pso_async:: list_x:: title_list:: bind:: alloc_pool:: --test-threads=4: 49 passed, 0 failed.
  • Title runs: xcl run <game folder> with XCL_NETWORK=0, XCL_MUTE_TTS=1, XCL_ACTIVITY=1, XCL_RUN_SECONDS=300, default compile threads, no XCL_PSO_WAIT_MS. Every run from cold driver caches: NVIDIA's DXCache emptied, and XCL_DXIL_CACHE set to a fresh copy of one DXIL cache without its driver folder. A held at 60 s and every 15 s up to 242 s (the account screen). Memory sampled every 2 s from outside XCL. Base 5 runs, this PR 2. The PR runs and the last base run started from the same DXIL copy; the first four base runs from one about 20 MB smaller.

Compute driver compiles of 3 s or more that finished (all after the first #101); build-seconds of those per second from the first #101 to the end; their gate note in the log (gated / wanted at once / ungated here, a title thread's); most at once; compiles still running at 300 s; least available memory, peak system commit and peak private bytes of the XCL processes:

finished build-s/s gated / wanted / ungated most at once running at 300 s least available peak commit XCL private
base cbc296a, 5 runs 7, 12, 7, 8, 7 0.59 – 0.95 0 / 0 / all 2 – 3 0 – 2 5 322 – 6 863 MB 44 824 – 45 482 MB 28 576 – 29 132 MB
1a18762, 2 runs 17, 10 2.05, 1.46 9 / 2 / 6, 6 / 2 / 2 7, 4 4, 2 4 774, 4 610 MB 46 565, 47 076 MB 30 349, 30 711 MB
  • So on Windows, as under Wine, more of the big compiles run at once and fewer of them on title threads. The cost here is about 1.5 – 2 GB more commit at the peak, leaving 4.6 GB available on 32 GB. Shaders: size-based admission for big compute driver compiles #1774's headroom held one build back for 1 486 ms; every other gated build waited 0 ms.
  • What the title shows does not change within 300 s: in all seven runs the last frames presented line is the 2 700-frame one at 101.6 – 102.6 s, and 2 869 – 2 925 frames were shown by 300 s. The first #101 came at 122 – 147 s. No run is past the world start.
  • 0 queue.Wait timeouts, 0 dispatches skipped, 0 device removals and no crash in all seven.

Regression run (scripts/smoke.ps1 -Seconds 60, no input):

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3060
title: 2f8ea335
seconds: 60
exit: 0x0
frames shown: 1545 (PresentX 1545)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15322 MB
xcl-smoke v1
commit: 1a18762674cab845df8b6a4df3f89e11711f4d83
gpu: NVIDIA GeForce RTX 3060
title: 2f8ea335
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14963 MB

Not tested

AI use

  • Claude (Claude Opus 5.5) wrote the run scripts, made the builds and runs on my PC and wrote this report from their logs; I asked it to post it.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@fewmet thank you: that is the Windows title run and the memory figure this was missing, at the default thread count, and your numbers are in the description now. Still open on my side: #2118 alone in the title on Windows, to split the 1.5 to 2 GB between it and the lane, and a run with #2098 merged in.

AI use: Claude Code (Claude Fable 5.2) wrote this.

Posted without review by a person: the account owner was away and reads replies later.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Closing: #1996 (merged as ae00ec7) gives the builds a submit waits for a cap of their own, XCL_HUGE_PSO_WANTED_CONCURRENCY. At 6 it did on our RTX 4060 Ti what this lane did (1 run: 2.47 build-seconds a second against 1.84 to 1.91 at the default), with no code of ours, so this is not rebased.

AI use: Claude Code (Claude Opus 5.5) wrote this note, from a run by another Claude Code session (Claude Fable 5.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants