Avoid shader container copies on warm cache hits #4865
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4865
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4864"
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?
@VazirAPI on GitHub · 2026-12-01 12:03 UTC · original
VazirAPI:perf/shader-cache-input→main· +40 −3 · 2 files · 1 commits · openWhat it changes
Every shader-cache lookup first allocated and copied the build fingerprint and the entire shader container into a joined input buffer, including validated warm hits. Hash the two borrowed slices directly and allocate contiguous converter input only after a miss.
CacheKey::new_partsproduces exactly the same hash asCacheKey::newover the concatenated input. Existing keys, cache format and translator fingerprint stay unchanged. Translation, corruption handling, cache-write failures and miss publication retain their existing paths. This removes one container-sized temporary allocation and copy per warm lookup; it does not remove hashing or decoded-output allocations.How it was tested
Tested commit:
44e5288ce1ee94c0140169abce3a37e7a73c490d(same tree as the final local checks).GPU and profile: CPU-only synthetic cache inputs on Windows 11; no game files, game run or FPS measurement.
Toolchain: pinned Rust 1.98.1, native
x86_64-pc-windows-gnuwith MinGW. MSVC and upstream CI are not claimed here.Before: added borrowed-input API tests failed to compile because the API was absent.
After:
cargo test -p victory-pipeline --locked --offline: 17 passed, 0 failed. Tests cover chunk boundaries including empty chunks, BLAKE3 block/chunk edges, converter versioning, and locating an entry written from contiguous input.cargo test -p victory-gpu --lib --locked --offline shader_cache::tests: 12 passed, 0 failed. These cover warm hits, translation failures, damaged/truncated entries, write failures and linked/masked key variants.The chunk-boundary test also pins a digest obtained by compiling the unchanged
CacheKeyimplementation from main5fabb46e, so compatibility does not rely only on comparing the two new API paths.Release key-generation microbenchmark on i7-13620H (median of 9 batches of 32 calls):
Compared
CacheKey::new(converter, &[build, container].concat())withCacheKey::new_parts(converter, &[build, container]), checking equal keys. Allocation counted through a forwarding system allocator. This measures only key generation, not disk reads, complete cache lookups, startup time or FPS. Larger inputs demonstrate allocation scaling; they are synthetic, not a measured distribution of game shaders.For shader changes, wave sizes tested: no GPU shader dispatch; emitted shaders are unchanged.
cargo testpassed for the crates it touches: full pipeline suite yes; focused GPU shader-cache tests yes. The full GPU/workspace suites were not completed locally; no full-suite pass is claimed.cargo clippy --workspace --all-targets --all-features --locked --offline -- -D warnings: stops at the same five existing findings on clean main5fabb46eand this commit, compared by diagnostic and location:font.rs:213,260(argument counts),menu.rs:667(is-multiple-of),panel.rs:602,668(collapsible if). Existing repair #4680 covers them; no unrelated fixes are bundled here.cargo xtask policy --staged: 2 files OK.git diff --cached --check: passed.Checked for overlap
CacheKeyparts and concatenation; inspected the open-PR file listing. Related: #2072 shares same-key cold misses through a gate, but still constructs contiguous input; this change only avoids the warm-hit input copy. #1012 and #636 change cache fallback/integrity behavior and retain the joined input. Cache-key configuration work and stale-key-test repairs are separate concerns. No competing implementation of borrowed-part cache hashing was found.AI-assisted implementation and review with OpenAI Codex.
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.