Shaders: cap the HLSL size --precompile compiles on a cache miss #1723
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!1723
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1723"
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?
@PracticalStudios on GitHub · 2026-11-24 19:55 UTC · original
PracticalStudios:shaders/precompile-source-cap→main· +260 −10 · 4 files · 3 commits · openxcl shaders --precompileskips programs not cached yet whose HLSL is over 8 MB (--max-source-mb Nto change it,0for no limit) and lists them at the end. Part of #1269.Why: a few programs over 8 MB take more than 12 GB each in DXC and stop
--precompile --only csfrom finishing (@Sergentval, @LRF17 in #1269).How it relates to
main's other limits:XCL_PIPELINE_MAX_KBcaps the DXIL that--pipelineshands to the driver; this caps the HLSL that DXC is given, earlier, where the >8 MB programs run out of memory. With--used-onlythe cap applies to the programs that filter keeps.What is in it
shaders.rs,dxc.rs,main.rs,README.md: the option; cached programs are still used; refusals are not cached; a bad value exits with code 2.Tested
cargo test --workspace --no-fail-fast -- --test-threads=2onfca46d4: 1165 passed, 1 failed, 46 ignored. The failure (kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory) fails the same way onmainon this machine.xcl shaders shaders.rpf --precompile --only cs --max-source-mb 8, release build of this branch (f0208f3, same tree as6e428e9),XCL_DXC_THREADS=8, empty cache: compiled 2683, refused 6 (147.4, 29.6, 29.5, 12.7, 12.3, 12.0 MB of HLSL), 0 errors, 2028 s, peak commit 3.8 GB.Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input,main(this PR's base) first, same machine:Not tested
XCL_DIRECT_DXIL, compute programs skip DXC, so the cap does not apply.AI use
@Royalflamejlh on GitHub · 2026-11-24 21:51 UTC · original
Offline pass under Wine, CPU only, on
0a1c528(the head before today's rebase; the change is the same): with--max-source-mb 8a pass over the first 22,700 records of a retail pack finished under an 8 GB memory limit, and without the option the same pass was killed at the limit. One pass each. The description's passes are on Windows and it lists Linux as not tested; this is the option under Wine, over a slice of the pack.We wrote the same limit before this pull request was opened and did not open ours once this one existed:
Royalflamejlh/xcl, branchshader/precompile-limit(858bc08, one commit, +53 / −4), on by default at 8 MB, with--max-source-mb 0turning it off. The two questions under Read come from it, and its numbers are below for whoever wants them. Take from it what helps.Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 62 GB RAM. These passes used no card. Release, cross-compiled to
x86_64-pc-windows-gnu, DXC 1.9.2609.5.0a1c528built as it is (its base isc160d86). That was the head until the force-push of 21:27 UTC. The head is now6e428e9, the same two commits onmainb9b6ea6: the changes todxc.rsandshaders.rsare line for line the same.6e428e9was not run.xcl shaders shaders.rpf --precompile --only cs --limit 22700 --split 1 [--max-source-mb 8], from an empty cache each time,XCL_DXC_THREADS=8, 4 memory windows, in a cgroup limited to 8 GB of memory and 1 GB of swap. Times are from the start of the process to its end; peak memory is the cgroup's.Tested
--max-source-mb 8main9e3831e). The description's whole-pack pass on Windows refused the same six sizes.The same limit on our branch, for comparison (each one pass, same machine and limit):
main9e3831ewas killed at 8 GB; with the limit on that commit, 540 compiled, 3 left out, peak 4.0 GB.c160d86, the base0a1c528had (8195346), 540 compiled, 3 left out, peak 4.3 GB, and the same 533 DXIL files by SHA-256 as the first row above; onmainb9b6ea6, the base the head has now (858bc08), 540 and 3 again, peak 4.1 GB.9e3831eand #688 merged in for speed: 2,683 compiled, 6 left out, 0 errors, 1,503 s, peak 7.7 GB.Read
shaders.rs:1110at6e428e9,max_source_arg: the cap is off unless the option is given. So--precompile --only cswithout the option still runs into those programs, as in the second row. When #744 was merged the maintainer wrote of the--precompile --pipelinespass that "a size limit for that pass would be a welcome follow-up". Would a default of 8 MB serve that better than an option that is off? 8 MB is wheredxc.rs:491already switches to-O0.dxc.rs:1346,a_zero_cap_refuses_every_non_empty_miss:--max-source-mb 0refuses every miss. If the cap became the default, 0 would be the natural way to turn it off: worth deciding which of the two it means.Not tested: the rebased head
6e428e9; the whole pack on this branch (a guess from the first 22,400 records, where #688 took the pass from 279–287 s to 55–59 s: about five times as long here without it);--pipelineswith the cap; other stages (--only vs|ps|ms, or no--only); a second pass over a warm cache; the exit code for a bad value; the test suite beyond the 12 new tests; a title run; native Windows; the native wave64 form on this branch. The machine was shared: a title run and another shader job of ours went on beside the passes.AI use: Claude Code (Claude Fable 5.2) ran the passes, read the diff and wrote this report.
Posted without review by a person: the account owner was away and reads replies later.
@PracticalStudios on GitHub · 2026-11-24 21:56 UTC · original
Thanks, this is useful, especially the Wine numbers and the cgroup kill without the option. Agreed on both points: I'm making 8 MB the default with
--max-source-mb 0turning it off, and will push it here shortly.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Rainmaker33 on GitHub · 2026-11-24 22:08 UTC · original
A whole-pack pass on this branch, the first item under Not tested, on Windows: with
--max-source-mb 8,--only csgoes through all 26 503 records, including the ones past @Royalflamejlh's 22 700-record slice under Wine. It finishes on a 32 GB machine with the default 11 compile threads, peaking at 4.7 GB.Tested
0a1c528(before the rebase; the code diff is the same as6e428e9apart from one indented help line), release. RTX 3090 24 GB (driver 32.0.16.1088), Ryzen 5 8600G (12 threads), 31 GB RAM, Windows 11 26300. DXC 1.8.2502.11 from the Windows SDK.xcl shaders shaders.rpf --precompile --only cs --max-source-mb 8on the retail pack, into an emptyXCL_DXIL_CACHE. Defaults otherwise: 11 compile threads, 4 memory windows, split wave64. Idle priority, nothing else running. A sampler read the process's private bytes every 2 s.Result
The six refused, as the pass lists them: 147.4, 29.6, 29.5, 12.7, 12.3 and 12.0 MB of HLSL. These are the three screen-probe programs and three of the RT shadow trace programs.
That is two more than the four in @LRF17's run with the same 8 MB limit:
ActivateProbesandActivateProbesTarget, at about 29.5 MB each here, were not refused there. Their tree had #1315/#1316, and I take its compact form to be what kept those two under 8 MB. I have not checked that.So, with this cap, the pass that ended in
memory allocation … failedon @Sergentval's 3090 without a cap completes here, on half the RAM of the machine in the description.Not tested: the HLSL path's run time against
main(the other half of the comparison); the wiring underXCL_DIRECT_DXIL.dacbefc(pushed since) makes 8 MB the default. That is the setting this pass used.AI-assisted (Claude Code)
@DavidM1911 on GitHub · 2026-11-24 22:28 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.Thanks!
@PracticalStudios on GitHub · 2026-11-25 03:11 UTC · original
Rebased onto
maincbc296a:shaders.rsconflicted with #1982's--used-only; both are kept (the used-only filter runs first, then this cap). New headfca46d4; its suite count and regression blocks are in the description. The description now also says how this relates toXCL_PIPELINE_MAX_KB(that one caps the DXIL handed to the driver; this one caps the HLSL given to DXC).AI use: Claude Code (Claude Opus 5.5) wrote this note.
@JJAutoCompare on GitHub · 2026-11-25 04:20 UTC · original
PR #1723 verification
Clean head
fca46d42e5a15172e55f9f2421dd725f5571c9eaon STOR-WINLAB. Windows 11 x64 (10.0.26200.9974), AMD Ryzen 7 3800X, Intel Arc A770 (16 GB, driver 32.0.101.9175), DXC 1.9.2609.5, rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc).Tested
cargo build --workspaceandcargo test --workspace --no-runboth exited 0 outside the Arc lock. Dev and test profiles were unoptimized with debug info and incremental compilation disabled.cargo test -p xcl --lib -- gpu::recomp::dxc::cache_tests max_source_mb --nocapturewithXCL_ADAPTER=NONE_CPU_ONLYoutside the lock. 22 passed, 0 failed, 0 ignored, 0 explicit skips. All 12 new tests passed. They cover cache hits above the cap, refusing oversized misses without calling the compiler or writing DXIL, accepting misses at and below the cap, cap scoping, and the longest refusal per call. Parser tests cover the 8 MiB default, zero disabling the cap, whole-MiB conversion, overflow saturation, invalid or missing values, and first-option precedence.cargo test --workspace --no-fail-fast -- --test-threads=4ran once insideInvoke-ArcTest.ps1withXCL_ADAPTER=A770andRUST_TEST_NOCAPTURE=1. Exit 101.pr1723-suite.loghas 21 summaries (20 test binaries and 1 doc-test harness) totaling 1,138 passed, 28 failed, and 46 ignored.Workspace failures and skips
0x80070057) and four output assertions covering FMA, implicit mip LOD, f16, and wave64 pixel reductions. The e2e title reported a blue pixel where theRSSetDepthBiasXcheck expected green.SKIPPED. Reasons included unavailable wave64, unsupported shader forms, tiled-resource tier, unavailable heap windows, and debug-layer or driver-cache requirements. These skips provide no coverage.Not tested
Matched
mainrun, retail title smoke, real-pack--precompileand its refusal output, or other GPUs.XCL_SAMPLE_*inputs were unset.AI use
T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1723-suite.logand published.@DavidM1911 on GitHub · 2026-11-26 06:17 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.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.