AMD driver compiles take 3-8x the budget's estimate and grow quadratically: one compute program cannot be built on 64 GB #19
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ThatRecompDev--five-star-recomp#19
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?
@Sr-0w on GitHub · 2026-11-25 05:22 UTC · original
On an AMD card the driver's pipeline compiles take far more memory than
CompileBudgetexpects, and the memory a compile takes grows about quadratically with its DXIL. With the default 4 driver compiles the loader reaches the machine's commit limit during the story load (51 GB private at 37 s); a single compute program cannot be built on a 64 GB machine at all.Setup: RX 7800 XT (16 GB), Adrenalin driver 32.0.32029.2010, 64 GB RAM, Windows 11 26300;
mainatf9fab82, DXIL backend (default),--min-free-memoryused to stop runs before the machine ran out.In game: the
[budget]lines (ff3914e)InstanceCulling~CS_Prop_BatchNoCullPS_OctaSLODReZ+MS_VS_OctaSLODPS_OctaSLODReZ+MS_VS_OctaSLODWindPS_BakeDecorations_0000+MSNC_VS_BakeDecorationsstandard_lod~CS_RaytracingResolvesr_tracing~CS_RaytraceVBuffer_RayBinning_ShaderBinning_Mixed_WithFarSo 3 to 8 times the estimate, with several running at once.
indirect_diffuse_lighting~CS_ScreenProbes_ActivateProbes(12-13 MB of DXIL, a 60,000-instruction program) goes to its own thread and takes the process from about 20 GB to over 50 GB private in 30 s; every run that requested it ended on the free-memory limit (or the machine ran out without one).Isolated:
fivestar shader psoon that one programA folder holding
results.jsonand<name>.dxil,fivestar shader pso <dir> --jobs 1 --max-memory N, peak private memory sampled every 0.5 s. Same HLSL (fivestar shader translate), compiled with dxc-Od(as for sources over 2.5 M characters), main's body cut after a fraction of its lines, open blocks closed, and the XOR of every s/v register stored to a UAV so nothing is dead:What I ruled out, each with the same harness or in game:
-O3DXIL is 8.0 MB (13.1 MB from the DXIL backend, 22.0 MB-Od). In game, with the-O3file placed in the program cache, the compile still passed 53 GB.g_code: the program has ans_getpc_b64, so its 122,191 code words are a static array that 210 pointer loads index through theCODE_TAGfallback. With only the 11-word table afters_endpgm, it is still over 40 GB at 63 s.FmtLoad: 3,281 calls, each a 4-component format decode. WithFmtLoadreplaced by a plainLoad4, it is still over 40 GB at 46 s.--dispatchform: 8.7 MB of HLSL, but dxc-Odhad not finished after 9 minutes.None of these is the cause on its own. The growth follows the size of one function with deeply nested
if (vw_any(active))blocks and the whole register file live across them. NVIDIA handles that, per the 2.75 GB per MB measurement; AMD's compiler does not.Effect
With
--max-driver-compiles 1, and the pipelines of 4 MB of DXIL or more left unbuilt (a local change), the same machine runs the story load and the opening credits, and reaches the first deferred-world draws (9,000 presents). The defaults run out of memory before that.Possible directions (to agree on before any PR)
GetCachedBlob, which the loader loads withCachedPSOand stores in its library. A compile past a memory or time limit is killed, and its pipeline stays a stand-in (its draws skipped, as for a failed one). The failure is recorded in the cache, so later boots do not retry it.I can send the measurements' scripts, or work on 1 or 2 if one of them fits where the compile budget is going.
@Sr-0w on GitHub · 2026-11-25 07:23 UTC · original
Thanks for
671b8bcandaca5a03. On72b7328, the RX 7800 XT gets further: the story load and the opening credits, at about 30 fps. Two things measured since then:1. With the commit charge at its limit, amdxc64 dereferences null instead of failing the compile. Three boots ended
Fatal error. 0xC0000005 at DesktopDevice.CreatePipelineState. A createdump minidump (DOTNET_DbgEnableMiniDump=1) puts it in the driver's compiler:Each time the commit charge was at the limit just before:
PS_PropFoliageDeferredTo_GBuffer+MSNC_VS_PropFoliageSkinDeferred(2 MB),MS_VS_CascadeShadows_drawskinnedPS_PropFoliageDeferredTo_GBuffer+MS_VS_PropFoliageDeferred(2 MB, 180 s in)ped_standard_lod*~CS_RaytracingResolve(8.8 and 14.8 GB each in isolation)Alone, with
fivestar shader pso --jobs 1, the two RaytracingResolve programs are accepted: 47 s at 8.8 GB, and 78 s at 14.8 GB.The first crash already had a second build thread inside the same amdxc64 functions, so a race is possible too. But the commit charge points to an allocation failure the compiler does not check.
2. The quadratic estimate is low for the 1.3-2.2 MB mesh pipelines. These are the in-game
[budget]lines from today's boots (79 compiles). The peaks are the process's growth, so concurrent compiles add noise:Below 1 MB the estimate covers the peaks. Above about 1.25 MB the mesh+pixel pipelines (
PropFoliage*,OctaSLOD*,TexturedDeferredAlphaClipNC+MS_VS_TransformSkinD) go past it. On a 64 GB machine with a system-managed page file, the commit limit is then reached.These slow, large compiles also cap the world's progress. With the cutscene's ~3,000 pipelines queued, a boot builds 13 to 100 of them. So the in-engine cutscene between the load and the credits stays black, and its draws are skipped as stand-ins.
Given (1), a compile in its own process (point 2 of the first post) would turn this crash into a failed compile. I can take that on if it fits your plans.
@ThatRecompDev on GitHub · 2026-11-25 08:10 UTC · original
main now has
--host-pipelines(off by default for now): compiles over 2 MB run in a separate copy of the loader with a memory and time limit, and if amdxc64 crashes or runs out of memory in there, the pipeline just stays a stand-in instead of taking the game down. once a host has built one, the driver's disk cache lets the loader create it in under a second (checked on NVIDIA, not on AMD yet). we also raised the AMD estimate above 1 MB from your table. if you get a chance, a run with--host-pipelineson the 7800 XT would tell us whether AMD's cache carries over the same way@ThatRecompDev on GitHub · 2026-11-25 11:42 UTC · original
quick update since your 7800 XT numbers. a lot of the AMD cost is gone thanks to your PRs: the simplifier (#24), lane masks staying bools (#26, ActivateProbes went from 11k ballots to 925 in the DXIL) and the readfirstlane crash fix (#27). the 4 CompileBudgetTests that failed on your machine were our bug too (a device created in another test left the vendor set to AMD), fixed on main in
376adc4.when you get a chance, could you check whether CS_ScreenProbes_ActivateProbes builds on the 7800 XT now, and roughly what it costs? that's the one that couldn't be built on 64 GB, so it tells us whether this issue can close
@Sr-0w on GitHub · 2026-11-25 16:01 UTC · original · edited 2026-11-25 16:37 UTC
CS_ScreenProbes_ActivateProbeson the RX 7800 XT, current backend: it still can't be built.Setup: 64 GB, Adrenalin 32.0.32029.2010.
fivestar shader psowith--jobs 1,--max-memory 48,--timeout 900, outside the game. The DXIL comes from the DXIL backend (--backend dxil-only).waveAnyTruewaveActiveBallot77187ce)So #24, #26 and #33 shrank the DXIL a lot (#33 removed 41% of the instructions), but the driver's peak doesn't move. The memory doesn't seem to follow the instruction count. It seems to follow the control flow: about 33k blocks, nested up to 28 levels deep. Each guarded VOP or memory group of the console program becomes an
if (vw_any(active)), and the source has 122k dwords. That points at the driver's structurizer or uniformity analysis rather than instruction selection.What I'll try next, and post here:
if (vw_any(active))blocks with the same mask into one region, and turn plain select-only bodies into straight-line code, so the block count drops without changing semantics.@ThatRecompDev on GitHub · 2026-11-25 16:43 UTC · original
great measurements, the CFG theory fits what we see on NVIDIA too. folding same-mask regions sounds right. one thing from our side: our --fast-waves experiment found some any-lane branches can't be folded safely when the paths have different barrier counts, so keep an eye on barriers inside those regions. looking forward to the numbers