Recompiler: format instruction operands without a temporary vector #1592

Open
pmilewsskiedu-gif wants to merge 1 commit from upstream-pr/1602 into main
pmilewsskiedu-gif commented 2026-11-24 18:08:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pmilewsskiedu-gif on 2026-11-24T18:08:18Z.


Part of #1269. rdna2::format formats every decoded instruction for disassembly and HLSL source comments. It previously collected all displayed operands into a temporary Vec<String> and joined them. This patch appends each operand directly to the existing output string, avoiding that vector allocation while preserving formatting and operand order.

What is in it

  • crates/xcl/src/gpu/rdna2.rs: replace the temporary operand vector and join with direct appends; one small function, no new dependencies.

Tested

  • Windows 11 Pro build 26200, AMD Ryzen 7 7700, NVIDIA GeForce RTX 4060 Ti 8 GB (driver 32.0.16.1088), Rust 1.100.0 MSVC, DXC 1.9.2602.17. Debug tests, release smoke.
  • cargo test -p xcl --lib gpu::rdna2::tests -- --test-threads=4: 9 passed, 0 failed, including LLVM gfx10 disassembly corpus.
  • cargo build --workspace then cargo test --workspace -- --test-threads=4: 776 passed, 0 failed, 41 ignored. Three GPU tests explicitly SKIPPED for unavailable native wave64 (2) or heap windows (1).
  • Two full local shader-pack scans (xcl shaders <local pack> --recomp --top 0): 26,698 shader programs and 44,422,713 decoded instructions. Main 9e3831e: 118.4/117.4 s; PR 5a976f8: 112.7/112.1 s (4.7% lower mean CLI scan time). Both translate all programs, zero errors, report 9,665.7 MB generated HLSL, with identical aggregate output except timing. Time does not measure DXC or driver pipeline compilation.

Additional ABBA scan (Nov 24, follow-up)

  • Four further sequential debug --recomp --top 0 full-pack scans on the same baseline/patch commits, alternating base / patch / patch / base: main 113.322 / 115.626 s; PR 116.163 / 112.008 s wall time. Each completed 26,698 programs, zero errors and the same aggregate outputs. Means: 114.474 vs 114.086 s (0.34% lower), smaller than run-to-run variation. This does not reliably reproduce the initial 4.7% result; treat the translation-speed benefit as uncertain until further controlled measurements.

Regression run

The following latest matched pair uses the same temporary xcl.exe path, working directory, title, and 60-second window, swapping the two release binaries sequentially and verifying SHA-256 after copying each. The repository's checker can compare these two directly. The other observed smoke results, including less favorable results, are disclosed in the table below.

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 4060 Ti
title: local Xbox title (folder name redacted)
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1523)
presents per 2 s (last 3): 53 30 0
device removals: 0
crashes: 0
peak commit: 21751 MB
xcl-smoke v1
commit: 5a976f8ea64f91b1abacf38d7b38bceca13336a6
gpu: NVIDIA GeForce RTX 4060 Ti
title: local Xbox title (folder name redacted)
seconds: 60
exit: 0x0
frames shown: 1233 (PresentX 1234)
presents per 2 s (last 3): 11 20 40
device removals: 0
crashes: 0
peak commit: 26144 MB

All other 60-second smoke runs (same title, RTX 4060 Ti; all exited 0 with zero crashes and device removals):

Setup Build Frames shown Last 3 presents / 2 s Peak commit (MB)
Separate executable paths, pair 1 Main 1,475 60 / 60 / 60 14,706
Separate executable paths, pair 1 PR 1,544 60 / 60 / 60 16,512
Separate executable paths, pair 2 Main 1,158 0 / 3 / 2 24,213
Separate executable paths, pair 2 PR 1,228 11 / 29 / 35 26,022
Shared executable path, pair 1 Main 1,405 7 / 0 / 4 23,441
Shared executable path, pair 1 PR 1,661 60 / 60 / 60 14,769
Shared executable path, pair 2 Main 1,522 53 / 30 / 0 21,751
Shared executable path, pair 2 PR 1,233 11 / 20 / 40 26,144

Executable location and cache state appear to matter substantially: the unmodified main also enters high-memory and stalled-presentation states when run from the shared location. Even under the same path, results vary strongly in both directions. The most recent matched pair meets the repository's 80% frame / 125% commit thresholds but does not establish a title runtime FPS or memory gain. The measured benefit is shader-translation scan speed.

Not tested
AMD/Intel GPUs, prolonged gameplay, controlled cold driver-cache comparisons, byte-by-byte HLSL comparison of all retail programs (decoder/disassembler corpus and full aggregate translation checks passed). Root cause of the high-memory title states is not established.

AI use
ChatGPT (GPT-6) through Chat On Steroids Core implemented the change, ran tests, full-pack scans and smoke comparisons, and wrote this description.

