WIP: [pr-feature][startup][shaders] Preload window: share its mark across darner.exe copies with the same translator, card and driver (DARNER_WARM_SHARED, off by default) #153
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-preload-marks-shared"
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
Step 4 of #128 (the done marks keep the exe's bytes, so every new build or copy opens the preload window again). Steps so far: #140 (remember an unfinished preload), #142 (skip title files an earlier run finished); step 3 (separate draft).
With
DARNER_WARM_SHARED=1(off by default; the switch already exists fordarner warm --used), the start's preload mark iswarmed/shared-<first 16 hex of blake3(translator id, card, driver)>instead ofwarmed/<first 16 hex of blake3 of darner.exe>. A second build or copy of darner.exe with the same translator, card and driver then does not open the preload window.warmup_mark) and the mark a finished preload writes (preload_mark) use the shared file. They were one file before, so there is no way to share one and not the other without writing two files.needs_pipelines) still opens the window when the library is empty.warm-done.txt) keep the exe path, as before.pub fn adapter_driver()incrates/darner-shader/src/emit/host.rs: the driver version asCheckInterfaceSupportgives it (0 if unknown). Its doc comment namesHost::driver(crates/darner-gpu/src/host.rs:2511), whichpipeline/known.rs:447and:462hash into the warm marks. Both takehardware_adapter(); they differ only if device creation on it fails and the host falls back to the default adapter (host.rs:2353).shared_marks()reads only the start's settings (darner-settings.txtor--set).prepareclears everyDARNER_*variable that is not inKEPT, so an environment-onlyDARNER_WARM_SHAREDused to make the window mark shared while the preload'swarm::shared_on()saw it unset. Now both see the same value. This is a detail of the new switch only; with the switch off nothing changes. The test gained an assertion for it.docs/findings.mdupdated: they now say that a new exe that finds the shared mark skips the whole preload and gets only the shared pipeline library (the early and slow pipelines), and that the other pipelines are built in game on first use (NVIDIA keeps its driver cache per program path; possible hitches, not measured).Off (the default) is unchanged.
Open question for the maintainer (why this is WIP)
Step 4 of #128 says "key the done marks without the exe path"; the code has the window mark and the preload mark as one file, so the shared mark also records that the preload finished. What that changes, from reading the code (not measured):
darner preload --all(what the window runs) does three things: translates the shaders,warm::run(makes every known pipeline in worker processes, which fills the driver's cache), andwarm::into_library(stores only the early and slow pipelines inhost-pipelines.bin).warm.rssays the driver keeps what it makes by program path and card (we assume NVIDIA does; not measured by us).warm.rs:183-189mentions black parts in the picture when a pipeline was not made for the program or card. Not tested. At best it is a start-time and hitch trade: the window does not open, but the new exe has not been warmed. The README row anddocs/findings.mdstill say only "possible hitches" and do not mention the black-parts possibility; see the open box at the end.Question: is skipping the whole preload for a new exe, with possible in-game hitches on NVIDIA from the per-exe driver cache, the trade step 4 of #128 wants? Or should a new exe still run
warm::runwithout the window? I can change it either way.How it was tested
f2fe5bebe(two commits,22abbecd7andf2fe5bebe), onmain57dea7f23.cargo test --locked -j 4 -p darner --bin darner -- shared warmup two_exes: 7 passed.cargo clippy --workspace --all-targets --locked -j 4 -- -D warnings(AGENTS.md gate 1): clean.cargo xtask policy: 553 ok.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings) and gate 3 (cargo test --workspace --locked).adapter_driver()andHost::drivertake the same adapter except in the device-creation fallback described above; I did not check this on a PC with two cards.adapter_driver()is a new public function indarner-shader; if AGENTS.md or you want public functions named or kept private, I will change it.Spec dependence
Likely general: the mark logic is in the launcher and does not depend on the GPU. What it saves, and what it costs, may depend on the GPU: the cost described above comes from the driver keeping compiled pipelines per program path (we assume this holds on NVIDIA; not measured). Written on an RTX 2070 SUPER 8 GB (Turing), driver 621.40, Resizable BAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320. Untested on other cards.
Checklist
main.docs/asset-policy.md.Checked for overlap
git merge-tree --write-tree: #142 merges cleanly; #140 has one conflict inapps/darner/src/play.rs, where both add tests at the same place in the test module (the code does not overlap). #140's partial record is keyed by the mark, see the open question. Whichever merges second needs a small rebase.warm.rs, #130 and #132 touchplay.rs, in other places).warm.rsoremit/host.rs. Other PRs that touchplay.rsor the README (#36, #59, #75, #80) also merge cleanly.Drafted with AI assistance (Claude Code).
Tested
f2fe5beon Windows, RTX 5080 (driver 32.0.16.2140):play::tests56 passed (incl. the 3 new mark tests);darner-shaderadapter tests 3 passed.--set DARNER_WARM_SHARED=1: the first wrotewarmed\shared-0b26aad2235ce5e2and the second skipped the preload window; with the switch off the second opened the window and wrote its own mark. An environment-onlyDARNER_WARM_SHARED=1(no--set) was ignored.Not tested: the in-game hitch benefit, other cards/drivers.
Drafted with AI assistance (OpenCode).
Second-opinion review: merge after a small fix. The shared mark (
warmed/shared-<blake3(translator, card, driver)>) is keyed right, and a tester confirmedf2fe5bewith two exes and a real launch (first frame at 10.6 s). Two small points:DARNER_KEY_STICK_MENUbullet; move it to its own place.warm::shared_onbecamepub(crate)but nothing new uses it.The trade-off is documented: a new exe skips the whole preload, so the driver's cache for its path is built during play. Drop WIP when ready. It conflicts with #140 in play.rs; whichever goes second resolves it.
Thanks for the review and for the test on
f2fe5be. Both points are fixed in3854be8df:docs/findings.md: the paragraph now has its own heading, "Preload window mark shared (DARNER_WARM_SHARED=1, off by default)". It sits before "NIS sharpening after DLSS". TheDARNER_KEY_STICK_MENUbullet is back where it was.apps/darner/src/warm.rs:shared_onis a privatefnagain, as on main. Nothing outside the module calls it.The commit changes 2 files (+5/-2). No logic changed.
Checked on
3854be8df:cargo test --locked -p darner --bin darner warm(16 passed). The asset-policy check passed in the pre-commit hook.Not re-run on
3854be8df:cargo clippy --workspace --all-targets --locked -- -D warnings, the same with--all-features, andcargo test --workspace --locked. Not tested: the in-game hitch benefit, other cards or drivers.On the conflict with #140 in
play.rs: I will resolve it on whichever of the two goes second.I will rebase onto main, re-run the three gates and drop WIP once you are happy with this.
This reply was drafted with AI assistance (Claude Code).
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.