Skip to content

recomp: cap per-lane compute size so giant shaders use compact DXIL (#2203) - #2341

Open
zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-size-cap
Open

zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-size-cap

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What is in it
Follow-up to #2203 addressing @tiagonleal's XCL_PER_LANE=1 memory-spike report on giant compute programs (such as 56c0cd3b82a00c6e):

  • After recomp: enable whole-wave branches and dead-SCC elision in split wave64 #2203 enabled whole-wave branches in split-wave64, 56c0cd3b82a00c6e (488,744 B guest code, 14,377 blocks) became accepted by recomp::lower_dxil::compute_with. Because the per-lane form has no compact loop-switch lowering, it emitted 4,563,088 B of plain DXIL (9.5× larger than gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's 478,764 B compact form), causing the NVIDIA driver compiler to spike +18 GiB RAM and OOM.
  • Adds two caps in crates/xcl/src/gpu/recomp/lower_dxil.rs:
    • MAX_INSTS = 20_000 (matching dxil::compact::large's 20,000-instruction threshold): checked right after decode before spawning the 256 MB worker thread or constructing IR, so giant programs immediately fall back to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's compact form.
    • MAX_DXIL_BYTES = 1 << 20 (1 MiB): post-lowering safety cap in compute_with (all 39 normal per-lane compute shaders in the 2,000-program sample are <= 197 KB).
    • Modifying lower_dxil.rs advances XCL_PER_LANE_SOURCE_ID automatically so any cached multi-megabyte per-lane entries are invalidated on disk.
  • Adds unit test compute_with_refuses_giant_programs_for_compact_fallback covering both caps.

Impact:

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti (driver 621.01), AMD Ryzen 5 7500F, rustc 1.100.0, DXC / dxil.dll 1.9.2602.17, debug & release builds.
  • cargo test --workspace -- --test-threads=4: 1273 passed, 0 failed, 46 ignored (SKIPPED: 20 native wave64 GPU tests on 32-lane NVIDIA GPU, 3 pre-existing f16/f32-to-f16 per-lane refusals, 1 driver-cache test without Windows Developer Mode, 1 heap-window test, 1 D3D12 debug-layer test, 2 other adapter-gated skips).
  • xcl shaders <pack> --direct --hash 56c0cd3b82a00c6e --lanes --split 1: refused by per-lane (program too large for the per-lane form), compact form 478 KB DXIL, 0 errors.
  • xcl shaders <pack> --direct --lanes --split 1 --sample 2000 --max-bytes 0: 39/205 per-lane compute programs unchanged, 4 giant compute programs capped, 0 validator/panic errors.

Regression run
Baseline (main 568e7db):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR (92437bd, run with XCL_PER_LANE=1):

xcl-smoke v1
commit: 92437bd3ebc7df5504604247055acd93e57fc46f
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1526 (PresentX 1526)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14932 MB

Not tested

  • AMD / Intel Arc GPUs; 300-second extended menu soak with XCL_PER_LANE=1 (verified via single-hash 56c0cd3b82a00c6e routing to compact form + 60-second XCL_PER_LANE=1 smoke run).

AI use

  • Antigravity (Gemini 4 Neon) assisted with measuring 56c0cd3b82a00c6e and the 2,000-program per-lane size distribution, implementing MAX_INSTS / MAX_DXIL_BYTES and the unit test in lower_dxil.rs, and running the test and smoke suites.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

No Linux/Wine report in the thread yet; adding one.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants