WIP: [pr-feature][startup][shaders] Preload: keep done marks across a translator change (DARNER_PRELOAD_KEEP_MARKS, off by default) #264

Manually merged
TrustNo1 merged 0 commits from Jesper-A/Darner:up-preload-keep-marks into main 2026-12-04 22:17:23 +00:00
Collaborator

Draft: no game run. Branch up-preload-keep-marks, one commit (f55e9b581) on main f3840d73d.

Refs #128

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: when the shader translator changes (a new release that touches darner-shader), play::clear_stale_in deletes pipelines/warm-done.txt together with the translated shaders and the host pipeline library (#128, point 1; first described in blazecoding2009's comment). The next preload then makes every pipeline again. But the marks in that file are named by the translated code, the root signature and the graphics state (known::names), under a fingerprint that does not include the translator (known::made_for: driver and static sampler order). So a pipeline whose translation did not change has the same name and the same mark, and the mark is still true. A pipeline whose translation changed has a new name, has no mark, and is made.
  • What this does: with DARNER_PRELOAD_KEEP_MARKS=1 the translator-change cleanup keeps warm-done.txt. Everything else is deleted as before (shaders/, adapters, warm-bad.txt, host-pipelines.*). warm-bad.txt is keyed with the translator, so it is not worth keeping.
  • Not used when DARNER_WARM_SHARED=1: there a mark means "stored in host-pipelines.bin", and that file is deleted on the change, so the mark would be wrong.
  • Switch off (the default): the code path is the same as main.
  • Why it should help: blazecoding2009 measured the premise in their #128 comment: a first start after a translator change, with the marks deleted, took 47 minutes for a 76,725-pipeline preload; the next start (same exe path, translator not rewritten, every mark reused) was done in about 80 s. They also read the code and pointed at the marks and the library being named by content. This PR is that idea behind a switch; credit to them. On our PC, cold preloads (28 to 31 min on our PC) against 0.6 to 0.7 minutes with marks and the driver cache kept (14 runs on 2026-12-02) point the same way. Those runs are not this change: they show what a preload costs with and without marks, not what this switch gives after a real update.
  • The marks file grows: a few MB (about 50 bytes per pipeline) for a 76,725-pipeline preload. It is append-only; the next translator change with the switch off clears it.
  • A README row for the switch (it says "A few MB of marks (about 50 bytes per pipeline)") and a section in docs/findings.md.

How it was tested

  • Tested revision: f55e9b581 (on f3840d73d).

  • Commands and results:

    • cargo test of the play::tests module (58 tests): 58 passed. This includes the new test done_marks_survive_a_translator_change_only_when_asked and the existing stale-cache test, changed to pass keep_marks = false.
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo xtask policy: ok.
  • Changes a default: no.

  • A/B result: not applicable for a speed claim, because the switch is off by default and nothing was timed with it on. Checked by unit tests of the file handling only.

    A (off) B (on)
    first preload after a translator change not measured with this change not measured with this change
  • Gates run on that revision (the three in AGENTS.md; there is no CI): gate 1 only (cargo clippy --workspace --all-targets --locked -- -D warnings). Not run: the same with --all-features, and cargo test --workspace --locked.

  • Gameplay, when relevant: not run. No game start after a translator change with the switch on.

  • Shader wave sizes tested, when relevant: not relevant (no shader change).

  • Hardware dependence: see Spec dependence.

  • Coverage gaps:

    • Not tested: whether NVIDIA's driver cache really answers quickly for pipelines whose DXIL did not change after an update. This is the premise; our runs with marks and driver cache kept fit it, but no run did a real translator change with the switch on.
    • If the driver cache does not answer, a skipped pipeline is simply made on demand in play, and nothing is wrong, but the preload would have saved that.
    • Not measured by anyone yet (blazecoding2009 says so in #128): how many pipelines keep their name across a typical translator change. If it is few, keeping the marks gains little.
    • Marks kept now and DARNER_WARM_SHARED=1 turned on later with a new library present: not guarded, same as main's behaviour for a same-translator cache.

Spec dependence

  • Likely general: the file handling and the naming of marks do not depend on the hardware.
  • May depend on our specs: the saving depends on the driver cache. We only have NVIDIA (RTX 2070 SUPER 8 GB, Turing, driver 621.40, no ReBAR, Ryzen 7 5800X, 32 GB, Series S + DLSS Performance). The marks include the driver and the card, so a driver update drops them on any card.
  • Untested elsewhere: AMD and Intel drivers (their cache keys and limits are not known to us), other install paths.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not yet: no game run. The PR stays a draft until one is done.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: ok).
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #142, #140, #215 (ours), #235 (andrewpozdnakov7-jpg), #153 (ours, play.rs, a mark shared across darner.exe copies with the same translator).
  • Replaces or overlaps:
    • #142 (translate.rs, stamps.rs, shader_cache.rs): no shared files.
    • #140, #215, #235 touch warm and translate paths, not clear_stale_*; I expect only trivial textual conflicts in README.md (switch table) and docs/findings.md (appended lines).
    • #153 also edits play.rs and the translator-change handling; not compared line by line. Possible conflict, to be checked on rebase.
    • #153, #140 and #215 all edit play.rs. WIP posted with conflicts as is; to be rebased before WIP comes off.
    • #128 stays open: this is a partial answer to its point 1.
    • No open or closed PR found that keeps the marks: searched "preload", "warm-done", "DARNER_PRELOAD", "slow-pipelines".

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

Draft: no game run. Branch `up-preload-keep-marks`, one commit (f55e9b581) on `main` f3840d73d. Refs #128 ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: when the shader translator changes (a new release that touches `darner-shader`), `play::clear_stale_in` deletes `pipelines/warm-done.txt` together with the translated shaders and the host pipeline library (#128, point 1; first described in [blazecoding2009's comment](https://git.gtahub.st/TrustNo1/Darner/issues/128#issuecomment-852854)). The next preload then makes every pipeline again. But the marks in that file are named by the translated code, the root signature and the graphics state (`known::names`), under a fingerprint that does not include the translator (`known::made_for`: driver and static sampler order). So a pipeline whose translation did not change has the same name and the same mark, and the mark is still true. A pipeline whose translation changed has a new name, has no mark, and is made. - What this does: with `DARNER_PRELOAD_KEEP_MARKS=1` the translator-change cleanup keeps `warm-done.txt`. Everything else is deleted as before (`shaders/`, `adapters`, `warm-bad.txt`, `host-pipelines.*`). `warm-bad.txt` is keyed with the translator, so it is not worth keeping. - Not used when `DARNER_WARM_SHARED=1`: there a mark means "stored in `host-pipelines.bin`", and that file is deleted on the change, so the mark would be wrong. - Switch off (the default): the code path is the same as main. - Why it should help: blazecoding2009 measured the premise in [their #128 comment](https://git.gtahub.st/TrustNo1/Darner/issues/128#issuecomment-852854): a first start after a translator change, with the marks deleted, took 47 minutes for a 76,725-pipeline preload; the next start (same exe path, translator not rewritten, every mark reused) was done in about 80 s. They also read the code and pointed at the marks and the library being named by content. This PR is that idea behind a switch; credit to them. On our PC, cold preloads (28 to 31 min on our PC) against 0.6 to 0.7 minutes with marks and the driver cache kept (14 runs on 2026-12-02) point the same way. Those runs are not this change: they show what a preload costs with and without marks, not what this switch gives after a real update. - The marks file grows: a few MB (about 50 bytes per pipeline) for a 76,725-pipeline preload. It is append-only; the next translator change with the switch off clears it. - A README row for the switch (it says "A few MB of marks (about 50 bytes per pipeline)") and a section in `docs/findings.md`. ## How it was tested - Tested revision: f55e9b581 (on f3840d73d). - Commands and results: - `cargo test` of the `play::tests` module (58 tests): 58 passed. This includes the new test `done_marks_survive_a_translator_change_only_when_asked` and the existing stale-cache test, changed to pass `keep_marks = false`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo xtask policy`: ok. - Changes a default: no. - A/B result: not applicable for a speed claim, because the switch is off by default and nothing was timed with it on. Checked by unit tests of the file handling only. | | A (off) | B (on) | |---|---|---| | first preload after a translator change | not measured with this change | not measured with this change | - Gates run on that revision (the three in AGENTS.md; there is no CI): gate 1 only (`cargo clippy --workspace --all-targets --locked -- -D warnings`). Not run: the same with `--all-features`, and `cargo test --workspace --locked`. - Gameplay, when relevant: not run. No game start after a translator change with the switch on. - Shader wave sizes tested, when relevant: not relevant (no shader change). - Hardware dependence: see Spec dependence. - Coverage gaps: - Not tested: whether NVIDIA's driver cache really answers quickly for pipelines whose DXIL did not change after an update. This is the premise; our runs with marks and driver cache kept fit it, but no run did a real translator change with the switch on. - If the driver cache does not answer, a skipped pipeline is simply made on demand in play, and nothing is wrong, but the preload would have saved that. - Not measured by anyone yet (blazecoding2009 says so in #128): how many pipelines keep their name across a typical translator change. If it is few, keeping the marks gains little. - Marks kept now and `DARNER_WARM_SHARED=1` turned on later with a new library present: not guarded, same as main's behaviour for a same-translator cache. ## Spec dependence - Likely general: the file handling and the naming of marks do not depend on the hardware. - May depend on our specs: the saving depends on the driver cache. We only have NVIDIA (RTX 2070 SUPER 8 GB, Turing, driver 621.40, no ReBAR, Ryzen 7 5800X, 32 GB, Series S + DLSS Performance). The marks include the driver and the card, so a driver update drops them on any card. - Untested elsewhere: AMD and Intel drivers (their cache keys and limits are not known to us), other install paths. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not yet: no game run. The PR stays a draft until one is done. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: ok). - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #142, #140, #215 (ours), #235 (andrewpozdnakov7-jpg), #153 (ours, `play.rs`, a mark shared across `darner.exe` copies with the same translator). - Replaces or overlaps: - #142 (`translate.rs`, `stamps.rs`, `shader_cache.rs`): no shared files. - #140, #215, #235 touch warm and translate paths, not `clear_stale_*`; I expect only trivial textual conflicts in `README.md` (switch table) and `docs/findings.md` (appended lines). - #153 also edits `play.rs` and the translator-change handling; not compared line by line. Possible conflict, to be checked on rebase. - #153, #140 and #215 all edit `play.rs`. WIP posted with conflicts as is; to be rebased before WIP comes off. - #128 stays open: this is a partial answer to its point 1. - No open or closed PR found that keeps the marks: searched "preload", "warm-done", "DARNER_PRELOAD", "slow-pipelines". This change was made with AI assistance (Claude Code).
A translator change deleted pipelines/warm-done.txt (#128), though the marks
are named by the translated code, root signature and graphics state under a
fingerprint without the translator. With the switch (off by default) the file
stays: a pipeline whose translation changed has a new name and is made again,
one that did not is skipped and the driver's cache answers for it. Not used
with DARNER_WARM_SHARED=1, whose marks mean "stored in the library" that the
change deletes. Switch off: unchanged.

This change was made with AI assistance (Claude Code).
First-time contributor

Data from a real translator change on one PC. This is not a test of this branch (I did not build it).

  • v2026.12.03.01 -> v2026.12.03.02 (translator ec4f8a0d... -> f49064c2...), RTX 5080 Laptop GPU,
    driver 621.47, the same darner.exe path, default cache folder. The first start's cleanup deleted
    warm-done.txt, and the first-start preload (preload --all) then took 14.8 min.
  • I had kept a copy of the old cache. The old warm-done.txt held 76,578 marks under c73a7c6f5f79eba9
    for this path. After the new preload there are 76,582 marks under the same fingerprint. 54,202 names
    (70.8 %) are in both lists, and 22,380 are new.
  • So here the fingerprint did not change with the translator, and about 71 % of the deleted marks were
    still true.
  • Not measured: how much of the 14.8 min went into those 54,202 makes. The driver's shader cache for this
    path was kept, so they were probably quick cache hits, and the time this saves may be much smaller than
    71 %. The marks do not cover the shader translations, which the cleanup also deleted.
Data from a real translator change on one PC. This is not a test of this branch (I did not build it). - v2026.12.03.01 -> v2026.12.03.02 (translator `ec4f8a0d...` -> `f49064c2...`), RTX 5080 Laptop GPU, driver 621.47, the same `darner.exe` path, default cache folder. The first start's cleanup deleted `warm-done.txt`, and the first-start preload (`preload --all`) then took 14.8 min. - I had kept a copy of the old cache. The old `warm-done.txt` held 76,578 marks under `c73a7c6f5f79eba9` for this path. After the new preload there are 76,582 marks under the same fingerprint. 54,202 names (70.8 %) are in both lists, and 22,380 are new. - So here the fingerprint did not change with the translator, and about 71 % of the deleted marks were still true. - Not measured: how much of the 14.8 min went into those 54,202 makes. The driver's shader cache for this path was kept, so they were probably quick cache hits, and the time this saves may be much smaller than 71 %. The marks do not cover the shader translations, which the cleanup also deleted.
Owner

Review of f55e9b58 (read only, not built or run). WIP draft: no code findings that block it.

Checked:

  • With the switch off, every path is the same as main: keep_marks = false everywhere, and the existing stale-cache test now passes it explicitly.
  • With it on, only warm-done.txt survives. shaders/, adapters, warm-bad.txt and host-pipelines.* are still deleted.
  • keeps_marks refuses DARNER_WARM_SHARED=1. That's right: a shared mark means "stored in the library", and that file is deleted.
  • The non-shared mark fingerprint (mark_fingerprint: made_for + program + card) has no translator in it, and the names come from the new translation. So a changed pipeline gets a new name and is made, and an unchanged one keeps its mark.
  • The switch is in KEPT, and the test checks !stale_switch(KEEP_MARKS), so it isn't cleared like the one-shot DARNER_PRELOAD* switches.
  • Andreww2009's data (an RTX 5080 laptop, .03.01 → .03.02) supports the premise: the fingerprint was unchanged and 70.8 % of the deleted marks were still true.

Points:

  1. warm-done.txt only grows while the switch stays on: every translator change adds the new names (about 22k, ~1 MB here) and nothing removes the old ones. Consider rewriting the file with only the current names when a preload finishes, or note it in the README row.
  2. As your gaps say, the premise still needs one real translator change with the switch on, timing the first preload against off. That's what takes it off WIP. The driver cache answering for unchanged DXIL is the open question; AMD and Intel are untested.
  3. Gates 2 and 3 (--all-features clippy, cargo test --workspace --locked) haven't run yet.

It merges cleanly with main (f3840d73), #153, #215 and #228. With #140, #266 and #267 it conflicts only in docs/findings.md and the README switch table, both trivial.

No testcall-ok while it's a draft. It can carry one once a run is in. It deletes nothing that main keeps.

Review of f55e9b58 (read only, not built or run). WIP draft: no code findings that block it. **Checked:** - With the switch off, every path is the same as main: `keep_marks = false` everywhere, and the existing stale-cache test now passes it explicitly. - With it on, only `warm-done.txt` survives. `shaders/`, `adapters`, `warm-bad.txt` and `host-pipelines.*` are still deleted. - `keeps_marks` refuses `DARNER_WARM_SHARED=1`. That's right: a shared mark means "stored in the library", and that file is deleted. - The non-shared mark fingerprint (`mark_fingerprint`: `made_for` + program + card) has no translator in it, and the names come from the new translation. So a changed pipeline gets a new name and is made, and an unchanged one keeps its mark. - The switch is in `KEPT`, and the test checks `!stale_switch(KEEP_MARKS)`, so it isn't cleared like the one-shot `DARNER_PRELOAD*` switches. - Andreww2009's data (an RTX 5080 laptop, .03.01 → .03.02) supports the premise: the fingerprint was unchanged and 70.8 % of the deleted marks were still true. **Points:** 1. `warm-done.txt` only grows while the switch stays on: every translator change adds the new names (about 22k, ~1 MB here) and nothing removes the old ones. Consider rewriting the file with only the current names when a preload finishes, or note it in the README row. 2. As your gaps say, the premise still needs one real translator change with the switch on, timing the first preload against off. That's what takes it off WIP. The driver cache answering for unchanged DXIL is the open question; AMD and Intel are untested. 3. Gates 2 and 3 (`--all-features` clippy, `cargo test --workspace --locked`) haven't run yet. It merges cleanly with main (f3840d73), #153, #215 and #228. With #140, #266 and #267 it conflicts only in `docs/findings.md` and the README switch table, both trivial. No testcall-ok while it's a draft. It can carry one once a run is in. It deletes nothing that main keeps.
TrustNo1 manually merged commit ee177bdc2a into main 2026-12-04 22:17:23 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
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!264
No description provided.