Repository navigation
D3D12.X: pipelines an earlier run used are built ahead of their first use - #690
Conversation
… use A lazy pipeline is built at its first use: until then a graphics one draws nothing and a compute one is waited for on the title's thread. A retail title's first frames of its world use hundreds of pipelines for the first time at once. The pipelines a title uses are now kept by a hash of their shaders (used-pipelines.txt beside the DXIL cache), and a lazy pipeline of shaders an earlier run used is sent to workers of its own when it is made: two to four threads at the lowest priority, apart from the ones a bind sends to, so a pipeline that is bound is not held up by the ones made ahead. XCL_PSO_PRELOAD=0 turns it off. Pipelines no run used stay lazy, as before (the memory of ~51 000 built pipelines was the reason for making them lazy). Measured on an RTX 5090 with a build that skips a dispatch instead of waiting for its pipeline: ~2 170 dispatches skipped in the title's first world frames without this, 94 - 150 with it. Assisted-by: Claude Code (Claude Fable 5.2)
|
Tested On
Each dispatch matched all 1,536 readback words. The focused test passed 1/1 in each process with the D3D12 debug layer enabled and no errors or runtime skips. Runtime code was stock. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug. Not tested Graphics pipeline preload, contention with a large history, and retail loading. AI use Codex with GPT-6.2 Sol adapted the scratch fixture, ran the tests, and drafted the report. |
|
Test run of Tested
Review: The set written this run starts as the file's set, so only keys that are new append a line: Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Independent Windows 11 / RX 7900 XT result on retail 1.0.2.1, with DXC 1.9.2602.17. I tested the preload change at 7296a8b on a local combined build with bounded graphics and compute waits, first-use tracking on those paths, and a sparse-buffer release fix. The prior-use file started with 180 shader sets. I had seeded 177 from earlier traces before the preceding run. The log recorded 128 pipelines built ahead of first use by 6.643 s. The account picker held 60 presents per two seconds and accepted A at 37.004 s. The game displayed the loading artwork and began streaming. It later hit the known world-loading watchdog at 154.691 s (0xc0000005 at title+0x23cf683), with no device removal. The submission thread logged 14 two-second Wait64BitValueX timeouts. Peak process commit was 40,842 MB. This verifies preloading on AMD. The build and warmed cache do not isolate its effect on frame rate or time to the watchdog. The combined workspace passed 722 tests with 41 ignored. Upstream change tested: 7296a8b. Workspace command: |
…uns, sparse and write-watch fixes) Conflict in pso_async.rs: xcl-dev#690's key / used fields and xcl-dev#533's timed_out kept side by side; the bounded waits (resolve_within, resolve_compute_within) record a pipeline's use too, so xcl-dev#690 builds those ahead next run; the older tests pass the new key argument (0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
upstream xcl-dev#690 added a key argument to submit_lazy (pipelines an earlier run used are built ahead); the wait-budget and compute-pool tests carried on perso pass 0, no key.
|
Follow-up to my earlier AMD test. I repeated a Series S-profile run on the RX 7900 XT with the exact same release executable, saved profile and A press at 37 s. The second launch used the complete application caches written by the first. Both builds had #690 enabled, so this measures repeat-launch behavior on the integration stack. The 512th pipeline finished preloading at 9.883 s on the repeat, compared with 16.952 s on the first run. The repeat accepted driver blobs on 282 successful compute pipeline creations. It still encountered 21 successful cold creations and two cold creations that returned The two failed compute compilations were serialized. ScreenProbes ActivateProbes (22,909,544 bytes of DXIL) took 91.119 s and ActivateRays (13,015,316 bytes) took 54.018 s. Both were started by a preload worker. Peak process commit was 68,701 MB. The repeat recorded 2,215 presents and zero device removals before a title access violation in world loading at 174.409 s. The trace establishes driver memory pressure; it does not establish the cause of the title exception. The local integration workspace reported 737 passed, 0 failed and 41 ignored. One counted pass printed a skip for the missing xgameruntime.dll debug-layer fixture. The same binary was used for both game runs. Codex (GPT-6) ran the tests and prepared this report. |
A lazy compute pipeline was built at its first bind, on the binding thread (waited for: a skipped dispatch leaves output the title reads). With the retail game's stall watchdog parked, an RTX 5070 Ti run went past its first cinematic's start and then stood still for over three minutes: twelve new compute pipelines bound one after another, each built on that thread in turn by the NVIDIA driver in 6 - 38 s. Compute pipelines now go to the workers that build ahead (xcl-dev#690's preload, lowest priority) as soon as the title makes them, so they are built in parallel before most first binds; a bind that finds one not started still builds it itself. Those workers are compile_threads / 2 (2 - 6) while this is on. XCL_EAGER_COMPUTE=0: built at first use, as before. Off in tests, which decide which thread builds what.
…, xcl-dev#490, xcl-dev#347) The fork keeps its own pso_async (short waits, all compute pipelines built ahead); xcl-dev#690 upstream is its used-pipelines part. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The page opened with the title and a paragraph; what a reader looks for first (which games, how to build, where to ask) was a scroll away, and the environment switches a user needs were spread over the text or only in HANDOFF.md. - a centred header: tagline, badges (Discord, CI, licence, platform), and links to the page's sections - how XCL works as three rows (native code, console libraries, shaders) - "Switches for a run": the eight variables a user is most likely to set, each checked against the code on main - the Pipelines row names what main has since xcl-dev#634 / xcl-dev#636 / xcl-dev#690 No statement about what works was changed. The test count (xcl-dev#485) and a Contributing section (xcl-dev#453) are left to their open pull requests. Assisted-by: Claude Code (Claude Fable 5.2)
|
Title: Pipeline preload (#690): committed memory climbs ~1.4 GB/s on AMD RDNA2 until Windows runs out (retail title from #505) Hardware: AMD Radeon RX 6600 XT (8 GB, RDNA2), Ryzen 5 5500, 32 GB RAM, page file on a second drive (commit limit 130 GB), Windows 11, DXC 1.8.2502.11. Build: a local test branch: main with #690 and #713, plus #533 and two local changes that bound pipeline waits (no changes to What happens Once
The title sat at its account picker the whole time. XCL's log is nearly silent after ~100 s, with no pipeline builds or uploads logged while memory climbs. The desktop stopped drawing (blank icon boxes, error dialogs) until a reboot. Two other runs with the same list ended at ~130 s with With
When it started: an earlier run with a short list ( Not checked yet:
|
upstream xcl-dev#690 added a key argument to submit_lazy (pipelines an earlier run used are built ahead); the wait-budget and compute-pool tests carried on perso pass 0, no key. (cherry picked from commit a3536a8)
A lazy compute pipeline was built at its first bind, on the binding thread (waited for: a skipped dispatch leaves output the title reads). With the retail game's stall watchdog parked, an RTX 5070 Ti run went past its first cinematic's start and then stood still for over three minutes: twelve new compute pipelines bound one after another, each built on that thread in turn by the NVIDIA driver in 6 - 38 s. Compute pipelines now go to the workers that build ahead (xcl-dev#690's preload, lowest priority) as soon as the title makes them, so they are built in parallel before most first binds; a bind that finds one not started still builds it itself. Those workers are compile_threads / 2 (2 - 6) while this is on. XCL_EAGER_COMPUTE=0: built at first use, as before. Off in tests, which decide which thread builds what. (cherry picked from commit f06d4f6)
A lazy compute pipeline was built at its first bind, on the title's thread: the bind has to wait for it (a skipped dispatch corrupts what it computes), and the driver takes seconds for a big one. Preloading (xcl-dev#690) covered only the shaders an earlier run used, so every compute pipeline new to a run was still compiled in the middle of a frame. Every compute pipeline now goes to the preload workers when the title makes it, after the ones of an earlier run (a second, lower line of the same queue). Graphics pipelines stay lazy: a retail title makes ~58 000 pipelines and only 2 734 of them have a compute shader, so building these costs little. A bind that comes first still builds or waits as before, and each build is kept on disk for later runs (driver_cache). Measured on the retail title of xcl-dev#505 (RTX 5080, driver 32.0.16.2124, XCL_NETWORK=0, 240 s), counting resolve_wait calls that found their pipeline not built: without this, 16 compute binds built theirs on a title thread, 3 - 23 s each and 92.7 s in all, on five threads within 10 s, and the title's hang watchdog ended the run at 125 s. With it, one bind waited 2 ms; the run went on until XboxBvhBuilder refused an acceleration structure above 2^40 (xcl-dev#585) at 137 s. Part of xcl-dev#505. XCL_PRELOAD_COMPUTE=0 turns off this build-ahead alone: the driver keeps each compute pipeline built (an AMD GPU under Wine measured 7 - 10 GB more host memory), and XCL_PSO_PRELOAD=0 would also turn off xcl-dev#690's preload of the pipelines an earlier run used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XCL_PSO_PRELOAD=graphics keeps remembered graphics pipelines eligible for preloading while compute pipelines retain their ordinary first-bind build and wait. Unset, 1, 0 and unrecognized values retain their existing behavior. The existing queues, workers and exact-once job ownership are unchanged. Extend xcl-dev#690 with an opt-in admission policy, not a default or dispatch change. The CPU scheduling regression runs five policy values in fresh processes and checks actual remembered graphics/compute submission and real-value selection. Assisted-by: OpenAI Codex (GPT-6; exact model variant unavailable)
A lazy pipeline (#162) is built at its first use: until then a graphics one draws nothing and a compute one is waited for on the title's thread. A retail title's first frames of its world use hundreds of pipelines for the first time at once. This keeps which pipelines a title used and builds those ahead of their first use in the next run, while the title loads.
I searched the open PRs first: #628 orders the worker pool's queue, #533 / #267 bound the waits, #214 / #567 the compile concurrency; none builds a pipeline before its first use. This works with any of them.
What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs:mod used– the shader-set keys of pipelines a run used, appended toused-pipelines.txtbeside the DXIL cache and read at the start of the next run;preload– two to four workers at the lowest thread priority, apart from the ones a bind sends to, that build a lazy pipeline as soon as it is made when an earlier run used one of its shaders (whoever takes the job first builds it, so a bind is never held up by them).submit_lazytakes the key;resolve/resolve_waitnote the first use.XCL_PSO_PRELOAD=0turns it off. Pipelines no run used stay lazy as before.crates/xcl/src/hle/d3d12x/real.rs:shaders_key(a hash of the pipeline's shader blobs in their order), passed fromgo_background.crates/xcl/src/hle/d3d12x/bind.rs: the threesubmit_lazycalls of an existing test get the new argument.the_keys_of_a_file_are_read_and_other_lines_passed_over,a_pipeline_an_earlier_run_used_is_built_ahead_of_its_first_use(built with no bind when an earlier run used it, still pending when none did, and a first use is kept),a_key_follows_the_shaders_and_their_order_and_is_never_zero.Tested
cargo build --workspace, thencargo test --workspace -- --test-threads=4on 2e36ce0: 695 passed, 0 failed, 41 ignored. The head commit 7296a8b differs from it in a doc comment and the commit message only; on it I rerancargo test --release -p xcl --lib -- used_tests shaders_key_tests: 3 passed.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.used-pipelines.txtof 1197 shader sets from earlier runs: 512 pipelines were built ahead within 5.2 s of the start (the log line is printed at powers of two), in the smoke run below and in a 200 s run into the title's world.maina compute pipeline is waited for, and the title's world still ends at its watchdog with this PR as without it (102 s without, 106 s with: no difference I can claim). On a build of mine that skips a dispatch instead of waiting (bounded waits, as D3D12.X: bound compute pipeline waits so slow compiles do not trip wa… #533 does), the title's first world frames skipped ~2 170 dispatches without this and 94 – 150 with it, in runs on this machine.Regression run
Both runs had the same scripted input (
XCL_PRESS_AT, A at 20 s and so on), so they leave the title's first menu and go on into its loading, where its pipelines are made.main:
```
xcl-smoke v1
commit: 91f9a5e
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1311 (PresentX 1311)
presents per 2 s (last 3): 2 2 0
device removals: 0
crashes: 0
peak commit: 22607 MB
Not tested
used-pipelines.txt: nothing is built ahead then (covered by the unit test's pipeline that no run used, not by a title run with the file removed).main.AI use