xcl shaders --precompile --pipelines: memory grows without bound (84 GB committed after ~17 min) #1657
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#1657
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@ThiagoAlexsander on GitHub · 2026-11-24 18:51 UTC · original
What happens
xcl shaders <retail shaders.rpf> --precompile --only cs --pipelineskeeps growing in memory for as long as it runs, until Windows is out of commit.With
XCL_PIPELINE_THREADS=4, after about 17 minutes:xcl.exehad a 42.8 GB working set and 83.9 GB committed (private bytes).An earlier attempt with
XCL_PIPELINE_THREADS=12on the same machine ran it out of memory as well.That is far more than the comment on
Pipelinesinshaders.rssuggests: about 1.5 GB in the driver for each of the biggest compiles, 4 at once by default. It looks like something is kept for the whole run (translations, compiled DXIL or blobs) instead of being dropped once it has been written to the cache.Workaround
The precompile is resumable, so I run it in a loop that kills
xcl.exeonce it passes 25 GB private and starts it again. Each pass skips what is already cached.--limit Ndoes not help with chunking: it takes the first N records (input.len().min(limit)), so every pass would redo the same programs.Expected
Memory stays around the working set of the compiles in flight. Programs whose DXIL and driver blob are on disk should no longer hold memory.
XCL version
A local release build of
mainb7aa9f3with #541, #1273, #681 and #1656 merged (and, for the later passes, #253). None of those touchesshaders.rsor the DXIL cache. I have not yet confirmed it on plainmain, and I can do that if it helps.Environment
shaders.rpf(26,503 records).AI use
Claude Code (Claude Opus 5.5) ran this and wrote the report. I approved filing it.
@coenflict on GitHub · 2026-11-24 19:10 UTC · original
I have a small patch for the chunking workaround described here. It adds a zero-based
--starttoxcl shaders --precompile, so--limitcan bound successive runs to different input records:Both bounds count input records before
--onlyfilters by stage. This lets you restart between chunks and reuse the existing caches. The cause of memory growth within a chunk remains open.Single-commit patch on my fork, based on upstream
c160d86.Tested
.\scripts\test.ps1 --nocaptureon9017f72: 859 reported passes, 0 failures, 42 ignored. Three of the reported passes skipped their GPU work:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64), andheap_window_out_of_memory_falls_back_to_the_switch_form(heap windows disabled).Not tested
AI use
gpt-6.2-sol) implemented the patch, ran the tests, and drafted this report.@tiagonogueiraa-bit on GitHub · 2026-11-24 19:23 UTC · original
This may be #1307 / #1332 rather than something kept for the whole run. On
b7aa9f3without #1321, record 22619 of the pack (indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays…, a compute program, so it is in--only cs) translates to 148 MB of HLSL, and DXC on it alone goes past 30 GB (#1332). On #1321's head, @Royalflamejlh ranxcl shaders --precompile --only cs --limit 23000: it finished with 843 compiled and a 2.6 GB resident peak, where930e8b4was killed at a 30 GB limit after 34 s (#1321). That pass had no--pipelines.A pass of yours with #1321 merged would tell whether anything is left over from the driver side with
--pipelines.Written with Claude Code (Claude Opus 5.5).
@NemesisDawn on GitHub · 2026-11-24 19:33 UTC · original
I looked into the missing progress line mentioned above. On main
c160d86, a shader skipped by--only cscan hit a 200-record milestone without printing an update. The attached patch makes progress reporting consistent for filtered, unrecognized, and unreadable records and adds a regression test.Two isolated Rust checks failed before the fix and passed afterward.
git apply --checkalso passed onc160d86. The patch addresses progress reporting. The memory-growth investigation and full GPU and retail smoke testing remain separate.AI use: OpenAI Codex (GPT-6, exact variant unavailable) diagnosed the bug, wrote the patch and regression test, and ran the isolated checks.
xcl-precompile-progress.patch
@JRamos1993 on GitHub · 2026-11-24 19:40 UTC · original
This looks like #1307. One compute program's structured HLSL is about 150 MB, and DXC alone takes tens of GB on it. On
mainc160d86here, a cold--precompile --only cswith 8 DXC threads went from 5.7 GB to 39 GB in 30 s, at the point where it picked up that program. With #1321 merged, the same run stayed under 8.7 GB for 10 minutes. Numbers and setup are in my comment on #1321.AI use: Claude Code with Claude Opus 5.5 ran the measurements and wrote this comment.
@itsd-effex on GitHub · 2026-11-24 19:43 UTC · original
One more piece next to #1321: several enormous programs at once. #1321 makes ActivateRays small again, but the two other screen-probe programs (ActivateProbes, ActivateProbesTarget) still have about 30 MB of DXIL each and take several GB in DXC. If they compile at the same time, their memory adds up. Under Wine, the admission check (
wait_for_memory) doesn't catch it, because the commit headroom it reads includes all of the host's swap.Measured in
xcl pipelineswith only these three programs in flight together. Linux, RTX 3080 Ti, 32 GB RAM, a cgroup of 25 GB RAM + 32 GB swap, empty DXIL cache:mainDetails and tests are in #1660. #1710 (retry after
E_OUTOFMEMORY) is the reactive side of the same problem. Under Wine, DXC rarely seesE_OUTOFMEMORY, because the host swaps first.AI use
@ThiagoAlexsander on GitHub · 2026-11-24 19:54 UTC · original
I narrowed it down. Each measurement samples
xcl.exeprivate bytes every 10 s for 60 s while it runsxcl shaders <retail shaders.rpf> --precompile --only <stage>, on the same machine and build as above.--only cs --pipelines(XCL_PIPELINE_THREADS=4)--only cs(no pipelines)--only cs, #688 merged--only cs,XCL_TRANSLATED_CACHE=0--only cs,XCL_DXC_THREADS=2(90 s)--only psWhat this rules out, and what it leaves:
--pipelinesit grows faster; with them, the driver compiles just slow the loop down.XCL_TRANSLATED_CACHE=0. It also grows when most programs are already in the DXIL cache: an earlier pass with nearly everything cached passed 25 GB within 20 s.--only csbranch, i.e.pso::console_to_dxil_in→compile_console_shader.--only psstays flat. I didn't confirm how many PS programs that run reached within its 60 s, so treat that row as weaker evidence.In the code,
ShaderCache(capped at 128 entries / 64 MB),cached_shader,translated::cached_in,shader::STATE(hashes only) and the translator's per-Ctxmemo all look bounded, so I couldn't point at a line. The growth works out to roughly 35 MB per compute program processed.Not tested: plain
mainwithout the merged PRs, and AMD.AI use: Claude Code (Claude Opus 5.5) ran these measurements and wrote this comment. Posted with my approval.
@itsd-effex on GitHub · 2026-11-24 20:16 UTC · original
A follow-up on memory, now that #1426 is on
main: the direct DXIL backend sidesteps most of DXC's memory use on the slow tail of this title.The same 40 slow-tail pipelines through
xcl pipelines(mainc160d86+ #688 + #759 + #684 + #1321 + #1660), once with HLSL + DXC and once withXCL_DIRECT_DXIL=1. Linux, RTX 3080 Ti, 32 GB RAM, 14 threads, a cgroup of 25 GB RAM + 32 GB swap, empty caches, stopped at 20 min:XCL_DIRECT_DXIL=1With direct DXIL, memory stopped being the limit for
--precompile-style runs on this machine. I haven't testedxcl shaders --precompileitself.AI use
@ThiagoAlexsander on GitHub · 2026-11-24 20:40 UTC · original
Retested on
main4178e88, which includes #1748.--only csnow stays at 1.5 to 3.1 GB private over 60 s (it was about 95 GB onb7aa9f3), same machine and same measurement. #1748 looks like the fix. I'll confirm once a full--only cs --pipelinespass finishes, then close this if nobody objects.AI use: Claude Code (Claude Opus 5.5) ran the measurement and wrote this comment. Posted with my approval.
@ivall on GitHub · 2026-11-24 21:08 UTC · original
The runaway growth here is #1307, and it is fixed on
mainby #1321, merged ase9e94ce. @tiagonogueiraa-bit, @JRamos1993 and @CoDrift had traced it: one compute program came out as about 150 MB of source, and DXC's memory on it kept growing. Your table fits that: it grew faster without--pipelines, and also with two DXC threads.One correction, so the result is not read the wrong way: I don't think #1748 is the fix. It changes only the direct DXIL path (
XCL_DIRECT_DXIL). I measured that program's source withxcl shaders … --export-hlsl … --record-hash 95cc13288a27a96e(AMD RDNA4, 4 windows, native wave64):main4178e88(with #1748, without #1321)A 60 s run on
4178e88may simply not have reached the program: it is around record 22,600, and #1524 had changed the generated source, so the DXIL cache started cold. That part is a guess.With #1321, @CoDrift's full
--only cspass ended with 2,689 compiled, 0 errors and a 7.1 GB peak (report).What is left is the driver's own memory on the other very large programs with
--pipelines(there 8 → 20 GB in about 10 s on an RTX 3080 Ti). That is #1598, with #1660 and #1316 as candidates. The patches proposed above (a start index, progress lines, a memory budget) have their own PRs and don't need this issue.Closing as fixed by #1321. If a full
--only cs --pipelinespass one9e94ceor later still grows without bound, say so here with the numbers and I'll reopen it. Thank you for the measurements.AI use: Claude Code (Claude Opus 5.5) read the thread, made the measurement and wrote this, on the maintainer's behalf.