Recompiler: format instruction operands without a temporary vector #1602

Open
github-bot wants to merge 1 commit from github-bot/gh-1602 into main AGit
Owner

@⁠pmilewsskiedu-gif on GitHub · 2026-11-24 18:08 UTC · original
pmilewsskiedu-gif:perf/format-operand-1269 → main · +7 −4 · 1 files · 1 commits · open

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.

**@⁠pmilewsskiedu-gif** on GitHub · 2026-11-24 18:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1602) `pmilewsskiedu-gif:perf/format-operand-1269` → `main` · +7 −4 · 1 files · 1 commits · open 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.
Append each displayed operand directly to the disassembly line. Shader translation formats every decoded instruction for its HLSL source comment; collecting operands and joining a Vec allocated on the hot path.

Assisted-by: Chat On Steroids Core (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:58 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 20:21 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-24 20:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1602#issuecomment-7143434693) 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!
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/rdna2.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1602/head:github-bot/gh-1602'
git switch 'github-bot/gh-1602'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1602'
git switch 'github-bot/gh-1602'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1602'
git switch 'github-bot/gh-1602'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1602'
git switch 'main'
git merge --squash 'github-bot/gh-1602'
git switch 'main'
git merge --ff-only 'github-bot/gh-1602'
git switch 'main'
git merge 'github-bot/gh-1602'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.