Recompiler: reuse the direct DXIL block traversal buffer #1768

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

@⁠jeroenhaentjens on GitHub · 2026-11-24 20:26 UTC · original
jeroenhaentjens:dxil/reuse-cfg-scratch → main · +42 −41 · 2 files · 1 commits · open

Direct DXIL allocated a separate successor list per block when ordering the blocks and finding dominators. Reuse a single buffer during traversal and visit edges directly when building predecessors. Block order and emitted bytes were identical in both benchmark fixtures.

Part of #1269.

What is in it

  • module.rs shares the successor buffer across DFS frames and builds block positions only for serialization. module/opt.rs uses the same successor visitor without allocating a temporary list per block.

Tested

  • Windows 11 Pro 26200, Intel i7-9750H, 32 GB RAM, NVIDIA Quadro RTX 3000 (driver 32.0.15.9706), Rust/Cargo 1.100.0 MSVC, DXC 1.9.2609.5.

  • Clean PR head 22b21db2d45af526142f4e86165e14918125fb87. cargo build --workspace --locked passed. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 reported 889 passed, 0 failed, 42 ignored in debug builds without debug symbols or incremental compilation. XCL_ADAPTER=nvidia, XCL_HEAP_WINDOWS=1. The bundled title tests passed.

  • Three tests counted as passes by Cargo returned early: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no native wave64), and pso_measurement_compiles_an_exact_synthetic_record (cache control unavailable, 0x887A002D).

  • Benchmark base b9b6ea6 vs patch tree b802bf0 (same tree as this head), with local timing and output capture on both sides. The existing synthetic long_programs_translate shader has 4,001 instructions. Across 12 paired, alternating debug runs, translation including validation had a median of 232.09 → 227.84 ms (ranges 222.41–251.61 and 216.74–242.03 ms). Both outputs were exactly 127,704 bytes and byte-identical (SHA-256 5044913c819dff245ee6e05e66847342933c3b7e8deabebf6072d3a835d8eba5).

  • Isolated Rust -O benchmark of module optimization and serialization using 5,000 consecutive diamond branches (15,001 blocks), six alternating pairs. Allocations including reallocations fell from 65,094 to 20,115. Median time was 8.22 → 5.70 ms and both bitcode outputs were identical. This measures CPU translation work.

  • Independent AMD/RADV corpus measurement by YaBulochka: base b9b6ea6 and head 22b21db, 500 shader records, three runs per side. Median wall time was 91.4 → 95.4 s, within the reported run-to-run spread; all 500 compiled on each run. This does not demonstrate an end-to-end speedup on that workload.

