Shaders: xcl shaders --heavy ranks by instruction count #1533

Open
speed-y wants to merge 1 commit from upstream-pr/1543 into main
speed-y commented 2026-11-24 17:27:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by speed-y on 2026-11-24T17:27:39Z.


Part of #1269. Campaign tooling: --heavy N ranks console programs by RDNA2 instruction count (compile-cost proxy) so measurement and DXC work can start from the heaviest shaders.

What is in it

  • xcl shaders … --heavy N in crates/xcl/src/shaders.rs (rank + distribution + JSON); help in main.rs / README.md
  • unit test heavy_ranks_programs_by_instruction_count

Tested

  • RTX 5080 (driver 621.24), Windows 10.0.26200, rustc 1.100.0, release + debug
  • .\scripts\test.ps1: 777 passed, 0 failed, 41 ignored; SKIPPED GPU: 2 (no wave64), 1 (no heap windows)
  • xcl shaders …\shaders.rpf --heavy 5 (retail pack): 26698 programs, max 88863, top50_all_cs true, ~25.5 s

Regression run
main:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5080
title: 7cf5ae7d
seconds: 60
exit: 0x0
frames shown: 1103 (PresentX 1104)
presents per 2 s (last 3): 29 38 15
device removals: 0
crashes: 0
peak commit: 21846 MB

this PR:

xcl-smoke v1
commit: 0284ec598b923028ec8950a1d16e3a30f96bd582
gpu: NVIDIA GeForce RTX 5080
title: 7cf5ae7d
seconds: 60
exit: 0x0
frames shown: 1212 (PresentX 1212)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15672 MB

Not tested

  • AMD adapters; wave64 / heap-window GPU paths (skipped on this adapter)

AI use

  • Cursor (Composer): implemented --heavy, tests, smoke, and this PR
<!-- greyfinch-sync:ivall/xcl:issue:5477097758 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543). Originally posted by [speed-y](https://github.com/speed-y) on 2026-11-24T17:27:39Z. --- Part of #1269. Campaign tooling: `--heavy N` ranks console programs by RDNA2 instruction count (compile-cost proxy) so measurement and DXC work can start from the heaviest shaders. **What is in it** - `xcl shaders … --heavy N` in `crates/xcl/src/shaders.rs` (rank + distribution + JSON); help in `main.rs` / `README.md` - unit test `heavy_ranks_programs_by_instruction_count` **Tested** - RTX 5080 (driver 621.24), Windows 10.0.26200, rustc 1.100.0, release + debug - `.\scripts\test.ps1`: 777 passed, 0 failed, 41 ignored; SKIPPED GPU: 2 (no wave64), 1 (no heap windows) - `xcl shaders …\shaders.rpf --heavy 5` (retail pack): 26698 programs, max 88863, top50_all_cs true, ~25.5 s **Regression run** main: ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 5080 title: 7cf5ae7d seconds: 60 exit: 0x0 frames shown: 1103 (PresentX 1104) presents per 2 s (last 3): 29 38 15 device removals: 0 crashes: 0 peak commit: 21846 MB ``` this PR: ``` xcl-smoke v1 commit: 0284ec598b923028ec8950a1d16e3a30f96bd582 gpu: NVIDIA GeForce RTX 5080 title: 7cf5ae7d seconds: 60 exit: 0x0 frames shown: 1212 (PresentX 1212) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15672 MB ``` **Not tested** - AMD adapters; wave64 / heap-window GPU paths (skipped on this adapter) **AI use** - Cursor (Composer): implemented `--heavy`, tests, smoke, and this PR
speed-y commented 2026-11-24 18:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by speed-y on 2026-11-24T17:27:52Z.


Part of #1269 — campaign tooling: xcl shaders --heavy N.

<!-- greyfinch-sync:ivall/xcl:comment:7139233638 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543#issuecomment-7139233638). Originally posted by [speed-y](https://github.com/speed-y) on 2026-11-24T17:27:52Z. --- Part of #1269 — campaign tooling: `xcl shaders --heavy N`.
nnonno91 commented 2026-11-24 18:09:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T17:35:25Z.


Independent AMD and CLI test of 0284ec598b923028ec8950a1d16e3a30f96bd582.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug.
  • cargo build --workspace --locked and cargo test --locked -p xcl --lib heavy_ranks_programs_by_instruction_count -- --test-threads=1 passed. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output reported 777 passed, 0 failed, 41 ignored, and one GPU skip (heap_window_out_of_memory_falls_back_to_the_switch_form, no heap windows). The bundled title test passed.
  • I generated five synthetic CS, PS, and VS programs with known counts (20,001, 8,001, 8,001, 7, and 3) and ran six xcl shaders commands with the debug binary. --heavy 3 --json agreed for a folder and a synthetic RPF9 pack, including the name-order tie, stage labels, 8,001 largest PS, three programs above 8,000, and one above 20,000. The pack’s plain-text top three matched its JSON.
  • The single-blob path counted both programs in one container. On the folder, --heavy 0 --json preserved the summary with an empty ranking and --heavy 99 --json returned all five programs, including the nested shader.

Not tested

Retail packs, retail title runs, and compile or driver cost. The synthetic counts check ranking and output formatting.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) generated the synthetic test inputs, ran the checks, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7139419011 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543#issuecomment-7139419011). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-24T17:35:25Z. --- Independent AMD and CLI test of `0284ec598b923028ec8950a1d16e3a30f96bd582`. **Tested** - Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug. - `cargo build --workspace --locked` and `cargo test --locked -p xcl --lib heavy_ranks_programs_by_instruction_count -- --test-threads=1` passed. `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output` reported 777 passed, 0 failed, 41 ignored, and one GPU skip (`heap_window_out_of_memory_falls_back_to_the_switch_form`, no heap windows). The bundled title test passed. - I generated five synthetic CS, PS, and VS programs with known counts (20,001, 8,001, 8,001, 7, and 3) and ran six `xcl shaders` commands with the debug binary. `--heavy 3 --json` agreed for a folder and a synthetic RPF9 pack, including the name-order tie, stage labels, 8,001 largest PS, three programs above 8,000, and one above 20,000. The pack’s plain-text top three matched its JSON. - The single-blob path counted both programs in one container. On the folder, `--heavy 0 --json` preserved the summary with an empty ranking and `--heavy 99 --json` returned all five programs, including the nested shader. **Not tested** Retail packs, retail title runs, and compile or driver cost. The synthetic counts check ranking and output formatting. **AI use** OpenAI Codex (GPT-6 family, exact variant unavailable) generated the synthetic test inputs, ran the checks, and drafted this report.
DavidM1911 commented 2026-11-24 21:08:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:13:01Z.


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

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

