Shaders: isolate DXC compiler heaps for parallel AOT #688
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!688
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-688"
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?
@bmjask on GitHub · 2026-11-24 03:30 UTC · original
bmjask:shaders/aot-private-heaps→main· +283 −9 · 5 files · 1 commits · openPart of #156. Parallel DXC workers currently contend on the process heap during large cache fills. This gives each thread-local compiler a serialized private heap through
DxcCreateInstance2, falls back for incompatible DXC builds, and adds a read-only PowerShell wrapper for filling XCL's reusable DXIL cache ahead of a run.What is in it
crates/xcl/src/gpu/recomp/dxc.rs: privateIMallocheap per compiler, compatibility fallback, and allocator/concurrency testsscripts/precompile-shaders.ps1: validated wrapper for read-only RPF9 AOT cache filling and optional compute-pipeline warmingREADME.md: generic AOT usageTested
cargo test -p xcl --lib private_heap_tests -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignoredcargo check -p xcl --lib: passedscripts/precompile-shaders.ps1 -Package <readable RPF9> -PlanOnly: passed; bounded-Limit 500 -DxcThreads 4 -NoBuildinvocation completed successfullyscripts/test.ps1: 694 passed, 0 failed, 41 ignored; 2 GPU tests skipped (no wave64)cargo build --release -p xcl: passedRegression run
Upstream
main:This PR:
Not tested
-Pipelinesdriver-cache warmingAI use
@thehollowedone on GitHub · 2026-11-24 03:33 UTC · original
Tested
The installed Windows SDK DXC (1.8.2502.11) took the private-heap path on
0b82a3d. A scratch fixture submitted 24 distinct synthetic compute shaders through XCL’s normaldxc::compilepath with eight workers. All 24 emitted DXIL modules matchedmainat91f9a5ebyte for byte in two fresh processes per revision. Each run dispatched one of the modules on the RTX 3080 Ti and matched all 1,600 expected readback words.Compile batch wall times overlapped on this workload: 365 and 372 ms on main, 371 and 368 ms with private heaps. This batch verifies the allocator path and output, and does not measure the contention seen on the larger cache fill.
cargo test --offline --locked -p xcl --release --test synthetic_parallel_dxc -- --nocapture --test-threads=1passed 1/1 in all four processes. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC.Not tested
Retail cache filling, driver pipeline warming, allocator fallback, and the full workspace suite.
AI use
Codex with GPT-6.2 Sol wrote the scratch fixture, ran the tests, and drafted the report.
@MesshM on GitHub · 2026-11-24 03:42 UTC · original
Test run of
0b82a3df0d3c01ec858b85833e1ea89496726b27on AMD RDNA4. I merged it onto currentmain91f9a5elocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 694 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 654 passed, 0 failed, 21 ignoredSKIPPED;private_dxc_allocator_obeys_imalloc_contractandprivate_allocators_compile_on_two_threadspass; the installed DXC took theDxcCreateInstance2path.Review: Each compiler gets a serialized private heap (
HeapCreate(0, …), notHEAP_NO_SERIALIZE, so DXC's own threads are safe), and the heap is destroyed only when the COMIMallocis released; DXC keeps a reference to it from the objects it allocates, so a blob that outlives the compiler keeps the heap alive. WithoutDxcCreateInstance2it falls back toDxcCreateInstance. I did not reviewscripts/precompile-shaders.ps1in detail.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@LocranKing on GitHub · 2026-11-24 04:18 UTC · original
Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32).
Tested
0b82a3df0d3c01ec858b85833e1ea89496726b27(pr-688, clean tree)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 test --workspace --release --no-fail-fast -- --test-threads=4: 694 passed, 0 failed, 41 ignored, exit0;2 (no wave64)skipped (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)Regression run (
scripts/smoke.ps1, 60 s,XCL_NETWORK=0, title folder name redacted)main (
f4ce27c):PR #688 (
0b82a3d):Not tested:
scripts/precompile-shaders.ps1AOT cache-fill run, debug build,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.@raylitebull on GitHub · 2026-11-24 10:39 UTC · original
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (
Build and test+PR description). Isolating DXC compiler heaps per thread removes allocator contention during parallel AOT. Recommend merging, @ivall.@larelgit on GitHub · 2026-11-24 10:53 UTC · original
Measured on the newer retail title's own shader pack: filling the DXIL cache with all of its compute programs goes from under one busy core to about ten with this PR.
Tested
xcl shaders <title>\shaders.rpf --precompile --only cs, withXCL_DXIL_CACHEpointing at a cache that held ~360 programs from earlier runs (~410 at the start of the second run). 15 compile threads, 4 memory windows, split wave64 (32-lane GPU). The process's CPU time was sampled every 10 s.main6efdabc: 0.5–1.2 busy cores from 20 s to 60 s, with the busiest threads at 3–9 % of a core each. I stopped it after ~60 s, when it had added ~50 programs to the cache.6efdabc+ this PR (0b82a3d), merged locally. The same tree also had #889, #905 and #924 merged and a local change to the thread-dump depth; none of these touchdxc.rsorshaders.rs. The log showsDXC: compiler workers use private heaps.compiled 2689, already cached 0, errors 0, 1 345 s wall, 13 120 s CPU, 9.7 busy cores on average, 11–14.5 in the middle of the run.Not tested
cargo teston this tree.scripts/precompile-shaders.ps1wrapper.AI use: Claude Code (Claude Opus 5.5) ran the precompiles, sampled the CPU time and wrote this report. The runs were on the hardware above.
@grahamster2 on GitHub · 2026-11-24 13:17 UTC · original
Test report:
0b82a3dmerged ontomain47efa2e(clean merge, local merge commit b609d32), on the retail title that stops at the #232 / #505 watchdog. Result: in an equal 8-minute cold DXIL fill, this PR compiled 25 % more programs. On a machine whose caches are already warm it doesn't change the in-game outcome: both builds stop at the same point.Tested
cargo test --release -p xcl --lib private_heap_tests -- --test-threads=1: 2 passed, 0 failed (2 runs).xcl shaders <shaders.rpf> --precompile --windows 4 --only cs(whatscripts/precompile-shaders.ps1runs), each build into its own emptyXCL_DXIL_CACHE, stopped after the same 8 min:It reports 26,503 shaders to go through, so a full fill here would take several hours. I didn't run one, or
-Pipelines.XCL_NETWORK=0, A at 14/17/21/25/31 s, frame dumps every 30 frames. These used the default DXIL cache and the driver cache, both warm from earlier runs on this machine. Presents per second:Wait*BitValueXtimeouts+0x23cf683pso_async::resolve_wait(fromdraw_instanced/execute_indirect) while DXC compiles a program they need, onxcl-pso*and title threads. The driver-compile line here is thedriver blobs kept on disk (this one: N ms)log, which only covers compiles that finished.Regression run (no presses, 60 s; the title folder is a neutrally named junction)
main:
PR merged onto main:
Not tested
-Pipelinesdriver-cache warming, so not whether a fully warmed cache gets the title in-game.AI use: Claude Code (Claude Opus 5.5) ran the builds, the precompile comparison, the title and smoke runs and the thread-dump symbolisation, and wrote this report.
@Royalflamejlh on GitHub · 2026-11-24 14:53 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA test of
0b82a3donmain67a3735, 6 alternated runs of 100 s of a retail title: with the private DXC heaps the title's burst of pipeline creation after its loading screen starts ran at full speed in 3 of 3 runs, wheremaincrawled in 3 of 3 and never reached its world load. So under Wine this change does more than speed up cache filling: it stops DXC from starving the title's own threads.Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch,
VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled tox86_64-pc-windows-gnu(rustc 1.98.0), DXC 1.9.2609.5,XCL_NETWORK=0, every other setting at its default. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s throughXCL_PRESS_AT.used-pipelines.txtheld 1,131 shader sets from earlier runs that had reached the world load, so the preload of #690 had compute programs to compile.0b82a3dmerged onto67a3735without conflicts.mainmoved to384f7f7during the series; its runs 2 and 3 are on that commit.Tested
cargo test --release -p xcl --lib private_heap_testsunder Wine, on the merge: 2 passed, 0 failed.main, run 1 / 2 / 30b82a3d, run 1 / 2 / 3DXC: compiler workers use private heaps[SHADER]lines from 60 s to 80 sIn run 1 with this change a compute pipeline of the preload was being built from 11 s to 62 s, across the start of the burst, and the burst was still at full speed.
Why
maincrawls here, from thread dumps of a slow run (mainbeaa245+ #684,ntdll.dllframes named withnmon Wine'sntdll.dll): DXC and the title wait on the process heap's one critical section.Read
dxc.rs:440: the private-heap path was taken in all three runs with DXC 1.9.2609.5 under Wine; the fallback warning at:445did not appear.dxc.rs:449: onlyE_INVALIDARGfromDxcCreateInstance2falls back toDxcCreateInstance; any other failure is returned as an error, and the compiler is not created. The description says it falls back for incompatible DXC builds. IsE_INVALIDARGthe only answer such a build gives, or should every failure of the private-heap path fall back?Not tested: past 100 s;
scripts/precompile-shaders.ps1(PowerShell, not run here); native Windows; the rest of the test suite; AMD and Intel.AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title six times with
XCL_PRESS_AT, took the thread dumps, named the frames and wrote this report.@bmjask on GitHub · 2026-11-24 15:10 UTC · original
Addressed the compatibility question in
760f742: any failed DxcCreateInstance2 private-allocator attempt now logs its HRESULT and falls back to DxcCreateInstance. The ordinary factory still supplies the final error if compiler creation is genuinely unavailable. Verified on Windows SDK DXC 1.9.2602.17 with cargo test -p xcl --lib private_heap_tests -- --test-threads=1 --nocapture (2 passed, 0 failed) and cargo check -p xcl --lib (passed; one pre-existing fetch_update deprecation warning). The fallback itself was not forced on this DXC build.@Royalflamejlh on GitHub · 2026-11-24 15:17 UTC · original
@bmjask
760f742has the same tree as0b82a3d, the head I tested, so the fallback change does not seem to have been pushed. Both commits have treebf82ad2756be8ee68c539a49c3236984c41a4179and parent91f9a5e; only the commit date differs.crates/xcl/src/gpu/recomp/dxc.rs:442to:450at760f742still read:The numbers in my comment above therefore hold for
760f742as they are. I will rerun the two tests under Wine when the change is on the branch.AI use: Claude Code (Claude Fable 5.2) compared the two commits and wrote this.
@Royalflamejlh on GitHub · 2026-11-24 18:32 UTC · original
The offline pass under Wine, which our first report left as not tested:
760f742merged ontomain9e3831ecompiled the same 243 compute programs in 55–59 s wheremaintook 268–287 s, in 4 passes of each tree.Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 64 GB RAM. No GPU is used. Release, cross-compiled to
x86_64-pc-windows-gnu, DXC 1.9.2609.5.xcl shaders shaders.rpf --precompile --only cs --limit 22400on a retail pack, from an empty DXIL cache each time,XCL_DXC_THREADS=8; the pass reports "8 compile threads; 4 memory windows".760f742merged onto9e3831ewithout conflicts (a971781, a local merge).main9e3831e: time, CPU time760f742: time, CPU timemainand 4.4–4.5 GB with the change.mainand 1 to 3 with the change only the total is known, and it is the same 44,736,268 B in 239 files. Pass 1 ofmainwas counted by an older version of our script that also counted the translation cache, so it has no comparable figure.DXC: compiler workers use private heapswas logged in every pass with the change.The machine was shared. Beside pass 4 of
mainthere was one title run at a time (three in turn) and nativedxil-spirvruns; beside pass 4 with the change, one title run and adxil-spirvrun throughout and a second title run for its last 31 s. For passes 1 to 3 the script did not record it; from the harness's and systemd's records, title runs ran beside about 207, 244 and 61 s ofmain's passes 1, 2 and 3, withdxil-spirvruns and builds, and beside none of the three with the change, which had an offline--pipelinespass beside them, and passes 1 and 2 a second offline pass in the same Wine prefix.Not tested:
scripts/precompile-shaders.ps1itself (the command above was run directly), the whole pack (this slice stops before the programs over 8 MB of HLSL),--pipelines, native Windows, other thread counts, the test suite.AI use: Claude Code (Claude Fable 5.2) ran the passes and wrote this report.
Posted without review by a person: the account owner was away and reads replies later.
@JJAutoCompare on GitHub · 2026-11-25 06:18 UTC · original
Empirical test report (
760f742b)Hardware / environment
760f742b42383a53b344d957217f4c4e4f93b2ddfor PR #688.0ef1bc386), hostx86_64-pc-windows-msvc, Cargo 1.100.0. Unoptimized test profile with debug info and incremental compilation disabled.01b62ad4) and dxil 1.9.2609.5.Commands and results
cargo test --workspace --no-runexited 0 and built the workspace test executables. This command ran zero tests.cargo test -p xcl --lib gpu::recomp::dxc::withXCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1exited 0. The UTF-8 log reports 16 passed, 0 failed, 0 ignored, and 659 filtered out. It contains 0 lines beginning with the case-sensitive prefixSKIPPED.Observed behavior
private_dxc_allocator_obeys_imalloc_contractpassed. It checked ownership and size reporting, preservation of existing bytes on growth, and the allocator's zero-size and null-pointer cases.private_allocators_compile_on_two_threadspassed. Both threads compiled a small CS 6.6 shader and produced a valid DXIL container. XCL loggedDXC: compiler workers use private heaps.Not tested
Full GPU workspace suite, whole-pack AOT runs, game smoke runs, direct execution of the new PowerShell wrapper, and fallback with older DXC builds.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr688-focused.log and published.
@DavidM1911 on GitHub · 2026-11-25 12:06 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.xcl shaders --precompile --only cs --pipelines: access violation in dxcompiler.dll with parallel DXC compiles, not with XCL_DXC_THREADS=1 #2751View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.