WIP: Preload: a full warm drops stale marks from warm-done.txt (DARNER_PRELOAD_KEEP_MARKS) #470

Draft
Jesper-A wants to merge 1 commit from Jesper-A/Darner:up-keep-marks-compact into Main
Collaborator

Refs #264

What it changes

Follow-up to #264 (merged at f55e9b58). It answers point 1 of the review: #264 (comment)

  • The problem on main: with DARNER_PRELOAD_KEEP_MARKS=1, warm-done.txt is kept across a translator change, so the file only grows. Each translator change adds the new names (about 22k, ~1 MB on the PC that gave the numbers in the review) and nothing removes the old ones. This is read from the code and from the review; I did not measure a grown file.
  • What this does (apps/darner/src/warm.rs): when a warm over every known pipeline ends (not --used, not --limit, and DARNER_PRELOAD_KEEP_MARKS=1), it rewrites warm-done.txt without this build's marks (the current fingerprint) whose name no pipeline has any more, and without repeated lines. Lines of other fingerprints (another program path, card or driver) and lines of no known shape are kept. It writes a file beside it (warm-done.txt.new) and renames it over the old one. It prints warm-done.txt: N marks of names no pipeline has any more were dropped, or was not compacted: <error> and goes on.
  • --used and --limit runs name only some pipelines, so they never compact.
  • With the switch off, nothing changes (the compaction is behind the same switch).
  • KEEP_MARKS in play.rs becomes pub(crate) so warm.rs reads the same name. README row and docs/findings.md say it.

How it was tested

  • Tested revision: branch up-keep-marks-compact @ e8f517e2a, based on main 47d21cd3b.
  • Based on main 47d21cd3b. main is now d91d8e4d6; git merge-tree merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP).
  • Commands and results (scoped; the three workspace gates were not run):
    • cargo clippy -p darner, with and without --all-features, and the darner tests for warm, including two new ones (compacting_the_done_marks_keeps_only_current_names_of_this_fingerprint, compacting_the_done_file_rewrites_it_only_when_a_line_goes), reported clean by the porter; exact flags and counts not kept. I did not re-run them for this text.
  • Changes a default: no. The switch stays off by default.
  • A/B result: none. A switch that is off by default; no speed claim.
  • Gates run on that revision: only the scoped ones above. Not run: the workspace clippy (with and without --all-features) and cargo test --workspace --locked.
  • Gameplay: not run in game. Not run: a real preload with the switch on across a translator change.
  • Shader wave sizes tested: no shader change.
  • Hardware dependence: see "Spec dependence".
  • Coverage gaps, to check in a real run before WIP: comes off:
    • A full darner preload with the switch on after a translator change: the printed line shows the dropped count, and a second start finds the marks it needs.
    • darner preload --used leaves warm-done.txt as it was.
    • A crash or kill between writing the new file and the rename leaves the old file (the rename is the only step that replaces it); not tested.

Spec dependence

  • Likely general: the file handling is plain text over names, with no GPU specifics.
  • May depend on our specs: nothing known.
  • Untested elsewhere: every card; whether the driver's cache answers for unchanged DXIL on AMD and Intel (this is the open question of #264, not of this change).

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game; the tests cover the rewrite only.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md. (Text only; policy not recorded as run for this branch.)
  • 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 (open PRs only; file lists read through the API, 2026-12-05):
    • #450, #458 and #463 (and older #165, #234, #270, #365) also edit apps/darner/src/warm.rs. #450 has a hunk at about line 828 (in make, next to mod tests), right where our new tests go (about line 830), so a textual conflict is possible there. #463 changes one test fixture about 55 lines further down; #458 edits run and into_library far from our hunks. #270 has one hunk (about line 377) a few lines above our run hunk (about 388).
    • #451 and #459 edit apps/darner/src/play.rs but not KEEP_MARKS; #429, #431 and #435 also list play.rs. Our change there is one line.
    • #451's body points to this compaction as a separate follow-up, so this PR is that follow-up.
  • Replaces or overlaps: none found (no open PR compacts warm-done.txt).

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