Thanks!

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

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:20:19Z.


Empirical test report (0284ec59)

Verified xcl-dev/xcl PR #1543, “Shaders: xcl shaders --heavy ranks by instruction count,” at commit 0284ec598b923028ec8950a1d16e3a30f96bd582.

Hardware / environment

  • Windows x64, OS build 10.0.26200, AMD Family 23 Model 113 Stepping 0. Cargo test profile with debug info and incremental compilation disabled.
  • rustc 1.100.0 (0ef1bc386 2026-11-09), Windows MSVC toolchain. DXC 1.9.2609.5 (01b62ad47), as reported by dxc.exe.
  • The focused test used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both Cargo commands ran outside Invoke-ArcTest.ps1 and held the Arc GPU mutex for zero time.

Commands and results

  • cargo test --workspace --no-run — exit code 0. Cargo compiled the workspace test targets.
  • cargo test -p xcl --lib shaders::tests::heavy_ranks_programs_by_instruction_count -- --exact --nocapture — exit code 0. 1 passed, 0 failed, 0 ignored, 0 skipped. Counts come from the libtest summary and lines beginning with SKIPPED, matched case-sensitively.

Observed behavior

The added unit test passed. It builds two synthetic Xbox shader containers and verifies that the ranking returns both programs, with the seven-instruction program ahead of the three-instruction program. The test exercises byte parsing and RDNA2 instruction decoding without opening a D3D12 device, compiling a shader, or loading game data.

Not tested

The full GPU workspace suite and game smoke runs were omitted. The focused test covers the ranking helper. CLI argument handling, text and JSON output, and retail shader packs were outside this run.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1543-focused.log and published.

