[pr-fix][shaders] Shader cache prune: staging files a stopped run left go by their age too #377

Open
iBooM72 wants to merge 1 commit from iboom72/cache-prune-staging into main AGit
Contributor

What it changes

  • The problem on main: read from the code only. Cache::prune (crates/darner-pipeline/src/cache.rs:188-189) keeps every .tmp-* file (old = !staging && …). So a staging file left by a run that stopped between writing and renaming stays in the shader cache for good. This only matters with DARNER_SHADER_CACHE_DAYS set, because pruning is opt-in.

Staging files now go by the same age rule as entries. The shortest max_age in use is a day (DARNER_SHADER_CACHE_DAYS=1; 0 turns pruning off), and a write takes far less, so a staging file still being written, by this run or a preload child, is never that old.

It doesn't change the shader cache key: darner-pipeline is not part of DARNER_TRANSLATOR.

How it was tested

  • Tested revision: 9e1d37bf (on main f3840d73)
  • Commands and results:
    • cargo test -p darner-pipeline --locked: 15 passed. prune_removes_old_entries_only_once_hits_are_marked now also has an old staging file removed and a fresh one kept.
    • cargo clippy -p darner-pipeline --all-targets --locked -- -D warnings: clean.
  • Changes a default: no
  • Gates run on that revision: none of the three workspace gates; the darner-pipeline tests and clippy only.
  • Gameplay: not run. Only an opt-in prune changes.
  • Hardware dependence: none.
  • Coverage gaps: not run against a real cache folder.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run: it changes only the opt-in prune, and the test covers both cases.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • 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 (adds mark_pruned after the same loop) and #253 (copy-free keys, same file). Each merges with this branch without a conflict (git merge-tree against their heads).
  • Replaces or overlaps: none found

Checked with AI assistance (Claude Code).

🤖 Generated with Claude Code

<!-- Thanks for the pull request. Start the title with its type (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests) and the area tags, like [pr-fix][memory]. This host has no labels yet, so the tags stay in the title. --> ## What it changes - The problem on main: read from the code only. `Cache::prune` (`crates/darner-pipeline/src/cache.rs:188-189`) keeps every `.tmp-*` file (`old = !staging && …`). So a staging file left by a run that stopped between writing and renaming stays in the shader cache for good. This only matters with `DARNER_SHADER_CACHE_DAYS` set, because pruning is opt-in. Staging files now go by the same age rule as entries. The shortest `max_age` in use is a day (`DARNER_SHADER_CACHE_DAYS=1`; `0` turns pruning off), and a write takes far less, so a staging file still being written, by this run or a preload child, is never that old. It doesn't change the shader cache key: darner-pipeline is not part of `DARNER_TRANSLATOR`. ## How it was tested - Tested revision: `9e1d37bf` (on `main` `f3840d73`) - Commands and results: - `cargo test -p darner-pipeline --locked`: 15 passed. `prune_removes_old_entries_only_once_hits_are_marked` now also has an old staging file removed and a fresh one kept. - `cargo clippy -p darner-pipeline --all-targets --locked -- -D warnings`: clean. - Changes a default: no - Gates run on that revision: none of the three workspace gates; the darner-pipeline tests and clippy only. - Gameplay: not run. Only an opt-in prune changes. - Hardware dependence: none. - Coverage gaps: not run against a real cache folder. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run: it changes only the opt-in prune, and the test covers both cases. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [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 (adds `mark_pruned` after the same loop) and #253 (copy-free keys, same file). Each merges with this branch without a conflict (`git merge-tree` against their heads). - Replaces or overlaps: none found Checked with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Cache::prune kept every .tmp-* file, so one left by a run that stopped
between writing and renaming stayed for good. They now go by the same
max_age as entries: the shortest age in use (DARNER_SHADER_CACHE_DAYS=1)
is a day, and a write takes far less, so a fresh staging file still being
written stays. The prune test now covers both.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/377/head:iboom72/cache-prune-staging'
git switch 'iboom72/cache-prune-staging'

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 'iboom72/cache-prune-staging'
git switch 'iboom72/cache-prune-staging'
git rebase 'main'
git switch 'main'
git merge --ff-only 'iboom72/cache-prune-staging'
git switch 'iboom72/cache-prune-staging'
git rebase 'main'
git switch 'main'
git merge --no-ff 'iboom72/cache-prune-staging'
git switch 'main'
git merge --squash 'iboom72/cache-prune-staging'
git switch 'main'
git merge --ff-only 'iboom72/cache-prune-staging'
git switch 'main'
git merge 'iboom72/cache-prune-staging'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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!377
No description provided.