WIP: [pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default) #142
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-preload-skip"
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?
Refs #128
Contributor role (optional)
What it changes
New switch
DARNER_PRECOMPILE_SKIP_DONE=1, off by default. With it off, nothing changes.Part of #128: a preload that starts again redoes the shader step from the start, even with every shader already stored. Most of that step goes on reading and scanning the title files, not on translating.
With the switch on:
<cache>/shaders/precompiled.txt: size, modification time, path.shader_cache::build_key(): the translator hash, the switches that change what a translation looks like, and the host limits. A list made under another key is thrown away.shaders/.clear_stale_indeletes that folder when the translator changes, so the list goes with the translations.DARNER_KEEP_OLD_SHADERSand named caches are covered by the key.Caveats:
build_keybrings up the host (the view-limit probe), which costs some time. Not measured.It does not help the cold translation after a translator change (about 2 minutes here). That is a different step of #128: keeping work across translator changes, as blazecoding2009 noted in the issue.
New public functions, additive only:
darner_gpu::shader_cache::build_keyanddarner_hle::modules::d3d12x::shader_build_key. Also a README row and a short entry indocs/findings.md.Why this is expected to help (from earlier logs of ours, switch not on): a warm-cache shader step took about 24 s for 25,770 shaders. About 17 s of that came before the first progress line, while the files before the first one holding shaders were read and scanned. The lookups took about 0.25 ms each.
So the saving is an estimate, up to about 17 s per start on this PC. It is an upper bound: the 17 s also covers the directory walk and the first 1000 lookups, and the walk still runs with the switch on. The old logs came from our own branch builds, not from this commit, and their GPU clocks were in an unknown state (the step is mostly disk and CPU). Nothing is measured with the switch on.
Spec dependence
Likely general: the code is in the launcher's preload and does not depend on the GPU. How much is saved depends on how fast the disk reads the title files. Our title drive is a SATA QLC drive, so a faster drive should save less. The numbers above are from an RTX 2070 SUPER 8 GB (Turing), driver 621.40, Resizable BAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320, Series S + DLSS Performance; the timings come from runs with GPU clocks in an unknown state. Not checked on other PCs, Series X, or Linux/Proton.
How it was tested
64729c78c(on top oftrustno1/main57dea7f23).cargo clippy --workspace --all-targets --locked -- -D warnings(gate 1): clean, at64729c78c.cargo xtask policy: ok.cargo test -p darner --bin darner --locked translate::stamps: 5 of 5 passed. That is this module only, not the workspace tests.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings) and gate 3 (cargo test --workspace --locked): not run, pending. This is why the PR is WIP.Checklist
main.docs/asset-policy.md.Checked for overlap
apps/darner/src/translate.rsandcrates/darner-gpu/src/shader_cache.rs, and PR #96 touchesshader_cache.rs; neither does this. README.md is touched by #59, #75, #110 and #118 (a different table row each, so it may need a rebase). Related issue: #128 (this is its plan point 2); #125 is related to #128 too.This change was made with AI assistance (Claude Code).
[pr-performance][startup][shaders] WIP: Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)to WIP: [pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)WIP: [pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)to [pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)Tested #142 on Windows (RTX 5080) against a GTA6 dump: build and 18 unit tests pass (5 stamps, 13 shader_cache). Bounded 180 s preloads: with
DARNER_PRECOMPILE_SKIP_DONE=1a restarted run reported '36 of 36 files skipped' and its shader phase took 0 s, versus 5 s re-reading everything with the switch off (warm cache). The 74 s first run is confounded: it populated the shared cache itself. No lock-wait lines seen, though the shader cache is shared with other builds here. Not tested: game run, full preload, pipeline warm phase, key invalidation.Drafted with AI assistance (OpenCode).
[pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)to WIP: [pr-performance][startup][shaders] Preload: skip title files whose shaders an earlier run finished (DARNER_PRECOMPILE_SKIP_DONE, off by default)Second-opinion review: hold for now. The stamp list (
shaders/precompiled.txt, keyed bybuild_key()) works for the bounded test, but three cases can leave shaders untranslated for good:contain_panic), and nothing retries those shaders.DARNER_SHADER_CACHE_DAYS, the prune deletes cache entries while the stamps stay, so the preload never translates those shaders again and they stutter in game. Clearing the list when a prune removes entries would fix it.A test of key invalidation and a full preload would be needed before merging. It conflicts with #184 (translate.rs) and #147/#140 (findings.md).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
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.