Repository navigation
Conversation
catminou4
left a comment
There was a problem hiding this comment.
gfx10::Instruction.words moves from a heap Vec<u32> to an inline [u32; MAX_WORDS=5] + len, with a decode-time guard rejecting instructions longer than the budget. All call sites (fields.rs, sp3.rs, apps/victory disasm) converted to words(); the public field removal is workspace-internal. Existing gfx10 decode tests stay green on macOS (96 passed). Nice allocation win for shader-heavy paths — consider a quick cargo bench-style before/after if you have one.
e9254f2 to
72eff75
Compare
Marvisak#1180 and Marvisak#1623 both change `Instruction`, so they conflict with each other in `gfx10/mod.rs`: this branch is stacked on `perf/instruction-name` (Marvisak#1180) so that whichever lands second still applies. The two are independent in what they save and compose without a trade: `words` stays the inline `[u32; MAX_WORDS]` with `len` (Marvisak#1623), and `name` stays resolved once at decode (Marvisak#1180), so an instruction carries both and neither costs the other its win. Merge Marvisak#1180 first; this diff then shrinks to the `words` change alone.
|
Heads up before merging: this PR and #1180 conflict with each other in This branch is stacked on
The resolution keeps both wins, since they are independent: words: [u32; Instruction::MAX_WORDS],
len: u8,
/// [`name`] of `encoding` and `opcode`, resolved once at decode time.
name: Option<&'static str>,Verified on the stack: |
Translation speed (compile-storm CPU): Marvisak#1623 inline instruction words (decode -18..-45%), Marvisak#1834 VALU names without heap vector, Marvisak#1833 live-set bit walk, Marvisak#1802 relative shift bounds, Marvisak#1824 dx.op declarations once. Per-draw/per-list CPU: Marvisak#1825 view-stride table once per list, Marvisak#1826 object names only where logged, Marvisak#1800 capped-heap log spam once per 64Ki. Tooling: Marvisak#1809 list pipeline keys without cache init. Locking: Marvisak#1680 pipeline library loads without the global mutex. Held: Marvisak#1819 (2^20->2^14 loop bound) breaks transcendental convergence tests (sin/cos/exp/sqrt) — accuracy-lowering, rejected per policy.
|
Automated triage for the maintainers. Merge candidate. Re-reviewed at On your reply: confirmed, that was the one change needed. CI: Generated by Claude Code |
13eece9 to
246c928
Compare
|
Real corpus, same method as the note on #1002: the Xbox build's
-1.2% is at the bottom of the -1..-5% the PR claimed on synthetic programs, which is what one would expect: the allocation it removes is one per instruction, and decode is a small part of a translation. The output is identical to That the two PRs are -3.2% and -1.2% rather than overlapping noise is also a check on the method: they were measured in the same window as the control. |
|
Automated triage for the maintainers, second look (a review against This is right as reviewed (an instruction's words fit inline; the tests pass). It no longer builds on Push the change and it will be reviewed again. Thank you for the contribution. |
One `Vec<u32>` per instruction was one allocation and one cache miss for the dword or two most instructions have. The words live in a fixed `[u32; MAX_WORDS]` with a length now: five dwords covers the longest instruction here (an MIMG with its three extra address dwords), and the decoder refuses anything longer rather than truncating it. Decode -18..45% depending on program size; whole translation -1..5%, since decode is a small part of it. Now that Marvisak#1180 is in `main`, this applies on its own: an `Instruction` carries both the inline `words`/`len` and the cached `name`, and neither costs the other its win. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.
246c928 to
cc2a2bd
Compare
…visak#2143 added Marvisak#2143 (merged today) reads `i.machine.words.len()` in `code_table_start`, and this branch made `words` an inline array behind an accessor, so the two textually disjoint hunks do not build together. The accessor returns the slice, so `.len()` is the same number; no behaviour change.
|
Rebased onto today's No other file needed a change: the rest of the branch applies as it was. |
…nline instead of in a heap vector (decode -18..-45%, translation -1..-5%) # Conflicts: # crates/victory-shader/src/gfx10/mod.rs
…gh words() Marvisak#1623 makes `Instruction::words` an inline `[u32; 5]` read through `words()`. The branch's far-jump test helper in `gfx10/mod.rs` still took `words.len()`, which now compiles but is always 5, so it stepped over the wrong number of bytes and could report overlaps that are not there. It now uses `words().len()`, the instruction's real length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fuzeofficlal
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC):
cargo test --locked -p victory-shader --lib gfx10::— 16 passed, 0 failedcargo test --locked -p victory-shader --lib emit::lower::tests::the_code_table_starts_after_the_instructions— 1 passed, 0 failedcargo test --locked -p victory— 18 passed, 0 failed (14 unit + 4 integration)cargo clippy --locked -p victory-shader -p victory --all-targets -- -D warnings(default and--all-features) — 0 warningscargo xtask policy— ok (191 files ok)
Review notes
- Verified all decoder branches in
instruction(): every supported encoding produces 1-5 words (MIMG maxes out at 5), and thelen > Instruction::MAX_WORDSguard prevents silent truncation or lossylen as u8conversion. - Heads-up for combining with #2012: if #2012 merges before this PR (or vice versa),
decode_alignedingfx10/mod.rsuses.words.len(), which would still compile against the private[u32; 5]array inside the same module and silently evaluate to5instead ofwords().len(). - Minor non-blocking formatting nit:
crates/victory-shader/src/gfx10/mod.rs:137(control) exceeds therustfmtline width after switching towords().len().
|
A silent conflict between this PR and #2012, found while merging all
Each PR is correct on its own and both merge cleanly into Whichever of the two lands second needs that two-line change. Reference commit on the integration branch: neonbyte1@17c7845dd (merge resolution only). Measured with CPU tests under Wine on Linux; no game data involved. AI-assisted (Claude); measured on my machine, no game data shared. |
Every GFX10 instruction owns a heap vector for its one or two dwords. They fit inline - the longest instruction here is five dwords - which takes 18-45% off
decodeand 1-5% off a whole translation, with byte-identical output.Instruction::words: Vec<u32>is built withcollect()in the decoder, so every decoded instruction makes one allocation for one to five words of data, and reads them back through a pointer. #1002's counter put it at 1.17 allocations and 149 bytes per instruction - the single largest allocation source in decode.What changes
words: [u32; Instruction::MAX_WORDS]pluslen: u8, andwords()returns the slice.MAX_WORDSis 5 because that is the longest instruction the decoder produces: an MIMG with its three extra address dwords (2 + ((w >> 1) & 3)); VOP3/VOP3P with a literal is 3, everything else 2 or 1. A longer instruction is now a cleanIsaerror rather than a silent truncation.The struct does not grow:
Vecis 24 bytes,[u32; 5]+u8+ padding is 24.Call sites move from the field to the accessor (8 in
gfx10/mod.rs, 1 insp3.rs, 2 infields.rs).Measured
Bench from #1002, standalone against
mainffe310e(not stacked on the other PRs), twelve interleaved rounds per arm, best of each, nanoseconds per instruction:decodebeforeHonest about the shape:
decodeitself is 18-45% faster, but the whole translation is 1.2-5.1%, and the gain shrinks with program size - at 16 k instructions it is inside the run-to-run spread of this machine. What it buys beyond the CPU time is one allocation and one indirection per instruction gone.Applied on top of #1002 + #1033 + #1180 the same change measured 0.929-0.957 of the translation, because the per-instruction constant those three leave behind is smaller and the removed allocation is a larger share of it. Both numbers are real; this one is the one that stands alone.
Correctness
cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.-D warnings;cargo xtask policy.No game data used. Four files, +38/-16; independent of #1002, #1033, #1180 and #1556.
What it gives (to decide the merge): an instruction's words are kept inline (
[u32; 5]) instead of in a heap vector: decode -18..-45 %, translation -1..-5 % (the numbers in the description).State: MERGEABLE, CI
checkgreen, rebased onto today'smain(f3578e3).Risk: rebased for #2143 (
words().len()through the accessor); 302victory-shadertests pass.