victory-shader: build the per-instruction read/write lists once (ir::build -13%) #1033
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1033
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1033/head"
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?
@pes7 on GitHub · 2026-11-24 15:14 UTC · original
pes7:perf/ir-pairs→main· +25 −25 · 1 files · 1 commits · merged 2026-11-25 21:49 UTCir::buildallocates four times per instruction for lists of two to four registers. This builds them once, for 13% off the SSA pass and 4.7% off a translation, with byte-identical output.effects()collects each instruction's register lists asVec<Reg>- two allocations - and the caller immediately maps them intoVec<(Reg, Value)>, the shape the IR wants - two more allocations - and frees the first pair. On a 26k-instruction program that is ~100k allocations and ~50k copies that nothing reads.What changes
effects(),add_regs(), themask/indexedhelpers and the branch arms push(Reg, NONE)directly, the placeholder the SSA pass fills in. Two allocations per instruction instead of four.Inst,Phiand everything downstream are untouched; the placeholder value is the sameNONEit was mapped to a line later.Measured
The bench is the one added in #1002 (
crates/victory-shader/src/emit/bench_tests.rs, synthetic GFX10 compute programs, no game data). Ten interleaved rounds per arm, best of ten, nanoseconds per instruction:ir::buildbeforegfx10::decode(105-113 ns),structure,resource,ioandlowerare unchanged, which is the check that the change did what it claims and nothing else.The bench lives in #1002 and the numbers above were measured on top of it, but this branch is only the
ir.rschange - one file, +25/-25 - and applies tomainon its own; nothing here depends on #1002 landing first.Correctness
cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.-D warnings;cargo xtask policy: 173 files ok.No game data used.
@Zipettte on GitHub · 2026-11-24 16:30 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 94cc038:
cargo test -p victory-shaderpasses, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@pes7 on GitHub · 2026-11-24 22:03 UTC · original
Rebased onto today's
main(70564ae), which conflicts onir.rs:buildbecamebuild_boundedandeffectsnow takesm0_max: Option<u8>to bound relative moves (v_movrel*). Both survive - the pairs this PR returns are still pairs, and the bound still cuts the range:Head is now
266f671.cargo test -p victory-shader --locked: 209 passed, 0 failed; both clippy configurations with-D warningspass, as doescargo xtask policy. The diff against this PR is unchanged (+25/-25, one file).@catminou4 - your approval is still shown on the PR, but the head moved because of the rebase, so re-check if you want the approval to be for this exact tree; the change itself is the same one you reviewed.
@Marvisak on GitHub · 2026-11-25 01:19 UTC · original · edited 2026-11-25 20:18 UTC
Automated triage for the maintainers.
Merge candidate. The head (
d809fb7) has not changed since the last review and still merges cleanly.effects()andadd_regs()incrates/victory-shader/src/ir.rspush(Reg, NONE)pairs directly, sobuild_boundedno longer converts eachVec<Reg>through theunsetclosure. The resulting IR is the same:NONEis the placeholder the closure added, theseen.containsdedup and them0_max-bounded indexed range are unchanged, and both functions are private to this file.Reply to the author: thanks for the corpus measurement (-3.2% wall time, output identical on all 26,084 programs). It confirms the earlier reading, so the verdict stays. #1623 is a separate decoder change and does not overlap.
CI: passing.
Generated by Claude Code
@pes7 on GitHub · 2026-11-25 16:26 UTC · original
Real corpus, same method as the note on #1002: the Xbox build's
shaders.rpf- 26 084 programs, 40 601 701 IR instructions -victory translate <shaders.rpf> --list, three binaries running at the same time on one thread each (--jobs 1) on a 32-core machine, so they share identical conditions and the control is common:mainmain940d32fd809fb7246c928So the claim holds on real programs and not only on the bench: -3.2% for the whole translation here, against the -4.7% the PR measured on synthetic programs (a real program is 1 557 instructions on average, so the SSA share is a little smaller there).
The output is identical to
mainon all 26 084 programs - every count in the summary and everyemit:/resources:line matches; only the(e.g. ...)examples differ between runs, because the thread that finishes first supplies the example.For the record, the same measurement says the earlier Fx-hasher change (#1002) is -0.3%, i.e. neutral, and I have closed it: whatever
lower's tables cost on synthetic programs, on this corpus they are not what the translation spends its time on.