Recompiler: compact form also for branch-heavy programs of 2000+ blocks #3263
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3263"
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?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T02:18:27Z.
Note: the suite and smoke results below replace an earlier set that, by a test-setup mistake (shared cargo target directory), came from another PR's build. These were run with a forced rebuild of this head.
Stacked on #3261 (which is stacked on #3250); only the top commit (
e618b742) belongs here.amd-dev's
9887b414(Saksukella):compact::large()asked only for 20,000+ reachable non-terminator instructions, so branch-heavy unrolled compute programs just under that (e.g.56c0cd3b82a00c6e, about 32k blocks) stayed in the plain form and produced 2.6 MiB of DXIL. The NVIDIA / AMD driver then committed tens of GB to compile it. The threshold becomes 10,000 instructions or 2,000 reachable blocks;automatic_planstill asks for the repetition and the table limit before it takes the form.What is in it
crates/xcl/src/gpu/dxil/compact.rs:LARGE_INSTS = 10_000,LARGE_BLOCKS = 2_000inlarge()crates/xcl/src/gpu/dxil/compact_tests.rs:a_large_program_that_repeats_itself_takes_the_compact_formchecks 2500 / 500 copies (compact) and 400 (plain)Tested
cargo test --workspace --no-fail-fast -- --test-threads=4one618b742: 2609 passed, 4 failed, 49 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3:E_OUTOFMEMORYfromCreateComputePipelineStateat seeds 70 / 545 / 1019 / 1507, the same as on main on this machine; they pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code. SKIPPED GPU tests: 30, almost allno wave64.-StartupTimeoutSeconds 3600for the cold pipeline rebuild new DXIL needs.Regression run
main:
this PR:
Not tested
AI use
9887b414(Saksukella, cherry-picked there from53995420); the subject is reworded to the repo's style.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:04Z.
merge-check
base:
fa204595a4head:
e618b74207merge: clean onto main and with the 7-PR stack.
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on main
fa204595:cargo test --workspace --no-fail-fast -- --test-threads=4(DXC 1.9.2609.5;-p xcl --librerun skipping the 2 knownmain#3187uma_drivermixed-window testsa_refused_gpu_upload_segment_becomes_customandmixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4fuzz_validate_and_gpu_0..3passed); failing: none. 150 sxcl-smoke(ea3b5e4d,XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack:exit: 0x0,2096frames shown,0device removals,0crashes,0display System events,32049 MBpeak commit.review: none (whole diff read: lowers
LARGE_INSTSto 10_000 and addsLARGE_BLOCKS = 2_000incompact::large(), still gated byautomatic_plandeduplication;compact_tests.rsupdated to check 2500/500/400 copies).performance: positive: avoids multi-MiB plain-form DXIL and driver memory spikes on branch-heavy 2000+ block shaders; no regression in 150 s smoke.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T19:32:41Z.
Test report: cold driver compile time with this stack on an RTX 2070 SUPER (Turing, 8 GB). One run per record, so read it as a direction.
I merged both of Foniass's stacks onto
main0fe06eb0(this PR's #3250 → #3261 → #3263 and #3266 → #3268 → #3269; they merge without conflicts) and compared that build withmain. The numbers are for both stacks together: I did not measure them separately.Setup
xcl shaders <retail game's shaders.rpf> --measure-pso <record> --repeat 1: the driver's shader caches are turned off (ShaderCacheControl, Developer Mode), so every build is cold. One compile at a time, through a local exclusive queue.Results (DXIL bytes, cold
CreateComputePipelineStates)mainXCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=195cc13288a27a96e2e1d03fbed9d95eb958400d2caf0724456c0cd3b82a00c6e1d4ecf4cb407d4fe95cc…, the program #3261 names: 4.8× less DXIL and 5.1× faster to build cold here.958400d2…and56c0cd3b…: about half. The plain-form programs (2e1d…,1d4e…) shrink 27–32 % but build barely faster; heap windows help those instead, so the two are complementary.E_OUTOFMEMORY).Not tested: the stacks separately; the suite and a title run of the merged build (only pipeline builds); whether the image is the same; AMD.
AI use: Claude Code (Claude Opus 5.5) merged and built the stacks, ran the queued job and wrote this report.
Context: why DXIL size matters for cold compilation. On this title, compute programs whose whole DXIL is 512 KiB or larger are 27 % of the 2,730 compute programs but about 95 % of a cold full preparation's compute driver work (driver time weighted as size^1.6, fitted to 1,340 cold compiles on this card). So size reductions count almost only on those programs. Breakdown by size band: https://github.com/xcl-dev/xcl/issues/2088#issuecomment-7262349510
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T19:37:19Z.
merge-check claim
head:
e618b74207Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T19:56:04Z.
merge-check
base:
0fe06eb0f0head:
e618b74207merge: clean. The merge carries the whole stack:
e13ccd7f(#3250),16f2f5c1(#3261) ande618b742(this PR's own commit); everything below is about that whole merge.build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2743 passed, 0 failed, 49 ignored, 28 SKIPPED: 22 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows (one of them the opt-in XCL_HEAP_WINDOWS=1 test), 1 no GPU_UPLOAD heaps; failing: none. The base
0fe06eb0, run alone on this PC with the same command and its own target dir: 2737 passed, 0 failed, 49 ignored, the same 28 SKIPPED. The PR's changed test a_large_program_that_repeats_itself_takes_the_compact_form passed. All 4 fuzz_validate_and_gpu_0..3 passed here (8 GB card). Each suite ran alone in the queue.review: 4 minor findings, no major or critical one.
e964ad22saw an RX 9070 XT reach 24 GB building the compact form of a 9,219-word program (neither form built);3cde0cc3since allows 12,288 words on every GPU; nothing gates the new limit by vendor, and no test covers a table above 12,288 words (compact_tests.rs:274 assertsp.words() <= 12288). Not a confirmed regression; the maintainer's RDNA4 run is what would show it.>= 4occurrences; the code does it at>= 2(compact.rs:359).Checked without a finding: the DEFINE_ABBREV encoding and abbreviation ids (function block width 4, 12 abbreviations; constants block width 3, 3), field widths, and abbreviated record layouts against the unabbreviated ones; CST_CODE_DATA never empty; micro-block splitting keeps instruction order; literal parameterization only for a block with one literal-bearing instruction; SGPR / SCC use-def sets against the operand table, with VCC, EXEC and M0 never elided; veneer strip relies on resolve_far_jumps' exact register match.
performance: measured on this PC in the earlier test report on this PR ( cold CreateComputePipelineState with the driver's caches off, one run per record): main
0fe06eb0with this stack and the #3266 -> #3269 stack merged together (not this stack alone) took 65.5 s against main's 109.5 s over 5 large compute programs, with 2.3-4.8x less DXIL on the three compact-form ones. Not measured here: frame time, and the extra per-iteration table loads in the compact loop head. Every direct-DXIL translation changes, so such programs are translated and built again once.verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 90e952bb98be58f5d9387dbd13789634dbf77d41 (local, not pushed). Not tested: AMD, native wave64. Claude Code: Claude Opus 5.5 (coordination, draft), Claude Opus 5.5 (full-diff review), Claude Opus 5.5 (recompiler review).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T21:42:53Z.
Test report: full startup shader preparation, cold cache, with #3442 + the #3263 stack + the #3269 stack together
One run of a build that combines these three PRs. It shows what they do together; it does not say how much each one contributes.
Build:
a96b183c, local merge of 4465c886 (main3b6a91ed+ #3318 #3321 #3323 #3325 #3328 #3330 #3332 #3336 #3364 #3377 + #3241 + #3242) with:4511c6e5;e13ccd7f, #326116f2f5c1, #3263e618b742);a343eafc, #3268527a8b26, #32694a8217a7).cargo build --release -p xcl. Also set:XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1(stands in for #2428, which does not merge onto this set).This PR in the build: the whole stack, #3250
e13ccd7f, #326116f2f5c1, #3263e618b742(the current head).Run: retail game,
XCL_PREPARE_ALL=1(all 26,503 records),XCL_RUN_SECONDS=180(ends 180 s after the title starts),XCL_ACTIVITY=1. Cold XCL cache:XCL_DXIL_CACHEpointed at a new, empty folder, so no translation, DXC output or driver blob was reused.Compared with: the same retail game and settings on 4465c886 alone (the base above, without the three PRs and without the heap switches), run earlier today with a warm cache: it started with 48,305 translations, 44,556 DXIL files and 13,051 driver blobs, and reused about half of its driver blobs.
Not tested / limits
30122062) and #3269 (nowe01151a2, with #3268 now64f666c0) have changed since, so this report is for the commits listed above.Hardware: NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1.
Tool and model: Claude Code (Claude Opus 5.5): two sessions on this machine ran the queued runs; this one extracted the numbers from their logs and wrote this report.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:23Z.
Review: COMMENTED
Static review of
e618b742for the stack in the #3041 comparison.The threshold change itself looks consistent with the tested intent. It makes more wave32 shaders eligible for compaction and therefore exposes an inherited correctness issue I found in #3261. The compact liveness pass can drop a live high SGPR store across a
SAVEEXEC_B64instruction because wave32 lowering writes only the low destination. This is new review evidence for the stack carried by this PR.Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T23:25:55Z.
Thanks for the review. Your 4 points are now handled in follow-ups, since this was merged:
Plan::words()leaving out the new tables: fixed in #3475.>= 4comments: fixed in #3475.MAX_TABLE_WORDS32768 on every GPU: kept. One program in the retail title has a 16121-word plan and would fall back to the plain form at 12288. amd-dev runs 32768 by default on RDNA4. I could not measure that program's build memory on AMD; #3475 says so under Not tested.Separately, the AMD iGPU also showed that the literal table read 0 on AMD (moombathepilot's #3261 finding). That fix is #3473.
(Claude Code, Claude Opus 5.5, for Foniass)