perf(shader): isolate IR allocations and preserve diagnostics #547
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!547
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-547"
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?
@tommiehansen on GitHub · 2026-12-05 02:41 UTC · original
tommiehansen:review-split/404-perf-only→main· +176 −83 · 1 files · 2 commits · merged 2026-12-05 20:08 UTCBenchmark highlights — pinned mixed-corpus replay
Linux and Windows audit, corrected head
5439540versusb581f7e. Six balanced process orders per platform.The original reported 10x regression did not reproduce on either hosted runner, including the original implementation. The corrected head retains CPU build gains; this is not proof against all heap-state regressions or a gameplay FPS measurement. Detailed historical tables below.
Review split from #404, based on current upstream main. The diff contains this one slice.
Linux shader suite: 295 passed and 2 ignored. The audit job failed the inherited launcher-switch documentation check tracked in #528.
Exact pinned CI evidence
No hardware timing or gameplay results. The original PR remains available until maintainers choose the integration order.
Post-review follow-up — 2026-12-05
Head:
54395407391a6f49ff8d666bfbd9e8e8c6f44c72.Restored main's original build iteration and per-instruction allocation lifetime while retaining effects_into and the independent unspill/IR optimizations. This follows the regression-isolation variant in Kal0s-design's review. The previously reported small-program gain and mixed-corpus regression are historical, not measurements of this head. Please repeat the full mixed-corpus replay before merging.
Fresh pinned debug/release CI started; new test and performance results must be reported at this head. Previous validation is retained at its original revision.
Independent mixed-corpus replay
Windows/Linux audit compares the pinned base
b581f7e, original split22ffc99, and corrected split5439540. It collects the existing synthetic library-test inputs on the base, then replays the same corpus with the exact two 4096-layer diamond programs in mixed and isolated processes. Six balanced process orders, full IR-result digests, and per-case build timings are recorded. The audit is independent of the old manual measurements; no real-title assets are supplied and no FPS claim is made. Results are pending.Linux mixed-corpus result (pinned audit)
Ubuntu job completed with identical IR result digests for all 691 distinct synthetic library-test inputs across all three revisions. Six balanced process orders, paired median ratios versus
b581f7e:22ffc995439540Negative values mean lower CPU build time. The reported 10x regression did not reproduce on this Linux runner, even at the original split. The corrected split retains substantial small-program gains. Windows replay is pending; these results neither reproduce the original Windows heap state nor establish gameplay FPS.
Windows mixed-corpus result (pinned audit)
Windows job completed with identical IR result digests for all 1,007 distinct synthetic inputs across all three revisions. Six balanced process orders, paired median CPU build time changes versus
b581f7e:Both Windows and Linux hosted runs pass. The original reported 10x regression did not reproduce on either hosted runner, including the original implementation, so this is not proof that the original heap-state issue cannot occur. The corrected split retains meaningful CPU gains on both systems. No gameplay FPS claim.
Standard CI raw-artifact follow-up (2026-12-05)
Both output digests identical; structurisation 95% CI −35.62% to −31.50%. Small node-probe +2.18% descriptive change is inconclusive, not established regression. Four complete ABBA blocks, eight runs per arm. Independently checked all 16 raw checkpoint revisions, per-run sample concatenation, medians and digests against results.json. The Python review gate incorrectly interprets
rounds=8(runs per arm) as eight ABBA blocks; its automatic verdict remains inconclusive pending a harness fix. The CIs above, where stated, are the Rust report's per-workload estimates. Generic software Vulkan control passed with identical SPIR-V, not activation of this PR. No physical GPU or gameplay FPS claim. Pinned CI/artifacts.@Kal0s-design on GitHub · 2026-12-05 06:34 UTC · original
Checked
22ffc99on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). Merge base isb581f7e, current main.The output side looks right to me. In
build, the block index now moves forward with the instruction (ir.rs:172), andendschecks onlyleaders[b + 1]instead of a binary search (ir.rs:208). That is only the same if no leader sits strictly between two decoded instructions.decodegives that guarantee, because every leader is a decoded offset and gfx10/mod.rs:110 rejects a branch into the middle of an instruction.effects_intokeeps the first occurrence when it dedups with the bitset (ir.rs:1967), as main'sretaindid, andindexstays belowREGSfor every register. The read list for written VGPRs now checksr_bufinstead of the growing list (ir.rs:232), so a VGPR written twice and never read would be pushed twice. Nothing ineffects_intoseems to produce that, and a check over every instruction the suite builds found no difference from main's order. The early return inunspill(ir.rs:327) is safe because withoutv_writelane_b32/v_readlane_b32parked()never matches, and main then returns empty at itsparks.iter().all(Option::is_none)check. WithVICTORY_WHY_UNSPILLset it still takes the full path, so the diagnostics stay. On the parked-lane tests in wave64_tests the WHY-UNSPILL lines were the same on both trees. The flat tables inwithout_skipsuseNONEas "no entry" (ir.rs:1060, 1211). That would only matter if a write or ans_movread heldNONE, and those are only ever phi args from a dead predecessor, which these tables never key on. So the result is the same.The
remove_trivial_phis_stepsearly return (ir.rs:1596) is a no-op for valid programs. The one change is on programs with dead blocks, whose reads keep stale ids from before the rename. Main runsfindon those and indexesreplacedout of bounds when a stale id is>= values. With no phis at all, the PR now skips that panic. With phis it still happens, which #546 fixes by pruning first.cargo test -p victory-shader --lib -- --test-threads=4(debug) gave 420 passed, 1 failed, 4 ignored, against 419/1/4 on main. The failure issize_tests::a_reused_descriptor_register_read_only_behind_its_flagon both, and it already fails on main. The only new pass is the new test, and that test also passes on main. Clippy with--lib --tests --examplesgives the same 12 warnings as main, and ir.rs is rustfmt-clean.For the output I hashed every DXIL container the test suite produces, and all 840 of 840 are byte-identical to main. I also collected the 1046 distinct
ir::buildinputs the suite uses and compared main and PR on the Debug dump of the builtProgram,operand_readsfor every instruction, andwithout_skipswithdeepfalse and true. All of it was identical, including the two inputs that fail to build (same error).Timing is where I'd like a second look. I replayed those 1046 inputs through
buildin release, interleaving main and PR over 7 rounds. On the 1044 small programs the PR is clearly faster, about 35% lower median for the whole set. The other two are the 4096-layer diamond chains fromreverse_order_diamond_chain_eliminates_trivial_phis, about 12k blocks each. With only those two loaded in the process, each built about 10% faster than main. Replayed with the rest of the corpus loaded, though, each took about 10x as long as on main, over every round and whatever order I ran them in. Since they dominate the total, the full replay came out several times slower on the PR. These timings clearly depend on heap state on both trees, because main itself took about half again as long on those two in the two-file run as in the full one. Still, the PR's 10x was steady. I bisected it to the new loop inbuild. Putting main's loop back, still callingeffects_intobut with fresh vectors per instruction, brings the big ones back to main's time. Dropping the peekable iterator beforelinkdoesn't help, and neither does allocating and freeing a list-sized vector around the loop the waynext_offsetsdid. The extra time isn't in the loop itself. It goes intolink,split_irreducibleandrename, which get byte-identical blocks on both trees (I also ruled out theremove_trivial_phis_stepsearly return insiderenamewith a separate variant). My guess is something about the short-lived per-instruction allocations the old loop made and freed, and how later stages then behave on this heap. I haven't confirmed that, so treat it as a lead and not a diagnosis. It would be worth checking whether it shows up on Linux, or on a real shader cache inside the game process. The test programs are tiny compared to real shaders.The body says this is split from #404, and that holds. The ir.rs here is #404's with only lines taken out (the pruning that went to #546). It merges cleanly with #545. With #546 it conflicts only at the end of the ir.rs tests module, where both append a test. I didn't run the Linux suite. The body's 295 passed fits the same baseline as #545 and #546 (298 each, four new tests) plus this PR's one new test. I didn't test real game shaders, a shader cache run, gameplay, or AMD and other vendors' drivers.
AI-assisted: yes
@tommiehansen on GitHub · 2026-12-05 10:18 UTC · original
Thanks @Kal0s-design for isolating the mixed-corpus regression. 5439540 restores the original build loop and per-instruction allocation lifetime, retaining the other optimizations. Six-round Linux/Windows replay shows identical IR and 31.4%/33.8% lower small-program build time, with both large CFGs also faster. Neither hosted runner reproduced the original 10x regression, so your heap-state finding remains relevant.
5439540739to13599691e0