Refs #264 ## What it changes Follow-up to #264 (merged at `f55e9b58`). It answers point 1 of the review: https://git.gtahub.st/TrustNo1/Darner/pulls/264#issuecomment-873185 - The problem on main: with `DARNER_PRELOAD_KEEP_MARKS=1`, `warm-done.txt` is kept across a translator change, so the file only grows. Each translator change adds the new names (about 22k, ~1 MB on the PC that gave the numbers in the review) and nothing removes the old ones. This is read from the code and from the review; I did not measure a grown file. - What this does (`apps/darner/src/warm.rs`): when a warm over every known pipeline ends (not `--used`, not `--limit`, and `DARNER_PRELOAD_KEEP_MARKS=1`), it rewrites `warm-done.txt` without this build's marks (the current fingerprint) whose name no pipeline has any more, and without repeated lines. Lines of other fingerprints (another program path, card or driver) and lines of no known shape are kept. It writes a file beside it (`warm-done.txt.new`) and renames it over the old one. It prints `warm-done.txt: N marks of names no pipeline has any more were dropped`, or `was not compacted: <error>` and goes on. - `--used` and `--limit` runs name only some pipelines, so they never compact. - With the switch off, nothing changes (the compaction is behind the same switch). - `KEEP_MARKS` in `play.rs` becomes `pub(crate)` so `warm.rs` reads the same name. README row and `docs/findings.md` say it. ## How it was tested - Tested revision: branch `up-keep-marks-compact` @ `e8f517e2a`, based on main `47d21cd3b`. - Based on main `47d21cd3b`. main is now `d91d8e4d6`; `git merge-tree` merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP). - Commands and results (scoped; the three workspace gates were not run): - `cargo clippy -p darner`, with and without `--all-features`, and the `darner` tests for `warm`, including two new ones (`compacting_the_done_marks_keeps_only_current_names_of_this_fingerprint`, `compacting_the_done_file_rewrites_it_only_when_a_line_goes`), reported clean by the porter; exact flags and counts not kept. I did not re-run them for this text. - Changes a default: no. The switch stays off by default. - A/B result: none. A switch that is off by default; no speed claim. - Gates run on that revision: only the scoped ones above. Not run: the workspace clippy (with and without `--all-features`) and `cargo test --workspace --locked`. - Gameplay: not run in game. Not run: a real preload with the switch on across a translator change. - Shader wave sizes tested: no shader change. - Hardware dependence: see "Spec dependence". - Coverage gaps, to check in a real run before `WIP:` comes off: - A full `darner preload` with the switch on after a translator change: the printed line shows the dropped count, and a second start finds the marks it needs. - `darner preload --used` leaves `warm-done.txt` as it was. - A crash or kill between writing the new file and the rename leaves the old file (the rename is the only step that replaces it); not tested. ## Spec dependence - Likely general: the file handling is plain text over names, with no GPU specifics. - May depend on our specs: nothing known. - Untested elsewhere: every card; whether the driver's cache answers for unchanged DXIL on AMD and Intel (this is the open question of #264, not of this change). ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game; the tests cover the rewrite only. - [x] This PR contains one change based on `main`. - [ ] The diff follows `docs/asset-policy.md`. (Text only; policy not recorded as run for this branch.) - [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 (open PRs only; file lists read through the API, 2026-12-05): - #450, #458 and #463 (and older #165, #234, #270, #365) also edit `apps/darner/src/warm.rs`. #450 has a hunk at about line 828 (in `make`, next to `mod tests`), right where our new tests go (about line 830), so a textual conflict is possible there. #463 changes one test fixture about 55 lines further down; #458 edits `run` and `into_library` far from our hunks. #270 has one hunk (about line 377) a few lines above our `run` hunk (about 388). - #451 and #459 edit `apps/darner/src/play.rs` but not `KEEP_MARKS`; #429, #431 and #435 also list `play.rs`. Our change there is one line. - #451's body points to this compaction as a separate follow-up, so this PR is that follow-up. - Replaces or overlaps: none found (no open PR compacts `warm-done.txt`). This change was made with AI assistance (Claude Code).
Review of #264 (TrustNo1, point 1): with DARNER_PRELOAD_KEEP_MARKS=1 the
done marks survive a translator change, so the file only grew. A warm
over every known pipeline (not --used, not --limit) now rewrites it
without this build's marks of names no pipeline has any more and without
repeated lines; other fingerprints' lines are kept. Written beside the
file and renamed over it. README row and findings updated.

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