Regression run
Paired retail smoke runs supplied by Toons29, reproduced below verbatim from that report, not run locally: AMD Radeon RX 9070 (driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, XCL_NETWORK=0. Same title and 60-second duration; the baseline commit is on main and the PR commit matches the current head.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 22b21db2d45af526142f4e86165e14918125fb87
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

Not tested

  • No cold NVIDIA driver PSO benchmark or measured improvement in time to a playable frame. The third-party smoke run is a regression check and does not establish whether the changed direct-DXIL code ran. Native wave64 and the 42 ignored tests were not exercised locally; no XCL_SAMPLE_* inputs were supplied.

AI use

  • Codex (gpt-6.2-sol) implemented the patch, designed and ran the benchmarks and validation, and drafted this description.
  • Toons29 reports using Claude Code (Claude Opus 5.5) for the smoke runs. Codex incorporated the linked independent reports and checked their commit identities and the PR-description gate; the exact model identifier for this description update is unavailable.
**@⁠jeroenhaentjens** on GitHub · 2026-11-24 20:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1768) `jeroenhaentjens:dxil/reuse-cfg-scratch` → `main` · +42 −41 · 2 files · 1 commits · open Direct DXIL allocated a separate successor list per block when ordering the blocks and finding dominators. Reuse a single buffer during traversal and visit edges directly when building predecessors. Block order and emitted bytes were identical in both benchmark fixtures. Part of #1269. **What is in it** - `module.rs` shares the successor buffer across DFS frames and builds block positions only for serialization. `module/opt.rs` uses the same successor visitor without allocating a temporary list per block. **Tested** - Windows 11 Pro 26200, Intel i7-9750H, 32 GB RAM, NVIDIA Quadro RTX 3000 (driver 32.0.15.9706), Rust/Cargo 1.100.0 MSVC, DXC 1.9.2609.5. - Clean PR head `22b21db2d45af526142f4e86165e14918125fb87`. `cargo build --workspace --locked` passed. `cargo test --workspace --locked --no-fail-fast -- --test-threads=4` reported **889 passed, 0 failed, 42 ignored** in debug builds without debug symbols or incremental compilation. `XCL_ADAPTER=nvidia`, `XCL_HEAP_WINDOWS=1`. The bundled title tests passed. - Three tests counted as passes by Cargo returned early: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no native wave64), and `pso_measurement_compiles_an_exact_synthetic_record` (cache control unavailable, 0x887A002D). - Benchmark base `b9b6ea6` vs patch tree `b802bf0` (same tree as this head), with local timing and output capture on both sides. The existing synthetic `long_programs_translate` shader has 4,001 instructions. Across 12 paired, alternating debug runs, translation including validation had a median of **232.09 → 227.84 ms** (ranges 222.41–251.61 and 216.74–242.03 ms). Both outputs were exactly 127,704 bytes and byte-identical (SHA-256 `5044913c819dff245ee6e05e66847342933c3b7e8deabebf6072d3a835d8eba5`). - Isolated Rust `-O` benchmark of module optimization and serialization using 5,000 consecutive diamond branches (15,001 blocks), six alternating pairs. Allocations including reallocations fell from **65,094 to 20,115**. Median time was **8.22 → 5.70 ms** and both bitcode outputs were identical. This measures CPU translation work. - [Independent AMD/RADV corpus measurement by YaBulochka](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1768): base `b9b6ea6` and head `22b21db`, 500 shader records, three runs per side. Median wall time was 91.4 → 95.4 s, within the reported run-to-run spread; all 500 compiled on each run. This does **not** demonstrate an end-to-end speedup on that workload. **Regression run** [Paired retail smoke runs supplied by Toons29](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1768), reproduced below verbatim from that report, not run locally: AMD Radeon RX 9070 (driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, `XCL_NETWORK=0`. Same title and 60-second duration; the baseline commit is on main and the PR commit matches the current head. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 22b21db2d45af526142f4e86165e14918125fb87 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14814 MB ``` **Not tested** - No cold NVIDIA driver PSO benchmark or measured improvement in time to a playable frame. The third-party smoke run is a regression check and does not establish whether the changed direct-DXIL code ran. Native wave64 and the 42 ignored tests were not exercised locally; no `XCL_SAMPLE_*` inputs were supplied. **AI use** - Codex (`gpt-6.2-sol`) implemented the patch, designed and ran the benchmarks and validation, and drafted this description. - Toons29 reports using Claude Code (Claude Opus 5.5) for the smoke runs. Codex incorporated the linked independent reports and checked their commit identities and the PR-description gate; the exact model identifier for this description update is unavailable.
Keep successor lists in one scratch vector and visit successor edges directly for dominators. Compute block positions only where the writer needs them. The existing traversal order and emitted bitcode are preserved.

Assisted-by: Codex (gpt-6.2-sol)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:21 +00:00
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-24 21:08 UTC · original

AMD/RADV check of this change: on this machine it is within run-to-run noise - no measurable win, no regression.

GPU RX 7600 XT (RDNA3), radv as reported by the title runs on this box
OS Linux, Wine 11.22, x86_64-pc-windows-gnu, release
Input retail shaders.rpf, 411,695,600 B, 26,503 records
Mode xcl shaders <pack> --compile 500 --json, XCL_DIRECT_DXIL=1, no title run, no adapter work

