gfx10: resolve the opcode name once, at decode time (translation -4..-8%) #1180
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!1180
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1180/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 16:21 UTC · original
pes7:perf/instruction-name→main· +8 −2 · 1 files · 1 commits · merged 2026-11-25 00:21 UTCThe translator asks every instruction for its opcode name eight times, and every answer is a binary search. Resolving it once at decode time takes 4-8% off a translation.
Instruction::name()doesbinary_search_by_keyover the opcode table of its encoding. The encoding and opcode are decoded from the instruction words and never rewritten, so the answer cannot change, but five stages each ask again:ir::build,structure,resource(the most call sites by far),ioandlower. Measured with a counter inname(): exactly 8 calls per instruction, flat across program sizes.What changes
Instructioncarries the resolvedOption<&'static str>, filled where the instruction is built (decode, one construction site), andname()returns the field. Eight table searches per instruction become one.Measured
Bench from #1002 (
emit/bench_tests.rs, synthetic GFX10 compute programs, no game data), sixteen interleaved rounds per arm, best of each, nanoseconds per instruction:resourceresourceresourceresourcelowerloweriodecodepays the one search it used to be spared and grows the struct by two words (112 -> 115 ns at 16k, inside the run-to-run spread);ir::buildre-decodes internally, so it is neutral.Correctness
Instructionis built in exactly one place, so there is no second initialiser to keep in step. The emitted DXIL is byte-identical at all four sizes.cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.-D warnings;cargo xtask policyok.No game data used. Independent of #1002 and #1033 - one file, +8/-2.
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 9e5c130:
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).
@Aniseto on GitHub · 2026-11-24 18:02 UTC · original
Ran the
victory-shadercrate at9e5c130. The PR adds no test of its own (it resolves the opcode name once at decode time), so this is a regression check:Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.Same as
mainon this machine (ffe310e), so decoding behaviour is unchanged on the existing synthetic corpus. The PR claims a 4-8% translation speed-up; I did not measure timings, and with no retail shader pack here there is nothing meaningful to time.Not tested: translation timing on a retail shader pack (no game data), the title, RDNA2/RDNA4 and Intel GPUs.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the crate's tests, wrote this report; no game data was used.
@pes7 on GitHub · 2026-11-24 22:56 UTC · original
One thing to know before this is merged, because it decides the order: #1623 conflicts with this PR, not with
main. I merged my seven branches together locally to check, and #1623 (Instruction.wordsinline) and this one (opcodenamecached) touch the same two places ingfx10/mod.rs- the struct and whatdecodefills in - so the second one to land would not apply.#1623 is now stacked on this branch and carries a merge that resolves it, so merge this one first and #1623 after. Nothing in this PR changed: head is still
146dfef, +8/-2.For the record, the resolution on the other side keeps both, since they are independent wins: