[pr-performance][shaders] Hash shader cache keys without copying containers #253
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:perf-shader-cache-key-without-copy"
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?
Tested with a local Xbox build via offline shader warm-up. Gameplay and FPS were not measured.
Contributor role (optional)
What it changes
On main, each disk-cache lookup constructs a temporary buffer containing the 32-byte build fingerprint followed by the shader container. This includes cache hits. Hash the two slices in order and pass the original container directly to the translator on a miss. A regression test reads an entry written under the original concatenated key.
How it was tested
Tested revision:
f3840d73d3504c30218debfbc8795b9225447317plus this patch, Rust 1.98.1 on Windows.cargo test --locked -p darner-pipeline: 15 passed.cargo test --locked -p darner-gpu --lib shader_cache::tests: 14 passed.cargo xtask policy: 555 files passed.cargo build --locked -p darner: passed. An offlinedarner translate <title-exe> --warm all --jobs 1with an isolated cache translated 15 of 15 shaders on the first run. A second run served 15 of 15 from the cache. The executable's SHA-256 matched before and after.Changes a default: no.
A/B result for key construction: a local counting-allocator probe used the original concatenation (A) and the split-input hash (B). Both produced the same key for synthetic inputs of 0, 64, 2048 and 65536 bytes. Each size was measured once per path.
Gates run: both workspace Clippy gates passed.
cargo test --workspace --lockedfailed atwatch::tests::ask_once_by_res_splits_reservations_without_refusals(watch.rs:8614). I reproduced the same assertion on clean main using the test executable built bycargo test --locked -p darner-gpu --features record --lib, with--test-threads 12. PR #150 addresses it.The
darner-hletest executable passed 493 tests outside the sandbox with--test-threads=1, including tests which require loopback and NTFS hard links.Between the serial workspace run and a run of the
darner-shadertest executable with--skip emit:: --skip oracle64::legacy_mul_forms_are_exact, 556 shader tests passed and 17 were marked ignored. The exhaustive multiplication oracle was stopped before completion.Gameplay: offline shader warm-up only.
Shader wave sizes tested: no dedicated wave-size comparison.
Hardware dependence: the allocation probe covers CPU-side cache-key construction.
Coverage gaps: gameplay frame times and different GPUs.
Checklist
main.docs/asset-policy.md.Checked for overlap
Independent Windows build, gate, and code-read review of
4cc87e1d5(based onmainf3840d73d). Not run in-game.Environment
x86_64-pc-windows-msvc), MSVC 19.44.35230.Measured results
cargo clippy --workspace --all-targets --locked -- -D warnings): PASScargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASScargo xtask policy: PASS (asset policy: 555 files ok)cargo test --locked -p darner-pipeline: PASS (15 passed; 0 failedin 0.07 s)cargo test --locked -p darner-gpu --lib shader_cache: PASS (14 passed; 0 failedin 3.92 s, including newreads_shader_cache_entries_written_with_concatenated_keys)Code-read audit
CacheKey::from_parts(crates/darner-pipeline/src/cache.rs:22-31) streamsconverter.id().as_bytes(),[0],converter.version().to_le_bytes(), then each slice inparts(build, thencontainer) with no extra length prefixes or separators. Because BLAKE3's streamingHasher::updateis strictly associative across arbitrary chunk boundaries, the resulting hash is identical to hashing[&build[..], container].concat()(verified across BLAKE3's 1024-byte chunk boundary by the new 2048-byte regression test).Translateis private tocrates/darner-gpu/src/shader_cache.rs;Translate::convertdrops&input[32..]in lockstep withcache.convert_and_store(&key, &converter, container), andCache::convert_and_store(crates/darner-pipeline/src/cache.rs:133-135) uses the caller'skeydirectly without re-hashinginput.Verdict: PASS.
AI-assisted: yes (Gemini 4 Neon).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.