Three interleaved runs per side, same pack, same flags:

base b9b6ea6 PR 22b21db
wall 88.9 / 91.4 / 96.2 s 93.5 / 95.4 / 96.3 s
median 0.48 / 0.53 / 0.54 s 0.47 / 0.50 / 0.55 s
p90 3.08 / 3.37 / 3.66 s 3.46 / 3.48 / 3.87 s
max 9.6 / 12.2 / 15.7 s 11.1 / 14.2 / 18.1 s
sum (CPU) 568 / 614 / 648 s 632 / 644 / 659 s

Reading: the medians favour the PR by about 5% (0.50 vs 0.53), but the wall, the p90 and the CPU sum do not, and the spread across three runs on one side (88.9-96.2 s) is larger than the difference between the sides (91.4 vs 95.4). So on AMD/RADV this is not a measured improvement - it is consistent with "no cost", which is still worth knowing since the buffer reuse only touches walk order.

If it helps, the number that dominates here is not the traversal but the biggest shaders: the PedTransformSkin family at 7-9 s and ~1 MB HLSL each, which is the same shape I reported in #1269.

Builds: both heads built clean with cargo build --release --target x86_64-pc-windows-gnu -p xcl; dxc_compiled 500, dxc_failed empty on every run.

**@⁠YaBulochka** on GitHub · 2026-11-24 21:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1768#issuecomment-7144539739) AMD/RADV check of this change: on this machine it is within run-to-run noise - no measurable win, no regression. | | | |---|---| | GPU | RX 7600 XT (RDNA3), radv as reported by the title runs on this box | | OS | Linux, Wine 11.22, `x86_64-pc-windows-gnu`, release | | Input | retail `shaders.rpf`, 411,695,600 B, 26,503 records | | Mode | `xcl shaders <pack> --compile 500 --json`, `XCL_DIRECT_DXIL=1`, no title run, no adapter work | Three interleaved runs per side, same pack, same flags: | | base `b9b6ea6` | PR `22b21db` | |---|---|---| | wall | 88.9 / 91.4 / 96.2 s | 93.5 / 95.4 / 96.3 s | | median | 0.48 / 0.53 / 0.54 s | 0.47 / 0.50 / 0.55 s | | p90 | 3.08 / 3.37 / 3.66 s | 3.46 / 3.48 / 3.87 s | | max | 9.6 / 12.2 / 15.7 s | 11.1 / 14.2 / 18.1 s | | sum (CPU) | 568 / 614 / 648 s | 632 / 644 / 659 s | Reading: the medians favour the PR by about 5% (0.50 vs 0.53), but the wall, the p90 and the CPU sum do not, and the spread across three runs on one side (88.9-96.2 s) is larger than the difference between the sides (91.4 vs 95.4). So on AMD/RADV this is not a measured improvement - it is consistent with "no cost", which is still worth knowing since the buffer reuse only touches walk order. If it helps, the number that dominates here is not the traversal but the biggest shaders: the `PedTransformSkin` family at 7-9 s and ~1 MB HLSL each, which is the same shape I reported in #1269. Builds: both heads built clean with `cargo build --release --target x86_64-pc-windows-gnu -p xcl`; `dxc_compiled` 500, `dxc_failed` empty on every run.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:36 UTC · original

Regression run of 22b21db2 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 22b21db2d45af526142f4e86165e14918125fb87
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/1768#issuecomment-7152077031) Regression run of `22b21db2` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 22b21db2d45af526142f4e86165e14918125fb87 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14814 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-25 16:46 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head 22b21db (on its base b9b6ea6).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 888 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 889 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 06c9f55 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-25 16:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1768#issuecomment-7168503458) Full-suite run, since this PR has no test report yet. Tested exact head `22b21db` (on its base `b9b6ea6`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **888 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - No new `#[test]` functions in the diff. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **889 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `06c9f55` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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