D3D12.X: compile compute pipelines eagerly on background workers #1432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1442"
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 ivall/xcl. Originally posted by WTactic on 2026-11-24T16:01:27Z.
Lazy PSO compilation previously meant compute pipelines were built synchronously on the calling thread during their first bind, leaving worker threads idle while large compute shaders blocked the title.
Submit compute pipelines eagerly so worker threads can build them in parallel across all CPU cores. Also track active driver PSO compiles and surface them in the window title, and make the DXC memory wait timeout and reserve configurable (
XCL_MEMORY_WAIT_SECS,XCL_MEMORY_RESERVE_GB, keeping the 60 s default per review feedback).What is in it
crates/xcl/src/hle/d3d12x/real.rs: eagerly submit compute pipelines to workers (!computeremaining lazy).crates/xcl/src/hle/d3d12x/pso_async.rs: add atomic counter tracking active driver PSO compilations across worker threads.crates/xcl/src/hle/d3d12x/present.rs: display active/built PSO counts in window title.crates/xcl/src/gpu/recomp/dxc.rs: make memory reserve and wait timeout configurable via environment variables (defaulting to 60 s).Tested
rustc 1.97.1, release/debugcargo test -p xcl --lib pso: 26 passed, 0 failed, 1 ignoredRegression run
main(1d027e5):PR (
293584e):Not tested
AI use
Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T16:42:25Z.
Hardware test report — commit
e9c84b0Verified clean merge with
main(b7aa9f3) one9c84b0ea1195e39dbea352aa6f4f723d77c4ec7: workspace tests pass (0failures,0skips),0crashes /0device removals on AMD RDNA4, +4.0 to +5.2 GB higher peak commit (14855 MBonmain→20089 MBcold /18881 MBsecond run) and-119frames on the initial 60 s run while background compute PSO workers run concurrently.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace --no-fail-fast -- --test-threads=4:751 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)report.jsond3d12):frames shown: 1559 (PresentX 1560)vs1678onmain,peak commit: 20089 MB(+5234 MBvsmain's14855 MB),translated_pipelines: 446,failed_pipelines: 0,background_pipelines: [446, 0, 57377],dxil_cache: { hits: 461, misses: 232, compilations: 232 }exit: 0x0,frames shown: 1674 (PresentX 1674),presents per 2 s (last 3): 60 60 60,device removals: 0,crashes: 0,peak commit: 18881 MB(+4026 MBvsmain),translated_pipelines: 475,failed_pipelines: 0,background_pipelines: [475, 0, 57348],dxil_cache: { hits: 693, misses: 29, compilations: 29 }pso_async::active()counter, thedxc::wait_for_memorytimeout change (60 s→5 sdefault) /XCL_MEMORY_RESERVE_GB&XCL_MEMORY_WAIT_SECSoverrides, or eager compute submission; the two newXCL_MEMORY_*environment variables are also not listed inREADME.mdRegression run
main(b7aa9f3):PR (
e9c84b0):Not tested
wait_for_memorytimeout;XCL_MEMORY_RESERVE_GB/XCL_MEMORY_WAIT_SECSoverrides; gameplay past the menusAI use
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T16:55:51Z.
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, 6C/12T CPU, 32 GB RAM) test report for
e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7.In the 60 s smoke run,
xcl.logconfirmed multiple background worker threads actively compiling compute PSOs concurrently without crashes or frame drops; peak commit rose by +1511 MB relative tomainb7aa9f3(16241 MBvs14730 MB, 110.3%, within the 125% ceiling).Tested
e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7(clean tree, merge-base930e8b4)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored, exit0SKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7):Not tested: debug build, custom
XCL_MEMORY_WAIT_SECS/XCL_MEMORY_RESERVE_GBoverrides,XCL_SAMPLE_*tests on this branch, AMD / wave64 hardware.AI use: Antigravity (
Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T17:05:42Z.
Verified head
e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7on Windows 11 / NVIDIA RTX 5080:cargo build --workspace: OK (0 new compiler warnings)cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignoredOne small review note: lowering
wait_for_memorydefault timeout from 60 s to 5 s (unwrap_or(5)) could let multiple background DXC workers pile into commit memory on tighter 16 GB systems when compute pipelines are submitted eagerly — keeping the default at 60 s while still honoringXCL_MEMORY_WAIT_SECSmight be safer.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:36Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by Raghav314 on 2026-11-24T22:26:36Z.
Test report for the new head
293584e, together with #1273 (be8d052), onmain689f2db: no regression, and no change at the world-load stop, which on this machine is not a pipeline wait.Setup: RTX 4090 24 GB (driver 617.14, 32-lane waves), 16 threads, 32 GB RAM, Windows 11, release. Local merge
c43951b=main689f2db+ this PR + #1273, no conflicts. Retail title, 180 s each,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PRESS_A_AT=20, network off, warm DXIL cache from earlier runs.main689f2dbWhere both stop: at 70–77 s the title's queues wait on four
Wait64BitValueXaddresses (0x704180110,…120,…138,…158), each loggedwait-before-signal, prod=qNone; a GPU wait timeout with the title's fences pending follows, and submits drop to ~0. After that only pipeline builds continue. So on this card the stop is the #1452 wait (here as a stall, not a device removal), and a faster or earlier pipeline doesn't move it; this PR can't be judged on the world load until that is fixed.main689f2db:main+ this PR + #1273 (c43951b, a local merge, so not this PR's head commit):Not tested: this PR without #1273, the test suite on this merge, a cold DXIL cache, whether the longer driver builds after the stop (32 s vs 13 s) come from more builds running at once, AMD.
AI use: Claude Code (Claude Opus 5.5) ran both builds and runs, read the logs and wrote this report for @Raghav314.
Imported from ivall/xcl. Originally posted by Rednaxeh on 2026-11-25T10:38:38Z.
RX 7800 XT (RDNA3), 32 GB RAM: no gain from eager compute builds on this machine. The title creates and binds its big compute programs one at a time, and the background workers cannot build them anyway: the 3 GB commit headroom of #1774 is never free here during world loading, so every worker parks in
big_compile_turnand the title's own thread ends up compiling at each bind, as onmain.Head
293584emerged locally ontomain568e7db(clean,6993fb2), release. Ryzen 7 7800X3D, 32 GB RAM (commit limit 43.6 GB with the system-managed page file), driver 32.0.32029.2010, Windows 11 26300. The newer retail title of #505, offline.Smoke, defaults (HLSL path), A at ~13 s
300 s runs,
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HUGE_PSO_CONCURRENCY=3 XCL_PSO_TRACE=1 XCL_ACTIVITY=1, thread dump at 200 smain, same switches: 1532); presents stop at 92 s in both. The chain of 20 compute programs of 270–330 KB that the AMD driver builds in 12–13 s each still runs one after the other on one title thread (huge, ungated here): the title creates each one right before it binds it, so submitting it to the workers at creation changes nothing. At 200 s, 18 workers were parked inbig_compile_turn(3 holding a slot and sleeping in the commit-headroom loop, 15 waiting for a slot) and one title thread was inamdxc64.dll.95cc13288a27a96e(ActivateRays, 3.35 MB of plain direct DXIL) enters the driver on a title thread at 78.8 s and has not returned at 300 s, the process at 54.5 GB of commit. Onmainthe same compile starts at 113 s; with this PR's eager build it starts earlier.XCL_PSO_WAIT_MS=2000on top: after 120 s not one driver compile runs for the remaining 180 s. The 3 slot holders sit inbig_compile_turn'scommit_freeloop (28.8 GB committed by the process, under 3 GB of commit free on this machine), nothing iswantedany more since the binds give up after 2 s, 2594 dispatches and 256 draws skipped, black window; commit flat at 28.8 GB.So the premise holds (the workers are idle while the title compiles), but on a 32 GB machine the gate keeps them idle by design, and only a bind that waits gets a compile started.
mainlogs nothing when the headroom holds a build back; that would be worth a line.Not tested
AI use: Claude Code (Claude Fable 5.1) read the logs and wrote this; the runs were mine.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:27:29Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:46:06Z.
Triage (#1607) – head
293584eNo open or merged PR makes the same change.
real.rs
go_background:lazy() && !computebuilds every compute pipeline eagerly.mainmade pipelines lazy because a retail game creates ~51,000 of them in 30 s and the eager builds ran out of commit (pso_async::lazydoc). The PR's own smoke run shows 1335 vs 1529 frames and 18,612 vs 15,898 MB peak commit, so this needs a justification or a switch.mainhas also moved this code tosubmit_lazy_keyed_with/submit_recipe_keyed_with, so the hunk no longer applies.The PR bundles three unrelated changes: eager compute, PSO counts in the window title (
pso_async::ACTIVE), and theXCL_MEMORY_RESERVE_GB/XCL_MEMORY_WAIT_SECSenv vars in dxc.rs. They should be separate PRs.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.