WIP: Preload window mark by exe path, translator, card and driver (DARNER_PRELOAD_MARK_BY_PATH, off by default) #451

Draft
Jesper-A wants to merge 1 commit from Jesper-A/Darner:up-preload-marks-pathfree-v2 into Main
Collaborator

Refs #128 (stage 4 of the plan in that issue; not a full fix)

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: read from the code and from the driver's cache folders on our PC; no log line, and no timed run. The preload window's "done" mark is keyed by the bytes of darner.exe (mark_path in play.rs), but the driver's pipeline cache follows the exe path. The two disagree in two cases:
    • An update in place (a new darner.exe over the old one): the driver's cache, the done marks, the shaders and the library are all still there, but the bytes changed, so the window opens and runs the whole preload again.
    • A byte-identical copy in another folder: the window stays shut (with #153's shared mark), although that path's driver cache is empty.

Evidence that the cache follows the path:

  • Each folder in the D3DSCache cache has a small database with an app_id table that holds the exe path. On NVIDIA 621.40 we counted 133 folders with 130 different paths, one path per folder (counted once, on our PC). Three system programs have two folders each (after updates), so the key may hold more than the path. For darner, the path decided it in our data.
  • Three byte-identical copies of darner.exe (the same SHA-256) in three different folders got three separate cache folders, each 1.0 to 1.8 GB. The second copy's preload was as slow as a cold one (step 2 782 s, step 3 813 s), so NVIDIA's shared DXCache did not answer for the new path either (one run, on our PC).
  • Eight darner or victory exes rebuilt at the same path, after their folder was created, each still have exactly one folder: new bytes at the same path keep the folder (counted once, on our PC).
  • Microsoft's spec (D3D12 Shader Cache APIs) says D3DSCache caches are "Process-local: the cache is tied to the executable that created it". Microsoft's registration API also keys on the executable path, but that is the key of the D3DSCR registration, not the name of the cache folder. Neither spec documents how the folder name is made, and neither NVIDIA nor AMD documents its own key.
  • Upstream's own text agrees: warm.rs:186-190 ("The driver keeps what is made here by program path and card"); TrustNo1's review of #153 (comment 858094: a new exe skips the whole preload, "so the driver's cache for its path is built during play"); and blazecoding2009's laptop in #128 (comment 852854): a new release at the same exe path with an unchanged translator finished the window in about 80 s with every mark reused, while a diagnostics build of the same commit in another folder made all 76,725 pipelines again (one PC, not like for like).

What it does not change. A path-free "done" mark is not right for the warm-done marks, which exist to fill the driver's cache for the exe that will play: their path in the key (warm.rs:203) is correct and stays. #153's shared mark stays an opt-in trade that TrustNo1 reviewed and accepted. This PR does not move #153.

The change. New switch DARNER_PRELOAD_MARK_BY_PATH=1, off by default. With it on, the window mark and the preload mark are both
warmed/path-<first 16 hex of blake3("program-path", translator id, 0, card, 0, driver, lowercased exe path)>.

  • Update in place with an unchanged translator: no window.
  • New translator, another card or a driver update: a new key, the window opens.
  • A copy at a new path: a new key, the window opens.
  • DARNER_WARM_SHARED=1 wins when both are on (the user asked for path-free).
  • With no translator id, it falls back to the mark by bytes.
  • It is read from the start's settings only, like #153's switch.
  • Switch off: main + #153 behaviour, unchanged. needs_pipelines (an empty library opens the window) is unchanged.

Caveat (the same as #153, accepted there): a change outside crates/darner-shader that changes pipeline names (the pipeline state code in darner-gpu) is not in the translator id. Such a build at the same path skips the window and builds the changed pipelines in the game. Possible hitches; not measured.

Known follow-up: #435 (Skanzinho) lets darner preload write the byte-hash mark (record_preload). With DARNER_PRELOAD_MARK_BY_PATH=1 the play start looks for the path mark, so a command-line preload under #435 would still open the window. This PR puts the choice in two helpers: content_mark (shared or path mark from the settings) and preload_mark_for (that, else the mark by bytes), which prepare uses for both the window's mark and the preload's. #435's record_preload() takes no settings today, so it would have to read the start's settings, call content_mark, and pass the result to preload_mark_for (as prepare does) to write the same mark the window waits for.

Not in this PR: compacting warm-done.txt (TrustNo1's first point on #264) was raised in #264 (merged); it is for a separate follow-up PR, not this one.

Files: apps/darner/src/play.rs (path_marks, path_mark, path_mark_in, content_mark, preload_mark_for, the choice in prepare, 4 tests), README.md (a switch row), docs/findings.md (an entry).

One commit on main (47d21cd3b), which has #153 and #215: git diff --stat trustno1/main...HEAD is 3 files.

main has since moved to d91d8e4d6 (the F2 RAM-speed note; other files). The branch was not rebased; a trial merge with it is clean (checked 2026-12-05).

How it was tested

  • Tested revision: branch up-preload-marks-pathfree-v2 @ efebde3af, on main @ 47d21cd3b.

  • Commands and results (there is no CI upstream; these are the ones I ran on efebde3af):

    • cargo test -p darner --bin darner --locked: 196 passed, 0 failed, 1 ignored
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
    • cargo xtask policy: ok (564 files)
    • New tests: path_preload_mark_is_by_translator_card_driver_and_path (each input changes the key, and it never equals the shared mark), path_mark_follows_the_exe_path_not_its_bytes (same path with new bytes counts as done; identical bytes in another folder does not; switch off is main's behaviour), path_marks_follow_the_setting, content_mark_picks_shared_then_path_then_nothing.
  • Changes a default: no. The switch is off by default.

  • A/B result: the switch is off by default, and it was checked by unit tests only. Not run in a game, so there is no A/B and no timing. The evidence above is from the driver's cache folders.

    A (off) B (on)
    not measured not run not run
  • Gates run on that revision: clippy workspace: yes. Clippy workspace with --all-features: yes. cargo test -p darner --bin darner: yes. Full cargo test --workspace --locked: not run. There is no CI upstream.

  • Gameplay: not run in a game. The machine for the later run: RTX 2070 SUPER 8 GB (Turing), driver 621.40, ReBAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320; Series S, DLSS Performance, frame generation off, ray tracing off.

  • Shader wave sizes tested: not relevant.

  • Hardware dependence: likely general (launcher logic); the path-keyed driver cache was observed on NVIDIA 621.40 only. Details in "Spec dependence".

  • Coverage gaps: every game run (the steps below); AMD and Intel drivers; the case of a build that changes pipeline names outside the translator; the full workspace tests.

In-game check, to run before WIP comes off

Use darner play with --set DARNER_PRELOAD_MARK_BY_PATH=1 and a test cache.

  1. First start of exe X at path P: the window opens and the preload finishes; warmed/path-<hash> exists.
  2. Rebuild X with the same translator (a change outside crates/darner-shader) and replace it at P. Start: no window, no new D3DSCache folder, and in-game pipeline builds ("being made") about the same as before the rebuild.
  3. Copy the same exe to another folder Q and start it: the window opens and a new D3DSCache folder is made for Q.
  4. With the switch off, step 2 opens the window (as main).
  5. A translator change at P opens the window.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not ticked: not run in a game yet. The PR stays a draft (WIP) until it has been.
  • This PR contains one change based on main.
    • Not ticked: it is one commit on main; ticking waits for the in-game check.
  • The diff follows docs/asset-policy.md (cargo xtask policy: ok).
  • I recorded this PR's dependencies below.
    • Depends on: none (#153 and #215 are in main; this uses #153's window_mark, adapter_driver and the settings-only read)

Spec dependence

  • Likely general (helps any card): the key logic and the update-in-place case are launcher logic with no GPU dependence.
  • May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM near budget, ReBAR off, Ryzen 7 5800X, 32 GB RAM, Series S + DLSS Performance): the path-keyed driver cache was observed on NVIDIA 621.40 only.
  • Untested elsewhere (other GPU generations, AMD, 12-16 GB, Series X, frame generation, ray tracing): AMD and Intel drivers (their cache keys are not documented), and any game run.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #153 (merged; its shared mark is path-free by design, and this does not change it), #215 (merged), #140 (merged; its record sits beside window_mark, so it follows the path mark too), #264 (merged; DARNER_PRELOAD_KEEP_MARKS: a different file, warm-done.txt, and a different trigger, a translator change; with both on, a translator change opens the window and the still-true marks are reused), #270, and #435 (Skanzinho, open, tested in its description): it moves the mark write into write_mark, so darner preload also writes the byte-hash mark. It is in the same play.rs area; the second to land rebases. See the known follow-up above.
  • Replaces or overlaps: none found. Searches for MARK_BY_PATH and "preload exe path" found no PR that does this.

This change was made with AI assistance (Claude Code).

Refs #128 (stage 4 of the plan in that issue; not a full fix) ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: read from the code and from the driver's cache folders on our PC; no log line, and no timed run. The preload window's "done" mark is keyed by the bytes of `darner.exe` (`mark_path` in `play.rs`), but the driver's pipeline cache follows the exe path. The two disagree in two cases: - An update in place (a new `darner.exe` over the old one): the driver's cache, the done marks, the shaders and the library are all still there, but the bytes changed, so the window opens and runs the whole preload again. - A byte-identical copy in another folder: the window stays shut (with #153's shared mark), although that path's driver cache is empty. **Evidence that the cache follows the path:** - Each folder in the `D3DSCache` cache has a small database with an `app_id` table that holds the exe path. On NVIDIA 621.40 we counted 133 folders with 130 different paths, one path per folder (counted once, on our PC). Three system programs have two folders each (after updates), so the key may hold more than the path. For `darner`, the path decided it in our data. - Three byte-identical copies of `darner.exe` (the same SHA-256) in three different folders got three separate cache folders, each 1.0 to 1.8 GB. The second copy's preload was as slow as a cold one (step 2 782 s, step 3 813 s), so NVIDIA's shared `DXCache` did not answer for the new path either (one run, on our PC). - Eight `darner` or `victory` exes rebuilt at the same path, after their folder was created, each still have exactly one folder: new bytes at the same path keep the folder (counted once, on our PC). - Microsoft's spec ([D3D12 Shader Cache APIs](https://microsoft.github.io/DirectX-Specs/d3d/ShaderCache.html)) says D3DSCache caches are "Process-local: the cache is tied to the executable that created it". Microsoft's [registration API](https://microsoft.github.io/DirectX-Specs/d3d/ShaderCacheRegistrationAPI.html) also keys on the executable path, but that is the key of the D3DSCR registration, not the name of the cache folder. Neither spec documents how the folder name is made, and neither NVIDIA nor AMD documents its own key. - Upstream's own text agrees: `warm.rs:186-190` ("The driver keeps what is made here by program path and card"); TrustNo1's review of #153 (comment 858094: a new exe skips the whole preload, "so the driver's cache for its path is built during play"); and blazecoding2009's laptop in #128 (comment 852854): a new release at the same exe path with an unchanged translator finished the window in about 80 s with every mark reused, while a diagnostics build of the same commit in another folder made all 76,725 pipelines again (one PC, not like for like). **What it does not change.** A path-free "done" mark is not right for the warm-done marks, which exist to fill the driver's cache for the exe that will play: their path in the key (`warm.rs:203`) is correct and stays. #153's shared mark stays an opt-in trade that TrustNo1 reviewed and accepted. This PR does not move #153. **The change.** New switch `DARNER_PRELOAD_MARK_BY_PATH=1`, **off by default**. With it on, the window mark and the preload mark are both `warmed/path-<first 16 hex of blake3("program-path", translator id, 0, card, 0, driver, lowercased exe path)>`. - Update in place with an unchanged translator: no window. - New translator, another card or a driver update: a new key, the window opens. - A copy at a new path: a new key, the window opens. - `DARNER_WARM_SHARED=1` wins when both are on (the user asked for path-free). - With no translator id, it falls back to the mark by bytes. - It is read from the start's settings only, like #153's switch. - Switch off: `main` + #153 behaviour, unchanged. `needs_pipelines` (an empty library opens the window) is unchanged. Caveat (the same as #153, accepted there): a change outside `crates/darner-shader` that changes pipeline names (the pipeline state code in `darner-gpu`) is not in the translator id. Such a build at the same path skips the window and builds the changed pipelines in the game. Possible hitches; not measured. Known follow-up: #435 (Skanzinho) lets `darner preload` write the byte-hash mark (`record_preload`). With `DARNER_PRELOAD_MARK_BY_PATH=1` the play start looks for the path mark, so a command-line preload under #435 would still open the window. This PR puts the choice in two helpers: `content_mark` (shared or path mark from the settings) and `preload_mark_for` (that, else the mark by bytes), which `prepare` uses for both the window's mark and the preload's. #435's `record_preload()` takes no settings today, so it would have to read the start's settings, call `content_mark`, and pass the result to `preload_mark_for` (as `prepare` does) to write the same mark the window waits for. Not in this PR: compacting `warm-done.txt` (TrustNo1's first point on #264) was raised in #264 (merged); it is for a separate follow-up PR, not this one. Files: `apps/darner/src/play.rs` (`path_marks`, `path_mark`, `path_mark_in`, `content_mark`, `preload_mark_for`, the choice in `prepare`, 4 tests), `README.md` (a switch row), `docs/findings.md` (an entry). One commit on `main` (47d21cd3b), which has #153 and #215: `git diff --stat trustno1/main...HEAD` is 3 files. `main` has since moved to d91d8e4d6 (the F2 RAM-speed note; other files). The branch was not rebased; a trial merge with it is clean (checked 2026-12-05). ## How it was tested - Tested revision: branch `up-preload-marks-pathfree-v2` @ `efebde3af`, on `main` @ `47d21cd3b`. - Commands and results (there is no CI upstream; these are the ones I ran on `efebde3af`): - `cargo test -p darner --bin darner --locked`: 196 passed, 0 failed, 1 ignored - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo xtask policy`: ok (564 files) - New tests: `path_preload_mark_is_by_translator_card_driver_and_path` (each input changes the key, and it never equals the shared mark), `path_mark_follows_the_exe_path_not_its_bytes` (same path with new bytes counts as done; identical bytes in another folder does not; switch off is `main`'s behaviour), `path_marks_follow_the_setting`, `content_mark_picks_shared_then_path_then_nothing`. - Changes a default: no. The switch is off by default. - A/B result: the switch is off by default, and it was checked by unit tests only. Not run in a game, so there is no A/B and no timing. The evidence above is from the driver's cache folders. | | A (off) | B (on) | |---|---|---| | not measured | not run | not run | - Gates run on that revision: clippy workspace: yes. Clippy workspace with `--all-features`: yes. `cargo test -p darner --bin darner`: yes. Full `cargo test --workspace --locked`: **not run**. There is no CI upstream. - Gameplay: **not run in a game.** The machine for the later run: RTX 2070 SUPER 8 GB (Turing), driver 621.40, ReBAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320; Series S, DLSS Performance, frame generation off, ray tracing off. - Shader wave sizes tested: not relevant. - Hardware dependence: likely general (launcher logic); the path-keyed driver cache was observed on NVIDIA 621.40 only. Details in "Spec dependence". - Coverage gaps: every game run (the steps below); AMD and Intel drivers; the case of a build that changes pipeline names outside the translator; the full workspace tests. ### In-game check, to run before WIP comes off Use `darner play` with `--set DARNER_PRELOAD_MARK_BY_PATH=1` and a test cache. 1. First start of exe X at path P: the window opens and the preload finishes; `warmed/path-<hash>` exists. 2. Rebuild X with the same translator (a change outside `crates/darner-shader`) and replace it at P. Start: **no window**, no new `D3DSCache` folder, and in-game pipeline builds ("being made") about the same as before the rebuild. 3. Copy the same exe to another folder Q and start it: the **window opens** and a new `D3DSCache` folder is made for Q. 4. With the switch off, step 2 opens the window (as `main`). 5. A translator change at P opens the window. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). - Not ticked: not run in a game yet. The PR stays a draft (WIP) until it has been. - [ ] This PR contains one change based on `main`. - Not ticked: it is one commit on `main`; ticking waits for the in-game check. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: ok). - [x] I recorded this PR's dependencies below. - Depends on: none (#153 and #215 are in `main`; this uses #153's `window_mark`, `adapter_driver` and the settings-only read) ## Spec dependence - Likely general (helps any card): the key logic and the update-in-place case are launcher logic with no GPU dependence. - May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM near budget, ReBAR off, Ryzen 7 5800X, 32 GB RAM, Series S + DLSS Performance): the path-keyed driver cache was observed on NVIDIA 621.40 only. - Untested elsewhere (other GPU generations, AMD, 12-16 GB, Series X, frame generation, ray tracing): AMD and Intel drivers (their cache keys are not documented), and any game run. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #153 (merged; its shared mark is path-free by design, and this does not change it), #215 (merged), #140 (merged; its record sits beside `window_mark`, so it follows the path mark too), #264 (merged; `DARNER_PRELOAD_KEEP_MARKS`: a different file, `warm-done.txt`, and a different trigger, a translator change; with both on, a translator change opens the window and the still-true marks are reused), #270, and #435 (Skanzinho, open, tested in its description): it moves the mark write into `write_mark`, so `darner preload` also writes the byte-hash mark. It is in the same `play.rs` area; the second to land rebases. See the known follow-up above. - Replaces or overlaps: none found. Searches for `MARK_BY_PATH` and "preload exe path" found no PR that does this. This change was made with AI assistance (Claude Code).
Port of our branch up-preload-marks-pathfree c3d737bf5 (stage 4 of #128), rebased on main with #153 and #215.

This change was made with AI assistance (Claude Code).
Jesper-A force-pushed up-preload-marks-pathfree-v2 from efebde3afe to 3e16dbb4af 2026-12-05 16:39:53 +00:00 Compare
Author
Collaborator

Closing this old-engine PR because post-merge replaced the preload window and its exe-path "done" mark; the mark there is preloaded.txt (preload.rs:38-41). It can be redone on post-merge if the problem shows there.

Written with AI assistance (Claude Code).

Closing this old-engine PR because post-merge replaced the preload window and its exe-path "done" mark; the mark there is `preloaded.txt` (`preload.rs:38-41`). It can be redone on post-merge if the problem shows there. Written with AI assistance (Claude Code).
Jesper-A closed this pull request 2026-12-06 01:26:01 +00:00
Jesper-A reopened this pull request 2026-12-06 01:51:46 +00:00
Author
Collaborator

Reopened: Main is the default branch again, so the close note above no longer applies.

Written with AI assistance (Claude Code).

Reopened: Main is the default branch again, so the close note above no longer applies. Written with AI assistance (Claude Code).
TrustNo1 changed title from WIP: [pr-feature][startup][shaders] Preload window mark by exe path, translator, card and driver (DARNER_PRELOAD_MARK_BY_PATH, off by default) to WIP: Preload window mark by exe path, translator, card and driver (DARNER_PRELOAD_MARK_BY_PATH, off by default) 2026-12-06 03:28:53 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'up-preload-marks-pathfree-v2:Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Jesper-A-up-preload-marks-pathfree-v2'

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.

git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Jesper-A-up-preload-marks-pathfree-v2'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Jesper-A-up-preload-marks-pathfree-v2'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Main'
git merge --squash 'Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-marks-pathfree-v2'
git switch 'Main'
git merge 'Jesper-A-up-preload-marks-pathfree-v2'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!451
No description provided.