<!-- greyfinch-sync:ivall/xcl:comment:7153674844 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543#issuecomment-7153674844). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T05:20:19Z. --- ### Empirical test report (0284ec59) Verified xcl-dev/xcl PR #1543, “Shaders: xcl shaders --heavy ranks by instruction count,” at commit `0284ec598b923028ec8950a1d16e3a30f96bd582`. **Hardware / environment** - Windows x64, OS build 10.0.26200, AMD Family 23 Model 113 Stepping 0. Cargo test profile with debug info and incremental compilation disabled. - rustc 1.100.0 (0ef1bc386 2026-11-09), Windows MSVC toolchain. DXC 1.9.2609.5 (01b62ad47), as reported by dxc.exe. - The focused test used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both Cargo commands ran outside Invoke-ArcTest.ps1 and held the Arc GPU mutex for zero time. **Commands and results** - `cargo test --workspace --no-run` — exit code 0. Cargo compiled the workspace test targets. - `cargo test -p xcl --lib shaders::tests::heavy_ranks_programs_by_instruction_count -- --exact --nocapture` — exit code 0. 1 passed, 0 failed, 0 ignored, 0 skipped. Counts come from the libtest summary and lines beginning with SKIPPED, matched case-sensitively. **Observed behavior** The added unit test passed. It builds two synthetic Xbox shader containers and verifies that the ranking returns both programs, with the seven-instruction program ahead of the three-instruction program. The test exercises byte parsing and RDNA2 instruction decoding without opening a D3D12 device, compiling a shader, or loading game data. **Not tested** The full GPU workspace suite and game smoke runs were omitted. The focused test covers the ranking helper. CLI argument handling, text and JSON output, and retail shader packs were outside this run. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1543-focused.log` and published.
luckyteagirl commented 2026-11-26 09:29:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:29:58Z.

Review: COMMENTED


On 0284ec5, the descending index for p90 is computed as ((n_prog - 1) as f64 * (1.0 - 0.9)) as usize. With 11 distinct programs ranked from 11 down to 1 instructions, 10 * (1.0 - 0.9) evaluates to 0.9999999999999998, then truncates to index 0. Both text and JSON report p90 = 11 (the maximum), whereas the formula's intended index 1 gives p90 = 10. The same boundary affects p99 with 101 programs.

Could the selected percentiles use integer arithmetic for the intended descending rank, such as (n_prog - 1) * (100 - percentile) / 100, with overflow-safe types? An 11-program fixture asserting p90 = 10 and max = 11 would catch this without changing the chosen percentile convention. I checked exact-head source and reproduced the arithmetic in Python; I did not run the XCL CLI on a synthetic pack.

<!-- greyfinch-sync:ivall/xcl:review:6071570500 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543#pullrequestreview-6071570500). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T09:29:58Z. **Review:** COMMENTED --- On `0284ec5`, the descending index for p90 is computed as `((n_prog - 1) as f64 * (1.0 - 0.9)) as usize`. With 11 distinct programs ranked from 11 down to 1 instructions, `10 * (1.0 - 0.9)` evaluates to `0.9999999999999998`, then truncates to index 0. Both text and JSON report p90 = 11 (the maximum), whereas the formula's intended index 1 gives p90 = 10. The same boundary affects p99 with 101 programs. Could the selected percentiles use integer arithmetic for the intended descending rank, such as `(n_prog - 1) * (100 - percentile) / 100`, with overflow-safe types? An 11-program fixture asserting p90 = 10 and max = 11 would catch this without changing the chosen percentile convention. I checked exact-head source and reproduced the arithmetic in Python; I did not run the XCL CLI on a synthetic pack.
Foniass commented 2026-12-01 06:03:25 +00:00 (Migrated from github.com)

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


Triage (#1607) – head 0284ec5

No open or merged PR adds an instruction-count ranking to xcl shaders; --heavy is not on main.
shaders.rs:collect_program_blobs inflates every record of the pack into memory before ranking, so peak memory grows with the pack size (fine for a CLI, worth a note). The PR conflicts with main and needs a rebase.
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:7302428301 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1543#issuecomment-7302428301). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:03:25Z. --- **Triage (#1607)** – head 0284ec5 No open or merged PR adds an instruction-count ranking to `xcl shaders`; `--heavy` is not on main. `shaders.rs:collect_program_blobs` inflates every record of the pack into memory before ranking, so peak memory grows with the pack size (fine for a CLI, worth a note). The PR conflicts with main and needs a rebase. 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/1543:upstream-pr/1543'
git switch 'upstream-pr/1543'

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/1543'
git switch 'upstream-pr/1543'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1543'
git switch 'upstream-pr/1543'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1543'
git switch 'main'
git merge --squash 'upstream-pr/1543'
git switch 'main'
git merge --ff-only 'upstream-pr/1543'
git switch 'main'
git merge 'upstream-pr/1543'
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!1533
No description provided.