Preserve the shader book when startup cannot read it #4868

Open
senduora wants to merge 1 commit from upstream-pr/4868 into main
senduora commented 2026-12-01 12:07:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by senduora on 2026-12-01T12:07:56Z.


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: #4785 and #3588 concern read error handling in warm and preload commands. Merged #2249 fixes write failures. This change protects the book during startup scanning.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5585365914 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4868). Originally posted by [senduora](https://github.com/senduora) on 2026-12-01T12:07:56Z. --- ## 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: #4785 and #3588 concern read error handling in warm and preload commands. Merged #2249 fixes write failures. This change protects the book during startup scanning.
andrewpozdnakov7-jpg commented 2026-12-01 13:01:42 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T13:01:42Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7311997202 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4868#issuecomment-7311997202). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T13:01:42Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4868:upstream-pr/4868'
git switch 'upstream-pr/4868'

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 'upstream-pr/4868'
git switch 'upstream-pr/4868'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4868'
git switch 'upstream-pr/4868'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4868'
git switch 'main'
git merge --squash 'upstream-pr/4868'
git switch 'main'
git merge --ff-only 'upstream-pr/4868'
git switch 'main'
git merge 'upstream-pr/4868'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!4868
No description provided.