Recompiler: decode RDNA2 instructions without hashing or scratch Vecs #1387
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!1387
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1387"
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?
@mastrr9 on GitHub · 2026-11-24 15:31 UTC · original
mastrr9:perf/rdna2-decode-no-hash→main· +297 −19 · 1 files · 1 commits · openTargets #1269 (shader translation / compilation speed).
What changed
rdna2::decoderuns once or more for every console instruction during shader translation (and across every instruction of a pack inxcl shaders). Previously it spent ~1,850 CPU instructions per decoded instruction on a bit-by-bit field extraction loop, two scratchVecheap allocations per call, and SipHash(encoding, opcode)table lookups.bits()now reads fields up to 32 bits in a single shift across up to two dwords (keeping the loop for wider widths);field_valuein the emitter benefits too.Vecs indexed by(encoding, opcode)filled in identical priority order.[u32; 2]) instead of allocating scratchVecs.Benchmark (
bench_decode, release, median of 7)cargo test -p xcl --release --lib rdna2::tests::bench_decode -- --ignored --nocapture): 54 ns / instruction across 23,812 LLVM corpus instructions (~1.7–2× faster decode vs ~112 ns baseline).Tested
2159c3bb7750e25f57e17adb81584bf628d16c72onmain930e8b4:cargo build --workspace: 0 new compiler warningscargo test --workspace -- --test-threads=4: 753 passed / 0 failed / 42 ignoredcargo test -p xcl --release --lib rdna2::tests::bench_decode -- --ignored --nocapture: passed (23812 instructions, ns per instruction (median of 7): decode 54)Regression run
Smoke run by @LocranKing in comment below: #1387
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.
main:
PR:
Tester's setup: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (
8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releaseTester's AI use: Antigravity (
Gemini 4 Neon) ran the build, tests, and smoke runs and drafted this report from the command outputs.Not tested
AI use
@Frtuchinno on GitHub · 2026-11-24 15:50 UTC · original
Test report for #1387 on an AMD host (Ryzen 5 7600, Windows):
decode123–129 → 63–65 ns per instruction; 753 passed, 0 failed, 42 ignoredThis covers the "Not tested: AMD hosts" line. The speedup reproduces on Zen 4:
decodeis about 1.9× faster, and the other decoder functions are unchanged.Tested
2159c3b, baselinemain930e8b4stable-x86_64-pc-windows-msvc, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0)cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(debug):main930e8b4: 751 passed, 0 failed, 41 ignored, 0 SKIPPED2159c3b: 753 passed, 0 failed, 42 ignored, 0 SKIPPED;decode_matches_the_hash_map_referenceandllvm_gfx10_corpuspassbench_decode(release,cargo test --release -p xcl --lib rdna2::tests::bench_decode -- --ignored --nocapture). For the baseline I copied the PR'sllvm_encodings,per_instructionandbench_decodeunchanged into the test module of amain930e8b4worktree. The two test binaries were run alternately, three times each (ns per instruction, median of 7, 23 812 instructions):decodemain → PRsgpr_usesvgpr_usesbranch_targetformatNot tested
xcl shaderstranslation timing, no smoke runAI use
@ArturoWolff on GitHub · 2026-11-24 15:51 UTC · original
Tested the decoder change inside #1269’s
lane_masks::analyze_code(&code, true), not justrdna2::decodein isolation. Same analyzer (gefydev/xcl51f977a7f29171c88307f152d529bed8bcc0d468), swapping only the decoder from930e8b49c1c2ec683d22c724a398b39111cd0e56to2159c3bb7750e25f57e17adb81584bf628d16c72.The decoder alone used 41% and 34% less CPU time respectively. Both decoders produced identical per-instruction records and every returned analyzer field matched. The join kept all seven guard sites; the mixer needed none.
Method: Ryzen 5 5600, native Linux x86-64, rustc 1.92.0,
-C opt-level=3, one codegen unit. Private CPU harness:python3 -IB measure2.pythenpython3 -IB stats.py; eight alternating A/B pairs, equal calls per pair, pinned to one hardware thread, warm inputs, measured process CPU time. No outliers removed; the mixer’s paired whole-analysis change ranged from 7.3% slower to 19.9% faster. This measures two generated programs, not total shader compilation or title loading. No DXC, GPU dispatch or full Windows suite in this test.AI use: Hermes Agent (gpt-6.2-astra) prepared and ran the harness, checked outputs and wrote this report.
@nnonno91 on GitHub · 2026-11-24 15:54 UTC · original
Windows test report and paired decoder benchmark for
2159c3bOn the Ryzen 7 9800X3D, median
decodetime fell from 112.5 to 56 ns per instruction (2.01× throughput).Tested
2159c3bb7750e25f57e17adb81584bf628d16c72,cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputpassed. Cargo reported 753 passed, 0 failed, 42 ignored, including passing decoder equivalence tests and the synthetic end-to-end title. Two GPU tests reportedSKIPPEDfor lack of native wave64 and are included in Cargo’s pass count:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.mainworktree at930e8b49c1c2ec683d22c724a398b39111cd0e56. I built each withcargo test --locked --release -p xcl --lib --no-runand rangpu::rdna2::tests::bench_decodedirectly from the two compiled test binaries with--exact --ignored --nocapture --test-threads=1. Both used the same 23,812-entry LLVM gfx10 corpus. The table shows thedecodemedian reported for each run, with the order reversed on every other pair.mainNot tested
AI use
@mastrr9 on GitHub · 2026-11-24 16:04 UTC · original
Huge thanks @Frtuchinno, @ArturoWolff, and @nnonno91 for the independent AMD Zen 4 (1.9x), RTX 5090 / 9800X3D (2.01x), and
lane_masksverification runs!@DavidM1911 on GitHub · 2026-11-24 16:55 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
@LocranKing on GitHub · 2026-11-24 17:43 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32) test and retail smoke report on clean head
2159c3bb7750e25f57e17adb81584bf628d16c72.Tested
2159c3bb7750e25f57e17adb81584bf628d16c72(clean tree, merge-base930e8b4)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 753 passed, 0 failed, 42 ignored, exit0SKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
2159c3bb7750e25f57e17adb81584bf628d16c72):Not tested: debug build, isolated decode throughput microbenchmark, AMD / native wave64 hardware, extended gameplay past 60 s.
AI use: Antigravity (
Gemini 4 Neon) ran the build, tests, and smoke runs and drafted this report from the command outputs.@Royalflamejlh on GitHub · 2026-11-24 19:16 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA test of
2159c3bonmain9e3831e+ #684: in a retail title the burst of pipeline creation after the loading screen starts (about 10,500 shaders parsed on the title's threads) took 2.9 to 5.1 s with it against 4.2 to 7.3 s without, shorter in 4 of 5 alternated pairs. Its tests pass under Wine.Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch,
VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled tox86_64-pc-windows-gnu(rustc 1.98.0), DXC 1.9.2609.5,XCL_NETWORK=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress.2159c3bmerged ontomain9e3831e+ #684 (e56dbc3) without conflicts;mainisc160d86now. The machine was busy with other work throughout (load 6 to 16 on 32 threads), so the timings are noisier than they would be alone.Tested
cargo test --release -p xcl --lib rdna2::under Wine, on the merge: 11 passed, 0 failed, 1 ignored (the benchmark). That includesbits_match_the_bitwise_referenceanddecode_matches_the_hash_map_reference.bench_decodeunder Wine, 3 runs:decode53, 55 and 52 ns per instruction.mainhas no such benchmark, so I have no figure without the change here.XCL_PSO_PRELOAD=0, caches warm. The burst is timed from its 100th[SHADER]line to its 10,400th:9e3831e+ #6842159c3bFour earlier runs of the same baseline tree today gave 4.28 to 4.62 s (two of them on a rebuilt copy of the same vkd3d-proton). All ten runs reached 60 s without a fault; one with the change then hung in XCL's shutdown and was ended by the harness.
ntdll.dllunderdxcompiler.dll. The machine had 7 to 10 GB of memory free before those two; 9 other cold starts with the change and 11 without had no fault, so I cannot tie them to the change.Read
rdna2.rs:203and:226: the two scratchVecs ofdecodeare arrays on the stack now. One allocation per instruction is left,read_wordsat:264forDecoded::words(up to 5 dwords). In the thread dumps on #688 the title's threads waited for the process heap's lock insiderdna2::decode, and a DXC worker was at the same lock from an allocation of its own; I have not taken a dump with this change, but this is the allocation they would still wait on. Would a[u32; 5]with the length do forwords?rdna2.rs:137: the one-shift path ofbitscoverscntup to 32 and reads a missing dword as 0, as the loop did. I found no field it reads differently, and the reference test agrees.Not tested: the burst with the preload on and an empty DXIL cache (5 runs were made, 2 of them beside a test suite of ours that faulted on the same card, so they do not compare); the offline pass (
xcl shaders --precompile) with and without; a quiet machine; AMD and Intel graphics.AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the tests, the benchmark and the runs, compared the logs and wrote this report.
Posted without review by a person: the account owner was away and reads replies later.
@ClosetPie107 on GitHub · 2026-11-25 17:42 UTC · original
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head
2159c3bb7750e25f57e17adb81584bf628d16c72(merged locally ontomain68a284a, clean merge).Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnu(debug)Tested (
XCL_REQUIRE_GPU=wave64,VKD3D_CONFIG=ignore_shared_fence,--test-threads=1 --nocapture)gpu::rdna2: 19 passed, 0 failed, 1 ignored (0 skipped)Not tested
bench_decodetiming, retail title smoke run, native Windows.AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.