Shaders: isolate DXC compiler heaps for parallel AOT #683
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-24T03:30:10Z.
Part 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
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T03:33:29Z.
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.
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T03:42:55Z.
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.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T04:18:23Z.
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.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-24T10:39:47Z.
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.Imported from ivall/xcl. Originally posted by larelgit on 2026-11-24T10:53:27Z.
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.
Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-24T13:17:30Z.
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.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-24T14:53:34Z.
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.Imported from ivall/xcl. Originally posted by bmjask on 2026-11-24T15:10:05Z.
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.Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-24T15:17:41Z.
@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.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-24T18:32:46Z.
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.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T06:18:31Z.
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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T12:06:18Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-26T12:28:36Z.
Review: COMMENTED
Needs changes — keep the useful work. Checked head
760f742b42383a53b344d957217f4c4e4f93b2dd.The private-heap compiler path still returns early when allocator creation fails, and falls back from
DxcCreateInstance2only for selected errors. A failure of this optional path can therefore prevent the ordinary compiler entry point from being tried. The local repair retries the ordinary entry point for allocator, factory and null-object failures; injected factories exercise the decisions without loading DXC.Local validation: head plus an uncommitted repair and regression fixtures: 3 passed, 0 failed, 0 ignored, 0 skipped. These are CPU checks of the local repair, not a claim that the unmodified PR passed them. Separate negative-control checks produced 1 passes and 2 expected failures.
Build command:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated target>(only the private absolute target path is replaced here). Each selected test executable was then run separately as<test-exe> <exact-name> --exact --test-threads=1 --nocapture.Selected exact tests
gpu::recomp::dxc::fallback_tests::private_creation_failures_try_process_heapgpu::recomp::dxc::fallback_tests::unavailable_private_heap_tries_process_heapgpu::recomp::dxc::fallback_tests::missing_private_entrypoint_uses_process_heapLatest-main source comparison:
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7; full-head merge-tree result: conflicts. This is a source compatibility check, not a tested integration build. Local repair patch SHA-256:55d83bd0c87cfedeb27d5dae7b204674c4ed57736b681dacc2734cc6aaff4e62.Windows 11 Pro build 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug tests. RTX 3060 Ti / driver 32.0.16.1714 is present but was not exercised. No full-suite, GPU or title result is claimed; installed builds and game data were untouched.
AI use: Codex (GPT-6) reviewed the source, prepared the local repair/fixtures, ran the checks and drafted this report.
Optional temporary Discord for coordinating this contributor work, helping test and comparing results.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-26T19:43:45Z.
Since #2555,
mainruns XCL's--precompilepass before every launch. I merged760f742ontomain8b957be. From an empty cache, it cut the pixel-shader part of that pass (980 programs) to about a third ofmain's time: 128 and 143 s, against 396 and 379 s. The DXIL was byte for byte the same in all four passes.Setup: Fedora 44, Wine 11.21 Staging, Ryzen 9 9950X3D, no GPU used; release
x86_64-pc-windows-gnu, DXC 1.9.2609.5,XCL_DXC_THREADS=8.xcl shaders shaders.rpf --precompile --split 1 --only ps --limit 12000on a retail pack, from an empty DXIL cache each time: theprecompilefunctionprepare_for_launchcalls (the launch also compiles the other stages and builds the pipelines). The merge (da6e952, local) conflicted only in theuseline at the top ofdxc.rsand inREADME.md; I kept both sides of each.760f742ran first in each)main8b957be760f742DXC: compiler workers use private heapswas logged in both passes with the change.cargo test -p xcl --lib -- gpu::recomp::dxcon the merge, under Wine: 22 passed, 0 failed, the twoprivate_heap_testsamong them.main's (none for about 3 of round 1's 6.6 minutes and 1 of round 2's 6.3).nvidia-devalready has this change as3842807a;amd-devandmaindo not.amd-dev's worker processes (d92b36ee) build only the compute pipelines; its DXC compiles still run in one process.Read: Prime1997's point holds at
760f742: whenDxcMalloc::new()fails (dxc.rs:435) orDxcCreateInstance2returns anything but success orE_INVALIDARG(:448-450),compiler()returns beforeDxcCreateInstanceis tried. Both passes with the change took the private-heap path, so the fallback was not exercised here.Not tested: the launch itself (
xcl run), only the pass it calls; the rest of the test suite on the merge; other thread counts; native Windows; AMD; the rest of the pack (these are the pixel shaders among its first 12,000 records);--pipelines;scripts/precompile-shaders.ps1.AI use: Claude Code (Claude Opus 5.5) ran the passes and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-27T07:54:00Z.
With
760f742merged, #2872 (my change that cuts DXC's work on pixel shaders) halved XCL's pass over 980 pixel shaders of a retail pack under Wine on 8 DXC threads, from 127 and 120 s to 64 and 63 s. Onmainalone it gained nothing.xcl shaders shaders.rpf --precompile --split 1 --only ps --limit 12000, from an empty DXIL cache:main8b957be48a4421, local: head2dad32e's diff on8b957be)760f742(this, merged by hand)760f742+ #2872's changemain's second pass was clear of it, and round 2's 120 → 63 s had it beside both. Fedora 44, Wine 11.21 Staging, Ryzen 9 9950X3D, no GPU, releasex86_64-pc-windows-gnu, DXC 1.9.2609.5,XCL_DXC_THREADS=8.main's 146.7 s (1 run each). A reading: on eight threads under Wine, the lock on the heap DXC's threads share sets the time, and760f742removes it.dxc::compile_whole, 1 run each unless said), this pull request made no difference on 8 threads, 123.6 s againstmain's 124.1–125.1 s in 3 runs, and on 16 took 117.2 s against 137.3 and 139.8 s (2 runs). #2872's change alone on 8 threads: 72.1 s against 125.1 s.Not tested: the two together on Windows; the launch itself (
xcl run), only the pass it calls; the other shader stages and the rest of the pack.AI use: Claude Code (Claude Opus 5.5) ran the passes and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T14:50:14Z.
Current-main audit (2026-11-29): already implemented; please close this PR.
Current
maincontains commit3842807a2363f94f7dcf8d12c132ff898f0f617b,Shaders: isolate DXC compiler heaps for parallel AOT, explicitly cherry-picked from this PR. The dependency, README text,DxcCreateInstance2allocator path, tests, andscripts/precompile-shaders.ps1are present.There is no remaining change to merge from this head. Cache impact of the carried implementation is intended to be byte-identical DXIL/PSO identity.
Review assisted by Codex; exact model name was not exposed in this session.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:37:57Z.
Review (head
760f742b, diff read, not a merge-check; it conflicts with main, so not built or run):760f742bwas cherry-picked as3842807a("Shaders: isolate DXC compiler heaps for parallel AOT") and merged in60380a2c;git range-diffshows no code difference.68046733: the private-heap path fell back only onE_INVALIDARG(dxc.rs~442-449), so any otherDxcCreateInstance2orHeapCreatefailure made every later compile on that worker fail; andDropcalledHeapDestroy(~417-419), which could leave memory DXC keeps after a compiler is released pointing into a destroyed heap when a thread exits.Recommendation: close as merged via
3842807a(follow-up fix in68046733).AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:39:19Z.
Closing as superseded: this change is already on
main(3842807a).3842807a(private DXC heap, DxcMalloc, DxcCreateInstance2) and68046733(heap fallback) are on main; dxc.rs has DxcMalloc and DxcCreateInstance2 use; PR's only missing lines are the older unfallbacked variantTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed