Repository navigation
Conversation
`rdna2::decode` runs once or more for every instruction the recompiler translates (and for every instruction of a pack in `xcl shaders`). Under callgrind on the LLVM gfx10 corpus it took ~1 850 instructions per call: a bit-by-bit loop in `bits` (every field read, ~28 %), two scratch `Vec`s for the first dwords next to the one `Decoded` keeps (~17 % in malloc / free), and a SipHash lookup of (encoding, opcode) for every candidate encoding (~10 %). - `bits` reads a field of up to 32 bits (all the tables have) with one shift of the two dwords it spans; wider counts keep the old loop. Missing dwords still read as 0. This also speeds up every `field_value` call of the emitter. - The opcode tables are vectors indexed by encoding and opcode, filled in the same order (the first instruction per opcode wins, as with `entry().or_insert`), and each primary encoding keeps its OP field. - The first dwords are a `[u32; 2]` on the stack (primary encodings are 32 or 64 bits; a 32-bit one reads its second dword as 0, as the one-dword `Vec` did). The tests keep the old decoder as a reference and compare every field of the result (same instruction, encoding and table entries, dwords, length, literal, variant) or the same error on the LLVM corpus cut at every length, on every encoding of every instruction with random operand bits, literal / SDWA / DPP source codes and short buffers, and on 100 000 random instructions; `bits` is compared with the bit loop for every offset and width on short and empty dword slices. Release, median of 7 alternating runs, ns per instruction: decode on the LLVM corpus (23 812 instructions) 112 before, 66 after (1.7x); a whole `translate` of six synthetic programs (34 552 instructions, structured control flow) 91.8 ms before, 79.5 ms after (both commits of this series; this one is most of it). Assisted-by: Claude Code
|
Test report for #1387 on an AMD host (Ryzen 5 7600, Windows): This covers the "Not tested: AMD hosts" line. The speedup reproduces on Zen 4: Tested
Not tested
AI use
|
|
Tested the decoder change inside #1269’s
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, AI use: Hermes Agent (gpt-6.2-astra) prepared and ran the harness, checked outputs and wrote this report. |
Windows test report and paired decoder benchmark for
|
| Build | Decode time across six runs (ns/instruction) | Median |
|---|---|---|
main |
126, 110, 111, 114, 110, 126 | 112.5 |
| PR | 56, 60, 56, 56, 56, 55 | 56 |
Not tested
- Retail-title smoke runs and end-to-end shader compilation time.
AI use
- OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests and prepared this report.
|
Huge thanks @Frtuchinno, @ArturoWolff, and @nnonno91 for the independent AMD Zen 4 (1.9x), RTX 5090 / 9800X3D (2.01x), and |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32) test and retail smoke report on clean head Tested
Regression run PR head ( Not tested: debug build, isolated decode throughput microbenchmark, AMD / native wave64 hardware, extended gameplay past 60 s. AI use: Antigravity ( |
|
Linux (Wine + vkd3d-proton) + NVIDIA test of 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, Tested
Four 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.
Read
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 ( 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. |
Targets #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)Not tested
scripts/smoke.ps1pair (mainvs head) not run yet (marked Draft until a retail smoke pair is added).AI use