<!-- greyfinch-sync:ivall/xcl:issue:5477699386 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1602). Originally posted by [pmilewsskiedu-gif](https://github.com/pmilewsskiedu-gif) on 2026-11-24T18:08:18Z. --- Part of #1269. `rdna2::format` formats every decoded instruction for disassembly and HLSL source comments. It previously collected all displayed operands into a temporary `Vec<String>` and joined them. This patch appends each operand directly to the existing output string, avoiding that vector allocation while preserving formatting and operand order. **What is in it** - `crates/xcl/src/gpu/rdna2.rs`: replace the temporary operand vector and join with direct appends; one small function, no new dependencies. **Tested** - Windows 11 Pro build 26200, AMD Ryzen 7 7700, NVIDIA GeForce RTX 4060 Ti 8 GB (driver 32.0.16.1088), Rust 1.100.0 MSVC, DXC 1.9.2602.17. Debug tests, release smoke. - `cargo test -p xcl --lib gpu::rdna2::tests -- --test-threads=4`: 9 passed, 0 failed, including LLVM gfx10 disassembly corpus. - `cargo build --workspace` then `cargo test --workspace -- --test-threads=4`: **776 passed, 0 failed, 41 ignored**. Three GPU tests explicitly SKIPPED for unavailable native wave64 (2) or heap windows (1). - Two full local shader-pack scans (`xcl shaders <local pack> --recomp --top 0`): **26,698 shader programs** and **44,422,713 decoded instructions**. Main `9e3831e`: 118.4/117.4 s; PR `5a976f8`: 112.7/112.1 s (4.7% lower mean CLI scan time). Both translate all programs, zero errors, report 9,665.7 MB generated HLSL, with identical aggregate output except timing. Time does not measure DXC or driver pipeline compilation. **Additional ABBA scan (Nov 24, follow-up)** - Four further sequential debug `--recomp --top 0` full-pack scans on the same baseline/patch commits, alternating base / patch / patch / base: **main 113.322 / 115.626 s; PR 116.163 / 112.008 s** wall time. Each completed 26,698 programs, zero errors and the same aggregate outputs. Means: 114.474 vs 114.086 s (**0.34% lower**), smaller than run-to-run variation. This **does not reliably reproduce the initial 4.7% result**; treat the translation-speed benefit as uncertain until further controlled measurements. **Regression run** The following **latest matched pair** uses the same temporary `xcl.exe` path, working directory, title, and 60-second window, swapping the two release binaries sequentially and verifying SHA-256 after copying each. The repository's checker can compare these two directly. The other observed smoke results, including less favorable results, are disclosed in the table below. ```text xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 4060 Ti title: local Xbox title (folder name redacted) seconds: 60 exit: 0x0 frames shown: 1522 (PresentX 1523) presents per 2 s (last 3): 53 30 0 device removals: 0 crashes: 0 peak commit: 21751 MB ``` ```text xcl-smoke v1 commit: 5a976f8ea64f91b1abacf38d7b38bceca13336a6 gpu: NVIDIA GeForce RTX 4060 Ti title: local Xbox title (folder name redacted) seconds: 60 exit: 0x0 frames shown: 1233 (PresentX 1234) presents per 2 s (last 3): 11 20 40 device removals: 0 crashes: 0 peak commit: 26144 MB ``` **All other 60-second smoke runs** (same title, RTX 4060 Ti; all exited 0 with zero crashes and device removals): | Setup | Build | Frames shown | Last 3 presents / 2 s | Peak commit (MB) | | --- | --- | ---: | --- | ---: | | Separate executable paths, pair 1 | Main | 1,475 | 60 / 60 / 60 | 14,706 | | Separate executable paths, pair 1 | PR | 1,544 | 60 / 60 / 60 | 16,512 | | Separate executable paths, pair 2 | Main | 1,158 | 0 / 3 / 2 | 24,213 | | Separate executable paths, pair 2 | PR | 1,228 | 11 / 29 / 35 | 26,022 | | Shared executable path, pair 1 | Main | 1,405 | 7 / 0 / 4 | 23,441 | | Shared executable path, pair 1 | PR | 1,661 | 60 / 60 / 60 | 14,769 | | Shared executable path, pair 2 | Main | 1,522 | 53 / 30 / 0 | 21,751 | | Shared executable path, pair 2 | PR | 1,233 | 11 / 20 / 40 | 26,144 | Executable location and cache state appear to matter substantially: the unmodified main also enters high-memory and stalled-presentation states when run from the shared location. Even under the same path, results vary strongly in both directions. The most recent matched pair meets the repository's 80% frame / 125% commit thresholds but does **not** establish a title runtime FPS or memory gain. The measured benefit is shader-translation scan speed. **Not tested** AMD/Intel GPUs, prolonged gameplay, controlled cold driver-cache comparisons, byte-by-byte HLSL comparison of all retail programs (decoder/disassembler corpus and full aggregate translation checks passed). Root cause of the high-memory title states is not established. **AI use** ChatGPT (GPT-6) through Chat On Steroids Core implemented the change, ran tests, full-pack scans and smoke comparisons, and wrote this description.
DavidM1911 commented 2026-11-24 21:09:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:21:59Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7143434693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1602#issuecomment-7143434693). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:21:59Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Foniass commented 2026-12-01 06:14:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:14:37Z.


Triage (#1607) – head 5a976f8

No open or merged PR makes the same change. The PR conflicts with main: rdna2::format there now returns early for MIMG and chains sdwa_compare_destination(d) in front of the operands, so the loop needs to iterate that chain too after a rebase.
The rewrite keeps the output the same (first operand after a space, the rest after ", ").
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302652678 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1602#issuecomment-7302652678). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:14:37Z. --- **Triage (#1607)** – head 5a976f8 No open or merged PR makes the same change. The PR conflicts with main: `rdna2::format` there now returns early for MIMG and chains `sdwa_compare_destination(d)` in front of the operands, so the loop needs to iterate that chain too after a rebase. The rewrite keeps the output the same (first operand after a space, the rest after ", "). Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1602:upstream-pr/1602'
git switch 'upstream-pr/1602'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1602'
git switch 'upstream-pr/1602'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1602'
git switch 'upstream-pr/1602'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1602'
git switch 'main'
git merge --squash 'upstream-pr/1602'
git switch 'main'
git merge --ff-only 'upstream-pr/1602'
git switch 'main'
git merge 'upstream-pr/1602'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1592
No description provided.