Recompiler: reuse the direct DXIL block traversal buffer #1758
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1768"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-11-24T20:26:11Z.
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.rsshares the successor buffer across DFS frames and builds block positions only for serialization.module/opt.rsuses 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 --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4reported 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_maskandgpu_wave32_program_in_wave64_hardware(no native wave64), andpso_measurement_compiles_an_exact_synthetic_record(cache control unavailable, 0x887A002D).Benchmark base
b9b6ea6vs patch treeb802bf0(same tree as this head), with local timing and output capture on both sides. The existing syntheticlong_programs_translateshader 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-2565044913c819dff245ee6e05e66847342933c3b7e8deabebf6072d3a835d8eba5).Isolated Rust
-Obenchmark 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
b9b6ea6and head22b21db, 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.Not tested
XCL_SAMPLE_*inputs were supplied.AI use
gpt-6.2-sol) implemented the patch, designed and ran the benchmarks and validation, and drafted this description.Imported from ivall/xcl. Originally posted by YaBulochka on 2026-11-24T21:08:53Z.
AMD/RADV check of this change: on this machine it is within run-to-run noise - no measurable win, no regression.
x86_64-pc-windows-gnu, releaseshaders.rpf, 411,695,600 B, 26,503 recordsxcl shaders <pack> --compile 500 --json,XCL_DIRECT_DXIL=1, no title run, no adapter workThree interleaved runs per side, same pack, same flags:
b9b6ea622b21dbReading: 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
PedTransformSkinfamily 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_compiled500,dxc_failedempty on every run.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:36:44Z.
Regression run of
22b21db2on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.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.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T16:46:11Z.
Full-suite run, since this PR has no test report yet. Tested exact head
22b21db(on its baseb9b6ea6).Tested
cargo build --workspace, thenXCL_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.#[test]functions in the diff.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).--skipleaves out tests that fail on main06c9f55too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:17:45Z.
merge-check claim
head:
22b21db2d4Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:32:07Z.
merge-check
base:
6089122ahead:
22b21db2d4merge: clean
build: cargo build --workspace -> FAILED (12 x E0599)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> not run (the merge result does not build); base alone: 1465 passed, 0 failed, 47 ignored
review: blocking: merged onto current main it does not compile, although GitHub shows no conflict. The PR deletes Module::successors and Module::block_layout; main has since gained callers in gpu/dxil/module/opt.rs and module/split.rs that the PR does not touch: 12 errors E0599 ("no method named block_layout / successors"), the first at opt.rs:634. The PR's own CI is green because it ran on the older base. The logic itself reads equivalent to the old code (same visiting order).
performance: opt-in direct-DXIL path, translation time only, fewer allocations (reasoned).
verdict: not yet: rebase onto current main and move the new callers to block_order / for_each_successor; I will rerun the suite on the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T00:18:49Z.
merge-check claim
head:
22b21db2d4Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T00:28:15Z.
merge-check
base:
2c717a043chead:
22b21db2d4merge: clean (no textual conflicts)
build: cargo build --workspace -> failed: 12 errors, first error[E0599] no method named
block_layoutfound for&mut Moduleat crates/xcl/src/gpu/dxil/module/opt.rs:634 (also opt.rs:717, andsuccessorsat opt.rs:755).mainadded these callers after this PR's base; the PR renamesblock_layout()toblock_order()and replacessuccessors()withfor_each_successor().tests: not run (the merge does not build)
review: the whole diff was read (module.rs block_order / for_each_successor, opt.rs). On its own it keeps the old block order (each DFS frame sorts its own tail of the shared successor buffer, descending, and pops from the end); the only problem found is the build break above, against the callers
maingained.performance: reasoned, not measured: shader translation only; no runtime cost per frame.
verdict: not yet: build fails on the merge (rebase onto main and move the new opt.rs callers to block_order() / for_each_successor())
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc; trial merge 6a24ccc94689aef5be51e52a076d147307e4e7e7 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:43:19Z.
Triage (#1607) – head
22b21dbNo open or merged PR changes
block_layoutorsuccessorsingpu/dxil/module.rs. #1860 changes howoptimizecallsblock_layout, so the two will conflict.No problems found in the diff. With the shared successor buffer, each DFS frame still pops only its own tail, so the order is the same as before.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.