Preserve the shader book when startup cannot read it #4869

Open
github-bot wants to merge 1 commit from github-bot/gh-4868 into main AGit
Owner

@⁠senduora on GitHub · 2026-12-01 12:07 UTC · original
senduora:fix/preserve-shader-book-on-read-error → main · +43 −16 · 1 files · 1 commits · open

What it changes

A failed shader-book scan used to return a byte offset, even when it could not open the file. Startup could then reopen the book for writing and truncate valid records. Propagate scan errors and repair a torn tail only after a successful scan. Successfully read records still count as known.

How it was tested

  • Windows with synthetic cache records and no game data. A sharing restriction that permits opening for writing but denies reading reproduces loss of a valid 41-byte shader book in the baseline scanner from 5fabb46.
  • cargo test --locked --offline -p victory-gpu --lib pipeline::known::tests -- --nocapture --test-threads=1 passed all 15 tests on c6f8f22, including the denied-open regression and successful torn-tail repair.
  • Gameplay shader stalls were not measured.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4786 and #3588 concern read error handling in warm and preload commands. Merged #2249 fixes write failures. This change protects the book during startup scanning.
**@⁠senduora** on GitHub · 2026-12-01 12:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4868) `senduora:fix/preserve-shader-book-on-read-error` → `main` · +43 −16 · 1 files · 1 commits · open ## What it changes A failed shader-book scan used to return a byte offset, even when it could not open the file. Startup could then reopen the book for writing and truncate valid records. Propagate scan errors and repair a torn tail only after a successful scan. Successfully read records still count as known. ## How it was tested - Windows with synthetic cache records and no game data. A sharing restriction that permits opening for writing but denies reading reproduces loss of a valid 41-byte shader book in the baseline scanner from `5fabb46`. - `cargo test --locked --offline -p victory-gpu --lib pipeline::known::tests -- --nocapture --test-threads=1` passed all 15 tests on `c6f8f22`, including the denied-open regression and successful torn-tail repair. - Gameplay shader stalls were not measured. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4786 and #3588 concern read error handling in warm and preload commands. Merged #2249 fixes write failures. This change protects the book during startup scanning.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 12:09:55 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-12-01 13:01 UTC · original

I found another way for the startup repair to discard valid records on c6f8f221. The scans stop at the length they measured. If another run appends before read checks the file again, the new length exceeds the old scan end and can be trimmed as if it were a torn record. This affects both books.

256a480e trims only a torn tail inside the scanned length, rechecks that length through a repair handle that excludes writers, and keeps the scanned file open until the operation finishes. An append can still run while the file is being scanned.

I used real Windows files and the exact startup readers with a callback that appended after the first record. The author head lost the new record in the shader and pipeline cases and trimmed a partial record while a writer was still open. The patch preserved both records in all three cases. The stable torn-tail control still trimmed both files, and staged policy passed for the one changed file.

Please keep the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change in.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 13:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4868#issuecomment-7311997202) I found another way for the startup repair to discard valid records on `c6f8f221`. The scans stop at the length they measured. If another run appends before `read` checks the file again, the new length exceeds the old scan end and can be trimmed as if it were a torn record. This affects both books. [256a480e](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/256a480ef3ef00a6c9ec4757ab58c567ba75192c) trims only a torn tail inside the scanned length, rechecks that length through a repair handle that excludes writers, and keeps the scanned file open until the operation finishes. An append can still run while the file is being scanned. I used real Windows files and the exact startup readers with a callback that appended after the first record. The author head lost the new record in the shader and pipeline cases and trimmed a partial record while a writer was still open. The patch preserved both records in all three cases. The stable torn-tail control still trimmed both files, and staged policy passed for the one changed file. Please keep the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change in. AI-assisted with OpenAI Codex.
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/4869/head:github-bot/gh-4868'
git switch 'github-bot/gh-4868'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4868'
git switch 'github-bot/gh-4868'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4868'
git switch 'github-bot/gh-4868'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4868'
git switch 'main'
git merge --squash 'github-bot/gh-4868'
git switch 'main'
git merge --ff-only 'github-bot/gh-4868'
git switch 'main'
git merge 'github-bot/gh-4868'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/trustno1-coder--VIctory-NVIDIA!4869
No description provided.