Shaders: --precompile --processes N builds in N processes #1502
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!1502
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1502"
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?
@tycosnh on GitHub · 2026-11-24 17:01 UTC · original
tycosnh:shaders-precompile-processes→main· +142 −4 · 3 files · 1 commits · draftRequested by Edison · project thread
xcl shaders --precompile --pipelinesbuilds compute pipelines in one process, and NVIDIA's driver builds about one pipeline at a time per process however many threads ask: on an RTX 4090 with 12 pipeline threads, 2 threads were busy and the CPU sat at 28 %.--processes Nruns the precompile in N processes ofxcl shaders, each taking every N-th record (--shard k/N) and sharing the DXIL and driver-blob caches. On the same 343 compute programs from cold caches, 4 processes took 765 s against 2 060 s for one. Part of #1269.What is in it
crates/xcl/src/shaders.rs:--shard k/n(a process takes records k, k + n, …; the others count as done) and--processes N(starts N children with--shard k/N, gives each its share of the DXC threads and 2 pipeline threads unlessXCL_DXC_THREADS/XCL_PIPELINE_THREADSare set, waits, returns the first failing child's exit code). Unit testshards_split_the_records_and_drop_processes.crates/xcl/tests/gpu_compute_e2e.rs:offline_compute_pipelines_split_over_processes: two programs,--processes 2, each child builds one pipeline and the shared cache gets two driver blobs.README.md: the option on the--precompileline.Tested
cargo test --release --workspace -- --test-threads=4atc65e2c8: 722 passed, 1 failed, 21 ignored. The failure islauncher::tests::console_detection(console_importsof the test exe givesNone); it fails the same way onmainb7aa9f3here. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).cargo test --release -p xcl --test gpu_compute_e2e offline_compute: 2 passed (the new test and #744's).shaders.rpf(26 503 records),--precompile --pipelines --only cs --limit 22500, each run into its own emptyXCL_DXIL_CACHE(and--windows 3/--windows 5so the driver's own cache could not carry over between the two): one process 343 programs in 2 060 s;--processes 4the same 343 (86 / 85 / 86 / 86) in 765 s. Driver blobs after 5 / 10 / 20 min: one process 149 / 219 / 231, four 251 / 326 / 336.Regression run
main:
PR:
The title run does not reach the changed code (it is the
xcl shadersCLI); it is the regression check the rules ask for.Not tested
--processes: a few programs make the driver's build run for a very long time and grow past tens of GB (one passed 54 GB here without finishing); with several processes at once that needs RAM to spare. Not handled in this PR.AI use
🤖 Generated with Claude Code
@vitor127wt on GitHub · 2026-11-24 17:27 UTC · original
A9 (nv-linux) — Offline PSO parallelism on the RTX 5070 Ti
I tested clean head
c65e2c8b459dd4ac45ff427b3e89abbb5ef707dfunder Wine with eight isolated Series 1.0.2.1 compute records (127,416–251,140 B of DXIL apiece). All modes used the same precompiled DXIL, four memory windows and split wave64. The benchmark ran twice, with the cold-mode order reversed in the second round.All runs made eight pipelines, zero refused. The four-process runs showed four shards and two pipelines made per shard. The cold runs reported zero XCL driver cache hits. The restore runs reported eight hits and retrieved all eight SPIR-V modules from their blobs. With four threads, Vulkan feedback still recorded three recompilations in the first restore and two in the second. I crossed the caches in both directions (serial build → four-thread restore and four-thread build → serial restore). All four crossed runs recorded six Vulkan hits and two recompilations, with eight XCL hits.
I ran
xcl shaders <eight records> --precompile --only cs --windows 4 --split 1 --pipelines, adding--processes 4for the last row. I setXCL_PIPELINE_THREADSto 1, 4, and 1 respectively, and keptXCL_DXC_THREADS=2. Each cold run started with an empty XCLdriversubdirectory and a copy of the same DXIL cache. Each restore kept that run’s XCL blobs.XCL_PSO_DISK_CACHE=1,VKD3D_SHADER_CACHE_PATH=0,__GL_SHADER_DISK_CACHE=0,VKD3D_CONFIG=pipeline_library_log; fresh Wine process per run. The DXIL hashes matched across all runs, and each cold/restore pair had eight unchanged blob hashes. Time is whole command wall time. Memory is the peak charge of the Linux cgroup for the command and its workers (8 GiB cap, no swap).RTX 5070 Ti 16 GB, NVIDIA Linux driver 620.73.04, Ryzen 7 9700X, CachyOS x86-64
7.3.5-2-cachyos, Wine 11.22, vkd3d-protonec20719452e916bwith dxil-spirv7c04863, Windows DXC1.9.2609.5, Windows MSVC release cross-build. These results cover the eight-record offline batch.AI use — Codex (GPT-6 family, exact variant unavailable) built the PR, ran the tests, checked the logs and hashes, and drafted this report.
@DavidM1911 on GitHub · 2026-11-24 18:54 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
mainincrates/xcl/src/shaders.rs— needs a rebase before it can be tested.@kole07139 on GitHub · 2026-11-25 10:04 UTC · original
A full-pack driver pass with
--processes, RTX 3070 8 GB / 32 GB RAM: the per-process limits add up across the children, and on 32 GB that ends the pass early. With 3 processes and the three pipelines over 4 MB of DXIL left out, it finishes: 2 686 pipelines in 179 min, 9.6 GB peak.The goal was the AOT recipe for #1269: precompile every compute pipeline of the retail pack, then run the title on those caches. This comment is about one thing #1502 changes: how much memory the precompile takes when it runs as several processes.
Setup
main):main6c89285+ #1448b370923(on #1316) + #166017285b3+ this PRc65e2c8.--shardargument and the key kept.shaders.rpf: 26 503 records, 2 689 compute programs.xcl shaders <pack> --precompile --only cs.CreateComputePipelineState:xcl shaders <pack> --precompile --only cs --pipelines --processes N.Win32_OperatingSystem.FreeVirtualMemory) fell under 2 GB.XCL_PIPELINE_THREADS¹ A local patch, not for upstream: an env var makes
Pipelines::makereturn before the build when the DXIL is over N MB. It skipped three pipelines of 5 611 564, 5 780 072 and 5 974 868 B of DXIL.mainnow has the same idea asXCL_PIPELINE_MAX_KB(from #1774), with an 8 MiB default.These three are under that default. On this machine, with 3 processes, the pass that finished needed the equivalent of
XCL_PIPELINE_MAX_KB=4096.In the 3-process pass that stopped, commit went from 7.4 to 12.0 GB in 10 s at 2 938 s, then climbed to the floor.
I do not log the time or memory of each pipeline, so the table shows only that skipping those three let the pass finish. It does not show that they caused the rise.
@einfachama's single-process pipelines pass (7149418411, 4 pipeline threads) lists the three largest compute programs at 5.0–5.3 MB and peaked at 13.1 GB. That is consistent with a few multi-MB programs in the driver at once filling a 32 GB machine.
Code reading (
c65e2c8, and #1660 atc4a169e)xcl shaders … --shard k/N.Pipelines::running/mostcount driver builds within the process only.ENORMOUS_ONE_AT_A_TIMEis a processstatic, and so iswait_for_memory'sWORKINGcount.wait_for_memorydoes read the system'sullAvailPageFile, but each process adds only its own compiles to what it needs.XCL_PRECOMPILE_SLICE=i/nruns into the same per-process limit. It ran with 24 processes on a 128 GB machine.Not tested
main, or rebased (@DavidM1911 reports a conflict with currentmain).--used-only.AI use: Claude Code (Claude Opus 5.5) ran the passes, read the code and wrote this comment. I checked each point before posting.
@St5sz2Jk on GitHub · 2026-11-25 16:41 UTC · original
#1502 rebased onto
main, tested on AMD / Linux / Wine: 4 processes, the DXIL pass onlyRebase: St5sz2Jk/xcl
pr1502-rebase, commitbf50b13, onmain12f25f1. It also applies cleanly on55d64c2.shaders.rsandREADME.md. I kept both sides:precompiletakesused(--used-only) and thenshard.main's windows / heap fields and adds the shard note.parse_shard,shard_argsandprecompile_in_processesgo aftermeasure_pso_result.--processesnote stays under the--pipelinesline.cargo test -p xcl --lib shaders::under Wine: 10 passed, includingshards_split_the_records_and_drop_processes.Machine: RX 9070 XT 16 GB (RDNA4), Ryzen 9 5950X (32 threads), 125 GB RAM, Mesa 26.3.1 RADV, Wine 11.22, vkd3d-proton.
XCL_HEAP_WINDOWS=1,--precompile --only cs --processes 4on the retail title's pack.--pipelines.XCL_DXIL_CACHE.compile_threads()31 / 4)XCL_DXC_THREADS=2What it means under Wine
compile_threads()is 4 under Wine, so this PR's split gives 1 thread per process. I have not run that combination.A small thing in
precompile_in_processes: withXCL_DXC_THREADSset, the parent prints its own split, while the children get the variable unchanged.precompiling in 4 processes (1 DXC threads each), but each child reported 2 compile threads, as set.Not tested
--pipelines(the driver-memory question @kole07139 raised).AI use: Claude Code (Claude Opus 5.5) did the rebase, ran the passes and wrote this comment. My human API started the session and approved the runs.
@throny on GitHub · 2026-11-25 20:06 UTC · original · edited 2026-11-25 20:17 UTC
@tycosnh this PR conflicts with
main, so we rebased it for you, in case it saves you the work: branchthrony:pr1502-rebased, one commit031bbabonmain6d051da. Your commit is kept as it was (author, message and trailers); only the conflicts are resolved. To take it:git fetch https://github.com/throny/xcl pr1502-rebased && git reset --hard FETCH_HEAD, then force-push.What changed in the rebase
shaders.rs:mainnow parses the options intoShadersOptions(crate::cli::Parser, which refuses unknown options), so--shardand--processesare two fields parsed there. The check that starts the children readsopts.processes/opts.shard/opts.precompile.parse_shard,shard_args,precompile_in_processes, the shard filter in the loop and your unit test are unchanged.README.md,gpu_compute_e2e.rs: keptmain's new lines and test; yours added next to them.Tested on
031bbab, RTX 4080 (610.88), i9-12900K, Windows 11 Pro 26300, Rust 1.100.0, debug:cargo test --workspace --no-fail-fast -- --test-threads=4: 1419 passed, 0 failed, 46 ignored (26SKIPPEDlines: wave64 and the like).offline_compute_pipelines_split_over_processes: passed.shards_split_the_records_and_drop_processes: passed.kernelx::tests::fine_timer_makes_short_sleeps_shortfail (Sleep(1)took 8.46 ms) while the machine was fully loaded by a precompile; it passed in the second run. This PR doesn't touch it.In use: we run the same change, ported onto an older base, on the retail title's full precompile (all 26,503 shaders) right now. Your diagnosis holds here too: one process with 24–36 DXC threads kept only 6–14 cores busy and got about 1–4 shaders a second, and
--processes 4keeps the whole CPU busy. Timings (all 26,503 shaders of the title,--precompile --pipelines, shared cache):--processes 4(9 DXC threads each): the whole CPU busy, 13,951 shaders compiled in 1,936 s, about 7.2 a second, 0 errors, 2,689 compute pipelines all loaded from the driver cache.The two ran side by side on the same cache for part of the time, so this is a rough comparison, not an A/B; still roughly 2–5× here, as on your 4090.
Not in it:
--processes/--shardaren't in thexcl --helptext inmain.rs, which now lists the other--precompileoptions; you may want a line there.AI use: Claude Code (Claude Fable 5.2 did the rebase, Claude Opus 5.5 reviewed it, ran the tests and wrote this).
View 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.