Scripts: run the compile-time benchmark and compare two runs (#1269) #2096

Open
BetterJdue wants to merge 6 commits from upstream-pr/2106 into main
BetterJdue commented 2026-11-25 04:25:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BetterJdue on 2026-11-25T04:25:44Z.


Stacked on #2100 (itself stacked on #1763); only the top three commits belong here: dae9b63, 7d3f7f6, 61dd6dc.

A script to run the compile-time benchmark of #2100 and one to compare two runs, plus a set of only the large programs and a summary ranked by DXC time, so the slow tail shows next to the median. Scripts and tests only: nothing in crates/xcl/src. 6 files changed, 431 insertions(+), 12 deletions(-), a little over the 400-line target; the large set (7d3f7f6) can go to a PR of its own if that is preferred.

Part of #1269

What is in it

  • scripts/compile_bench.ps1 (dae9b63): builds release and runs the benchmark one compile at a time (-Set full|large|small, -Reps, -DxcArgs); writes the JSON, CSV and log to target\compile_bench\<commit> and warns when the tree has uncommitted changes.
  • scripts/compile_bench_compare.py and its test (dae9b63, 61dd6dc): compares two runs program by program (sizes, median DXC time, head / base ratio, geometric mean), says when the two environments make the times incomparable, and marks any size change and any time change beyond the run-to-run noise (5 % unless --noise says otherwise).
  • crates/xcl/tests/compile_bench/measure.rs, main.rs (7d3f7f6): XCL_COMPILE_BENCH=large, 18 programs (base, divergent and resource programs at 8 000, 20 000 and 40 000 operations, native wave64 with 1 memory window and split wave64 with 4); every run prints the programs slowest first and a summary (median, nearest-rank p90, maximum, total, the slowest tenth's share), which also goes into the JSON.
  • README.md: a paragraph under the tests.

Tested

  • AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003; Ryzen 5 3600; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; Python 3.15.2.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 61dd6dc (debug): 764 passed, 3 failed, 41 ignored. The failures are not from this PR: placed_title_textures_share_vram_and_preserve_pixels, transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory, the same RDNA2 texture failure and its two lock-poisoning followers as in #2100. SKIPPED: none.
  • The compile_bench tests in that run: 16 passed, 0 failed. python -I -m unittest discover -s scripts -p "test_compile_bench_compare.py": 8 tests, OK.
  • Negative control: four changes to the summary and the ranking (the p90 index, the size of the slowest tenth, the order, the summary left out of the JSON; made on 1297b3d's copy of these files, which is the same code) and three to the comparison (the noise ignored, the size check dropped, --noise not passed on) each make a test fail.
  • compile_bench.ps1 -Set large, release, 3 compiles per program, on 1297b3d: the same benchmark code as dae9b63 and 7d3f7f6, but on a newer main (4178e88) whose recompiler emits different HLSL than this PR's base, so these numbers show the shape of the tail, not this head's values: 18 programs, DXC median 24.8 s, p90 155.6 s, maximum 497.5 s (divergent-40000-split-4win: 26.6 MB of HLSL, 33.3 MB of DXIL); the 2 slowest take 47 % of the 1385 s.
  • The noise behind the 5 %: compile_bench.ps1 -Set small (6 programs of 0.1 to 0.25 s) 5 times on 7d3f7f6, the programs' median DXC times moved by at most 1.9 %; within one full-set run (ae43075, 3df53eb) the 3 compiles of a program spread by 2.8 and 1.4 % (median), single compiles by up to 17 %. 5 % is a margin chosen above that, not a measured bound.

Not tested

  • Game data and scripts/smoke.ps1: none used; scripts and tests only.
  • The large set on this head, and a second full-set run on one commit: not run, because I limit unattended runs to programs of up to about 8 MB of HLSL after a run was stopped for low memory.
  • Other machines and DXC versions.
  • NVIDIA and Intel; macOS and Linux (not built).

AI use

  • Claude Code (Claude Opus 5.5) wrote the scripts, the tests and this description, and ran the tests and the measurements. Prepared under human supervision: I direct this work and approve every change and comment before it is published.
<!-- greyfinch-sync:ivall/xcl:issue:5485157723 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106). Originally posted by [BetterJdue](https://github.com/BetterJdue) on 2026-11-25T04:25:44Z. --- Stacked on #2100 (itself stacked on #1763); only the top three commits belong here: `dae9b63`, `7d3f7f6`, `61dd6dc`. A script to run the compile-time benchmark of #2100 and one to compare two runs, plus a set of only the large programs and a summary ranked by DXC time, so the slow tail shows next to the median. Scripts and tests only: nothing in `crates/xcl/src`. 6 files changed, 431 insertions(+), 12 deletions(-), a little over the 400-line target; the large set (`7d3f7f6`) can go to a PR of its own if that is preferred. Part of #1269 **What is in it** - `scripts/compile_bench.ps1` (`dae9b63`): builds release and runs the benchmark one compile at a time (`-Set full|large|small`, `-Reps`, `-DxcArgs`); writes the JSON, CSV and log to `target\compile_bench\<commit>` and warns when the tree has uncommitted changes. - `scripts/compile_bench_compare.py` and its test (`dae9b63`, `61dd6dc`): compares two runs program by program (sizes, median DXC time, head / base ratio, geometric mean), says when the two environments make the times incomparable, and marks any size change and any time change beyond the run-to-run noise (5 % unless `--noise` says otherwise). - `crates/xcl/tests/compile_bench/measure.rs`, `main.rs` (`7d3f7f6`): `XCL_COMPILE_BENCH=large`, 18 programs (base, divergent and resource programs at 8 000, 20 000 and 40 000 operations, native wave64 with 1 memory window and split wave64 with 4); every run prints the programs slowest first and a summary (median, nearest-rank p90, maximum, total, the slowest tenth's share), which also goes into the JSON. - `README.md`: a paragraph under the tests. **Tested** - AMD Radeon RX 6700 (RDNA2), driver 32.0.21045.29003; Ryzen 5 3600; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; Python 3.15.2. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `61dd6dc` (debug): 764 passed, 3 failed, 41 ignored. The failures are not from this PR: `placed_title_textures_share_vram_and_preserve_pixels`, `transitions_apply_when_their_list_is_submitted`, `d32s8_targets_take_their_own_size_of_video_memory`, the same RDNA2 texture failure and its two lock-poisoning followers as in #2100. SKIPPED: none. - The `compile_bench` tests in that run: 16 passed, 0 failed. `python -I -m unittest discover -s scripts -p "test_compile_bench_compare.py"`: 8 tests, OK. - Negative control: four changes to the summary and the ranking (the p90 index, the size of the slowest tenth, the order, the summary left out of the JSON; made on `1297b3d`'s copy of these files, which is the same code) and three to the comparison (the noise ignored, the size check dropped, `--noise` not passed on) each make a test fail. - `compile_bench.ps1 -Set large`, release, 3 compiles per program, on `1297b3d`: the same benchmark code as `dae9b63` and `7d3f7f6`, but on a newer `main` (`4178e88`) whose recompiler emits different HLSL than this PR's base, so these numbers show the shape of the tail, not this head's values: 18 programs, DXC median 24.8 s, p90 155.6 s, maximum 497.5 s (`divergent-40000-split-4win`: 26.6 MB of HLSL, 33.3 MB of DXIL); the 2 slowest take 47 % of the 1385 s. - The noise behind the 5 %: `compile_bench.ps1 -Set small` (6 programs of 0.1 to 0.25 s) 5 times on `7d3f7f6`, the programs' median DXC times moved by at most 1.9 %; within one full-set run (`ae43075`, `3df53eb`) the 3 compiles of a program spread by 2.8 and 1.4 % (median), single compiles by up to 17 %. 5 % is a margin chosen above that, not a measured bound. **Not tested** - Game data and `scripts/smoke.ps1`: none used; scripts and tests only. - The large set on this head, and a second full-set run on one commit: not run, because I limit unattended runs to programs of up to about 8 MB of HLSL after a run was stopped for low memory. - Other machines and DXC versions. - NVIDIA and Intel; macOS and Linux (not built). **AI use** - Claude Code (Claude Opus 5.5) wrote the scripts, the tests and this description, and ran the tests and the measurements. Prepared under human supervision: I direct this work and approve every change and comment before it is published.
DavidM1911 commented 2026-11-25 06:06:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:02:43Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7154384618 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106#issuecomment-7154384618). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T06:02:43Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
RavenCurseBurg commented 2026-11-25 12:06:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T11:43:07Z.


Tested 61dd6dcfe80e40dda56573876cc71612949b8a2a on Windows 11 24H2 (26100.9711), i7-13700, Python 3.14.3.

Tested

  • python -B -m unittest discover -s scripts -p test_compile_bench_compare.py passed all 8 tests (0 failures, 0 skips).
  • Through scripts/compile_bench_compare.py, I compared two synthetic JSON reports for the same program on an identical recorded environment. Changing only the head row's dxc_args from -O1 to -O3 produced byte-identical text. Changing its synthetic median from 10 ms to 5 ms then printed DXC time 0.500 without a settings note. Changing the profile from release to debug did produce a note. The timing values are fixture inputs.
  • I tested a follow-up commit based on this head that counts shared programs with different DXC arguments and prints that count beside the environment notes. Its new assertion failed on the original head. All 9 comparator tests pass with the patch, and the same CLI case now identifies the settings difference.

Not tested

DXC compilation, actual shader performance, Rust/GPU workspace tests or retail data.

AI use

OpenAI Codex (GPT-6) ran the tests, wrote the synthetic comparison and follow-up patch, and prepared this report.

Follow-up on the review at 61dd6dcfe80e. Tested candidate 6c7bfd018. The existing Rust benchmark prints a completion line after both report writes succeed. The wrapper now checks the current invocation’s captured output for that line and verifies that the JSON exists. On Windows PowerShell 5.1 and PowerShell 7 the original wrapper returned 0 on a skipped rerun with an old report. The candidate returned 1 and preserved those bytes. A run that wrote new artifacts returned 0, and Cargo status 37 propagated. I used a native command stand-in with real Cargo excluded from the child PATH. All 18 script tests passed.

Command on the candidate: python -B -m unittest discover -s scripts -p "test_*.py". Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.

<!-- greyfinch-sync:ivall/xcl:comment:7161408628 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106#issuecomment-7161408628). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T11:43:07Z. --- Tested `61dd6dcfe80e40dda56573876cc71612949b8a2a` on Windows 11 24H2 (26100.9711), i7-13700, Python 3.14.3. **Tested** - `python -B -m unittest discover -s scripts -p test_compile_bench_compare.py` passed all 8 tests (0 failures, 0 skips). - Through `scripts/compile_bench_compare.py`, I compared two synthetic JSON reports for the same program on an identical recorded environment. Changing only the head row's `dxc_args` from `-O1` to `-O3` produced byte-identical text. Changing its synthetic median from 10 ms to 5 ms then printed `DXC time 0.500` without a settings note. Changing the profile from release to debug did produce a note. The timing values are fixture inputs. - I tested a [follow-up commit based on this head](https://github.com/RavenCurseBurg/xcl/commit/1c857055b880054b06c25389bf902e79ebf1ac4c) that counts shared programs with different DXC arguments and prints that count beside the environment notes. Its new assertion failed on the original head. All 9 comparator tests pass with the patch, and the same CLI case now identifies the settings difference. **Not tested** DXC compilation, actual shader performance, Rust/GPU workspace tests or retail data. **AI use** OpenAI Codex (GPT-6) ran the tests, wrote the synthetic comparison and follow-up patch, and prepared this report. Follow-up on [the review](https://github.com/xcl-dev/xcl/pull/2106#pullrequestreview-6071991753) at `61dd6dcfe80e`. [Tested candidate 6c7bfd018](https://github.com/RavenCurseBurg/xcl/commit/6c7bfd01831ca43abf1be89eddac02630da36912). The existing Rust benchmark prints a completion line after both report writes succeed. The wrapper now checks the current invocation’s captured output for that line and verifies that the JSON exists. On Windows PowerShell 5.1 and PowerShell 7 the original wrapper returned 0 on a skipped rerun with an old report. The candidate returned 1 and preserved those bytes. A run that wrote new artifacts returned 0, and Cargo status 37 propagated. I used a native command stand-in with real Cargo excluded from the child PATH. All 18 script tests passed. Command on the candidate: `python -B -m unittest discover -s scripts -p "test_*.py"`. Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.
luckyteagirl commented 2026-11-26 09:59:20 +00:00 (Migrated from github.com)

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

Review: COMMENTED


On 61dd6dc, the wrapper treats mere existence of compile_bench.json in its commit-named output directory as proof that this run produced a report. A rerun can reuse that directory. I reproduced a successful-but-skipped stand-in Cargo run that printed test skipped: no DXC and emitted no JSON: with a previous compile_bench.json seeded in the output directory, the script exited 0 and left the stale report untouched; with the same stub and no seeded file, it exited 1 with the no-report warning. A downstream comparison can therefore label old measurements as the current run.

Could each invocation write into a fresh staging directory and publish only newly emitted artifacts (or otherwise prove the report was produced by this run)? A CPU-only fixture with a preexisting report and a successful no-output test stub should still fail while preserving the old artifact. This is an exact-head PowerShell differential; I did not run DXC or a GPU benchmark.

<!-- greyfinch-sync:ivall/xcl:review:6071991753 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106#pullrequestreview-6071991753). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T09:59:20Z. **Review:** COMMENTED --- On `61dd6dc`, the wrapper treats mere existence of `compile_bench.json` in its commit-named output directory as proof that *this* run produced a report. A rerun can reuse that directory. I reproduced a successful-but-skipped stand-in Cargo run that printed `test skipped: no DXC` and emitted no JSON: with a previous `compile_bench.json` seeded in the output directory, the script exited 0 and left the stale report untouched; with the same stub and no seeded file, it exited 1 with the no-report warning. A downstream comparison can therefore label old measurements as the current run. Could each invocation write into a fresh staging directory and publish only newly emitted artifacts (or otherwise prove the report was produced by this run)? A CPU-only fixture with a preexisting report and a successful no-output test stub should still fail while preserving the old artifact. This is an exact-head PowerShell differential; I did not run DXC or a GPU benchmark.
github-actions[bot] commented 2026-12-01 02:33:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:33:58Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298753131 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106#issuecomment-7298753131). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:33:58Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:23:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:23:43Z.


Triage (#1607) – head 61dd6dc

Stacked on #2100 (itself on #1763); only dae9b63, 7d3f7f6 and 61dd6dc belong here (compile_bench.ps1, compile_bench_compare.py and its test, the large set and the summary). The shared lines with #2100 and #1763 are the stack, not a duplicate.
No problems found in the diff. It conflicts with main and is over the 400-line target, as its description says.
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:7304003330 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2106#issuecomment-7304003330). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:23:43Z. --- **Triage (#1607)** – head 61dd6dc Stacked on #2100 (itself on #1763); only dae9b63, 7d3f7f6 and 61dd6dc belong here (compile_bench.ps1, compile_bench_compare.py and its test, the large set and the summary). The shared lines with #2100 and #1763 are the stack, not a duplicate. No problems found in the diff. It conflicts with main and is over the 400-line target, as its description says. 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/2106:upstream-pr/2106'
git switch 'upstream-pr/2106'

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