Tested e8f517e2a5282bf2e6bfe504de1bef16e3057cc6 on Windows 11 build 26300, NTFS, RTX 3060 Laptop GPU (621.24).

  • I ran the actual darner warm --jobs 1 with DARNER_PRELOAD_KEEP_MARKS=1 in a fresh cache. A small compute pipeline generated from the project's test helpers was named and created on the GPU. After adding one stale mark with the active fingerprint and one mark with a different fingerprint, the second warm reused the existing pipeline, built zero, and dropped exactly one line. The valid and foreign marks survived byte-for-byte. A third warm left the journal hash unchanged.
  • With an empty inventory and two stale marks, the full warm removed both. The switch-off run, --limit 1 and --used preserved the file. Holding the journal open for read/write sharing without delete sharing made the full warm report that compaction failed and exit 0. The original bytes survived. After releasing the handle, the next warm removed the two stale lines and the temporary file.
  • For the interruption case, I used the PR's compaction functions in a standalone harness with one pause added immediately before the rename. I stopped the fixture process at the pause. The original journal was intact, the completed .new remained, and a normal retry replaced the file successfully.

These runs exercised the real GPU pipeline cache and Windows file handling. I did not run a game, switch translators, or simulate a power loss.

Tested `e8f517e2a5282bf2e6bfe504de1bef16e3057cc6` on Windows 11 build 26300, NTFS, RTX 3060 Laptop GPU (621.24). - I ran the actual `darner warm --jobs 1` with `DARNER_PRELOAD_KEEP_MARKS=1` in a fresh cache. A small compute pipeline generated from the project's test helpers was named and created on the GPU. After adding one stale mark with the active fingerprint and one mark with a different fingerprint, the second warm reused the existing pipeline, built zero, and dropped exactly one line. The valid and foreign marks survived byte-for-byte. A third warm left the journal hash unchanged. - With an empty inventory and two stale marks, the full warm removed both. The switch-off run, `--limit 1` and `--used` preserved the file. Holding the journal open for read/write sharing without delete sharing made the full warm report that compaction failed and exit 0. The original bytes survived. After releasing the handle, the next warm removed the two stale lines and the temporary file. - For the interruption case, I used the PR's compaction functions in a standalone harness with one pause added immediately before the rename. I stopped the fixture process at the pause. The original journal was intact, the completed `.new` remained, and a normal retry replaced the file successfully. These runs exercised the real GPU pipeline cache and Windows file handling. I did not run a game, switch translators, or simulate a power loss.
Jesper-A force-pushed up-keep-marks-compact from e8f517e2a5 to 29caad42ee 2026-12-05 16:40:19 +00:00 Compare
Author
Collaborator

Closing this old-engine PR because post-merge replaced the preload marks it changes; 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 marks it changes; 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:31 +00:00
Jesper-A reopened this pull request 2026-12-06 01:52:07 +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-fix][startup][shaders] Preload: a full warm drops stale marks from warm-done.txt (DARNER_PRELOAD_KEEP_MARKS) to WIP: Preload: a full warm drops stale marks from warm-done.txt (DARNER_PRELOAD_KEEP_MARKS) 2026-12-06 03:28:28 +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-keep-marks-compact:Jesper-A-up-keep-marks-compact'
git switch 'Jesper-A-up-keep-marks-compact'

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-keep-marks-compact'
git switch 'Jesper-A-up-keep-marks-compact'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-keep-marks-compact'
git switch 'Jesper-A-up-keep-marks-compact'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Jesper-A-up-keep-marks-compact'
git switch 'Main'
git merge --squash 'Jesper-A-up-keep-marks-compact'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-keep-marks-compact'
git switch 'Main'
git merge 'Jesper-A-up-keep-marks-compact'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!470
No description provided.