Shaders: hash the translator's hot maps with the multiply-rotate hasher #2399
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!2399
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2399"
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?
@borosf on GitHub · 2026-11-25 12:51 UTC · original
borosf:vibe/translate-hot-hash-842ca5→main· +201 −76 · 8 files · 6 commits · openSummary
lower's value/PHI/bool caches,wave's section shapes,bitcode's constant and type dedup,structure's pass maps — hashed with the std default's SipHash, which profiling attributed ~10–12% of translation time.structurealready used for its atom maps, moved to a sharedhash.rs. No semantics change: iteration order converges anywhere order matters.#[ignore]d benchmark (emit::translate_bench) drives a straight-line synthetic pixel program — 10,000v_mad_f32and 250s_addk_i32, no control flow; a test asserts that exact shape (every instruction decodes under its own name, no branch opcodes, one IR block) — through ir → structure → resource → io → emit, so the stage times measure the straight-line passes only.Numbers
Interleaved A/B in release mode, the fixture identical on both sides:
structurenow genuinely measured at ~0.34–0.40 ms on this fixture.Verification
cargo test -p victory-shader --lib: 145 passed; the fixture-shape test among them.cargo clippy -p victory-shader --all-targets: identical to pristine main940d32f.cargo check --target x86_64-pc-windows-msvc -p victory-shader --all-targets: clean.cargo test --release -p victory-shader bench_translate --ignored --nocapture. No game data used.@borosf on GitHub · 2026-11-25 14:05 UTC · original
@DrDarkDK
Both points taken and fixed in
f383abd— thank you, the fixture was lying. You found the exact cause: this decoder's SOPP table numberss_cbranch_scc0as op 4 ands_branchas op 2, and my SOPK word carried the opcode at the wrong bit-field — so my "branch" word wass_cmp_eq_i32and my "back edge" both wrong-coded and unreachable, exactly as you decoded. Since the program was straight-line in fact, I took your second option: the fake control words are gone, the fixture is documented as a straight-line workload (10,000v_mad_f32+ 250s_addk_i32), and a test asserts that shape — every instruction decodes under its own name, no branch opcodes, one IR block — so it can't drift again.The structure timer now wraps the call (~0.40 ms here, matching your 0.38), and a fresh A/B with the honest fixture on both sides lands where your run did: emit 5.79 → 4.83 ms here, your 5.60 → 4.06 with an identical DXIL checksum. Stage-fair attribution to the hasher unchanged.
@Marvisak on GitHub · 2026-11-25 15:30 UTC · original · edited 2026-11-26 07:22 UTC
Automated triage for the maintainers.
Needs work (one line). Thanks for the rebase.
839ca90merges cleanly. The hasher change is mechanical:crate::hash::{HashMap, HashSet}replaces the std maps inlower.rs,wave.rs,bitcode.rsandstructure.rs, using the same Fx stepstructurealready used. It does not change the output. The std default was already randomly seeded, so nothing could depend on iteration order before either.One point from the earlier note is still open. In
emit/translate_bench.rsbench_translate, theiostage reuses the timer started beforeresource::track, soioreports resource + io. Addlet n = std::time::Instant::now();beforecrate::io::raise.I'm withdrawing the earlier
pub(crate)request.structure::Structured's public fields (masks,active,discards, ...) now have the Fx-hashed map type, sohashandFxneed to be public.CI:
checkpassing.Generated by Claude Code
@borosf on GitHub · 2026-11-25 17:15 UTC · original
Rebased onto current main (merge
fd40df1): main's new entry/join handle maps in lower join the rest as multiply-rotate maps — same hasher, same one-line-swap pattern, no behavior change. One note for the Linux side: main's new lower.rs tests reference the Windows-gated validator without cfg gating, so cargo test -p victory-shader --lib doesn't build on Linux on pristine main either (pre-existing, not from this PR); the Windows-target check is clean, and CI is green.Again, please check it out when you can :) @Marvisak
@borosf on GitHub · 2026-11-26 06:59 UTC · original
Merged current main in at
839ca90— live_edges' new Known lanes copy is kept and the Fx-hash maps follow it; translate_bench and the newly-landed census_tests coexist. CI green.@DrDarkDK on GitHub · 2026-11-25 13:13 UTC · original · requested changes
I ran
bench_translatein release mode on native Windows at7dd429c. Two details affect how I’d interpret the benchmark:structure(&p)returns. The original run printedstructure=0.00ms. Timing the call itself measured about 0.38 ms per translation.v_mad_f32instructions, but the words marked as the conditional branch and back edge decode ass_cmp_eq_i32ands_movk_i32respectively.In one local A/B against
510c2a2, emit time still fell from 5.60 ms to 4.06 ms, and the emitted DXIL had the same length and checksum. Could the benchmark move the timer before the call and either assert that the fixture contains the intended control flow or describe it as a straight-line workload?AI-assisted with Codex.
@catminou4 on GitHub · 2026-11-25 13:25 UTC · original · approved these changes
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 144 passed, 0 failed, 3 ignored (Windows-gated hardware execution tests not run here). Approving — hot translator maps hashed with the multiplexer (perf; one extra ignored test is Windows-gated).@DrDarkDK on GitHub · 2026-11-25 14:13 UTC · original · approved these changes
Rechecked
f383abdon native Windows with the Ryzen 9 7900X. The fixture test passes and confirms one IR block with 10,000v_mad_f32instructions, 250s_addk_i32instructions, and no branches. Structuring now measures 0.34–0.38 ms across the valid runs.I used the corrected fixture on both
510c2a2andf383abd, with three interleaved release runs per revision. Mean emit time fell from 5.55 ms to 3.93 ms, about 29% on this synthetic workload. The emitted DXIL had the same byte length and SHA-256 in every run.This resolves both points from my earlier review. Please update the PR description to call the fixture straight-line so it matches what the benchmark measures.
AI-assisted with Codex.
@borosf on GitHub · 2026-11-26 13:53 UTC · original
The last open point is fixed at
a19546d:let n = std::time::Instant::now();now starts theiostage beforecrate::io::raise, soiono longer reports resource + io — exactly as asked. Theresourcestage keeps its own timer, and nothing else in the bench changed.Verified on an Intel Arc B580, Windows 11:
cargo clippy -p victory-shader --all-targets -- --locked -- -D warningsclean.cargo test -p victory-shader --lib --locked -- --test-threads=1 emit::translate_bench→ the bench test passes.rustfmt --edition 2024 --checkon the touched file: one hunk, at line 66, which is the file's own pre-existing unformattedassert!— the same single hunk before and after this commit (checked against a stashed baseline), so nothing new. This tree is deliberately notcargo fmtclean.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.