[pr-fix][startup][shaders] Read a pending pipeline library when promotion is blocked #232

Open
andrewpozdnakov7-jpg wants to merge 3 commits from andrewpozdnakov7-jpg/Darner:port/3747-read-pending-pipeline-library into main
First-time contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

When a Windows reader holds the current library without delete sharing, promotion of the newer pending file can fail with access denied. Read the pending file in that case and leave it available for a later promotion. Keep the existing fallback if the pending file is empty or no longer present.

Restores locally saved VIctory-NVIDIA work from December 1, 2026. Previous review: CodeFloe #389. Adapted by andrewpozdnakov7-jpg (GitHub profile).

How it was tested

  • Tested revision: 16ed5b8 on f3840d7.
  • Commands and results: The current read_scoped logic was exercised with a real Win32 sharing restriction. Main returned Win32 5. The patched revision returned the latest bytes while the old file remained open, then promoted the pending file after the reader closed. cargo check --locked -p darner-gpu --lib --tests, xtask policy, and git diff --check passed.
  • Changes a default: no.
  • Follow-up 6106095: akimfomin found that Blob::read returns Some(Blob::None) for a zero-byte pending file. With the primary held open on Windows, the previous PR returned 0 bytes, while main and this update returned the 19-byte primary in the focused fixture. The update also retained the nonempty-pending path and promotion after release. The fixture used the actual buffered Blob::read, read_scoped and load_cache logic. Added a regression for the empty pending file. cargo check --locked -p darner-gpu --lib --tests, xtask policy and git diff --check passed. A fresh test on the hardware that reported the regression would confirm this new head end to end.
  • Compatibility check at 593668b: merge-tree with #275 succeeds. A Windows file-level fixture on the combined code preserved the busy primary with an empty pending file and returned the data of a valid pending file. The regression checks the primary bytes regardless of whether #275 has already cleaned up the empty file. Asset policy and whitespace checks passed.
  • Gates run on that revision: none of the three workspace-wide gates.
  • Coverage gaps: Synthetic temporary files on Windows. No gameplay.

Checklist

  • I ran this change in the game.
  • 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: #192 also changes library loading, for cache build identity. The sharing case uses a current adapter-scoped cache.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: <!-- optional --> ## What it changes When a Windows reader holds the current library without delete sharing, promotion of the newer pending file can fail with access denied. Read the pending file in that case and leave it available for a later promotion. Keep the existing fallback if the pending file is empty or no longer present. Restores locally saved VIctory-NVIDIA work from December 1, 2026. Previous review: [CodeFloe #389](https://codefloe.com/TrustNo1/Darner/pulls/389). Adapted by [andrewpozdnakov7-jpg](https://git.gtahub.st/andrewpozdnakov7-jpg) ([GitHub profile](https://github.com/andrewpozdnakov7-jpg)). ## How it was tested - Tested revision: 16ed5b8 on f3840d7. - Commands and results: The current read_scoped logic was exercised with a real Win32 sharing restriction. Main returned Win32 5. The patched revision returned the latest bytes while the old file remained open, then promoted the pending file after the reader closed. cargo check --locked -p darner-gpu --lib --tests, xtask policy, and git diff --check passed. - Changes a default: no. - Follow-up 6106095: [akimfomin found](https://git.gtahub.st/TrustNo1/Darner/pulls/232#issuecomment-862007) that Blob::read returns Some(Blob::None) for a zero-byte pending file. With the primary held open on Windows, the previous PR returned 0 bytes, while main and this update returned the 19-byte primary in the focused fixture. The update also retained the nonempty-pending path and promotion after release. The fixture used the actual buffered Blob::read, read_scoped and load_cache logic. Added a regression for the empty pending file. cargo check --locked -p darner-gpu --lib --tests, xtask policy and git diff --check passed. A fresh test on the hardware that reported the regression would confirm this new head end to end. - Compatibility check at 593668b: merge-tree with #275 succeeds. A Windows file-level fixture on the combined code preserved the busy primary with an empty pending file and returned the data of a valid pending file. The regression checks the primary bytes regardless of whether #275 has already cleaned up the empty file. Asset policy and whitespace checks passed. - Gates run on that revision: none of the three workspace-wide gates. - Coverage gaps: Synthetic temporary files on Windows. No gameplay. ## Checklist - [ ] I ran this change in the game. - [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: #192 also changes library loading, for cache build identity. The sharing case uses a current adapter-scoped cache. - Replaces or overlaps: none found
Adapt locally saved VIctory-NVIDIA work from December 1, 2026 (0571ced, f1559d7). Read the pending snapshot when Windows blocks its promotion and leave it in place for a later retry.

https://git.gtahub.st/andrewpozdnakov7-jpg
https://github.com/andrewpozdnakov7-jpg

Co-authored-by: Stas Darevskiy <[email protected]>
First-time contributor

The valid pending library works on hardware. I also found a regression in the empty-file fallback described in the PR. I held a real 58,063,156-byte primary host-pipelines.bin open on Windows with read/write sharing, without delete sharing. Each test used an isolated copy, the matching translator marker and the same adapter.

Build host-pipelines.next at startup Library the game actually opened
Stock .02 (f3840d7) 0 bytes After OS error 5, mapped the valid primary, 58,063,156 bytes
PR 16ed5b8 0 bytes Reported no host pipeline library yet and started an empty one
PR 16ed5b8 290,461,638 bytes, valid Mapped 290,461,638 bytes, as intended

All three reached the world and exited normally. The primary SHA-256 stayed unchanged. In the empty-file PR case, the game wrote a new 97,035,640-byte pending library while the old primary was still held.

Blob::read represents an existing zero-byte file as Ok(Some(Blob::None)). In the blocked-rename branch, Some(blob) therefore reports success for the empty file. Returning the promotion error for Some(Blob::None) as well as None would let load_cache use its existing read-only fallback for the valid primary. A regression case can reuse the existing held-reader fixture with a zero-length pending file.

Windows 11, RTX 4070 Ti SUPER, driver 617.14. Both nonempty files were real libraries from this adapter. Tested with Codex assistance.

The valid pending library works on hardware. I also found a regression in the empty-file fallback described in the PR. I held a real 58,063,156-byte primary `host-pipelines.bin` open on Windows with read/write sharing, without delete sharing. Each test used an isolated copy, the matching translator marker and the same adapter. | Build | `host-pipelines.next` at startup | Library the game actually opened | |---|---:|---| | Stock .02 (`f3840d7`) | 0 bytes | After OS error 5, mapped the valid primary, 58,063,156 bytes | | PR `16ed5b8` | 0 bytes | Reported `no host pipeline library yet` and started an empty one | | PR `16ed5b8` | 290,461,638 bytes, valid | Mapped 290,461,638 bytes, as intended | All three reached the world and exited normally. The primary SHA-256 stayed unchanged. In the empty-file PR case, the game wrote a new 97,035,640-byte pending library while the old primary was still held. `Blob::read` represents an existing zero-byte file as `Ok(Some(Blob::None))`. In the blocked-rename branch, `Some(blob)` therefore reports success for the empty file. Returning the promotion error for `Some(Blob::None)` as well as `None` would let `load_cache` use its existing read-only fallback for the valid primary. A regression case can reuse the existing held-reader fixture with a zero-length pending file. Windows 11, RTX 4070 Ti SUPER, driver 617.14. Both nonempty files were real libraries from this adapter. Tested with Codex assistance.
Blob::read returns Some(Blob::None) for an empty pending file. Preserve the original promotion error in that case so load_cache can use its read-only fallback to the valid primary. Reuse the held-reader setup to cover the empty-file regression reported at #232 (comment).

https://git.gtahub.st/andrewpozdnakov7-jpg
https://github.com/andrewpozdnakov7-jpg

Co-authored-by: akimfomin <[email protected]>
First-time contributor

I tested a one-line fix on top of 16ed5b8. In read_scoped’s failed rename branch, handle the empty Blob before accepting a pending library:

return match Blob::read(&next)? {
    Some(Blob::None) | None => Err(promotion),
    Some(blob) => Ok(Some(blob)),
};

The existing load_cache error path then opens the primary read-only. I rebuilt the full executable and repeated both hardware cases with the same input file hashes and Windows sharing flags as my previous comment:

  • Held primary + empty pending: mapped the original 58,063,156 bytes, reached the world, exited 0. The primary hash stayed identical and the pending file stayed zero bytes. The unmodified PR had started an empty library here.
  • Held primary + valid pending: mapped the newer 290,461,638 bytes, reached the world, exited 0. The primary hash stayed identical and the pending save updated normally.

A separate Windows file-level fixture compiled the PR’s and the patched cache-reading code, with mapped reads disabled. It also checked a held primary with no pending file and a promotable valid pending file: behavior stayed the same in both controls. This change covers a zero-byte pending file when promotion fails; I did not test a nonempty corrupt library.

I tested a one-line fix on top of 16ed5b8. In read_scoped’s **failed rename** branch, handle the empty Blob before accepting a pending library: ```rust return match Blob::read(&next)? { Some(Blob::None) | None => Err(promotion), Some(blob) => Ok(Some(blob)), }; ``` The existing load_cache error path then opens the primary read-only. I rebuilt the full executable and repeated both hardware cases with the same input file hashes and Windows sharing flags as my previous comment: - Held primary + empty pending: mapped the original **58,063,156 bytes**, reached the world, exited 0. The primary hash stayed identical and the pending file stayed zero bytes. The unmodified PR had started an empty library here. - Held primary + valid pending: mapped the newer **290,461,638 bytes**, reached the world, exited 0. The primary hash stayed identical and the pending save updated normally. A separate Windows file-level fixture compiled the PR’s and the patched cache-reading code, with mapped reads disabled. It also checked a held primary with no pending file and a promotable valid pending file: behavior stayed the same in both controls. This change covers a zero-byte pending file when promotion fails; I did not test a nonempty corrupt library.
First-time contributor

I checked the next startup after the held-reader test on 6106095cee265a8c6977bf15d3bb07e3877b03cc and on f3840d73. The Windows file-level fixture used a 16-byte primary and a deliberately empty pending file. With a reader holding the primary without delete sharing, promotion returned Windows error 5 and the first load returned the original 16 bytes. I then dropped both the returned blob and the reader and reopened the same directory. On both revisions the empty pending file replaced the primary. The second load returned zero bytes, the primary on disk was zero bytes, and the pending file was gone.

With a nonempty pending file, the second load returned its contents and promoted it correctly. Mapped and buffered reads gave the same results. The second-start behavior also occurs on main. This fixture seeds the empty file explicitly and does not establish how often it occurs in gameplay.

I checked the next startup after the held-reader test on `6106095cee265a8c6977bf15d3bb07e3877b03cc` and on `f3840d73`. The Windows file-level fixture used a 16-byte primary and a deliberately empty pending file. With a reader holding the primary without delete sharing, promotion returned Windows error 5 and the first load returned the original 16 bytes. I then dropped both the returned blob and the reader and reopened the same directory. On both revisions the empty pending file replaced the primary. The second load returned zero bytes, the primary on disk was zero bytes, and the pending file was gone. With a nonempty pending file, the second load returned its contents and promoted it correctly. Mapped and buffered reads gave the same results. The second-start behavior also occurs on main. This fixture seeds the empty file explicitly and does not establish how often it occurs in gameplay.
Verify that the busy primary is returned and stays intact. The cache can keep its save destination once the empty pending file is cleaned up by #275.

#275
Author
First-time contributor

Thanks for checking the second startup, @superhero-520. #275 now cleans up the empty pending file under the writer lease. I checked the combined code on Windows. With the primary held open, empty pending data leaves the primary intact and a valid pending file is still read.

593668b keeps this PR's regression focused on the bytes returned and preserved. That allows the same test to cover both the current fallback and the cleanup from #275. The two branches merge cleanly.

Thanks for checking the second startup, @superhero-520. [#275](https://git.gtahub.st/TrustNo1/Darner/pulls/275) now cleans up the empty pending file under the writer lease. I checked the combined code on Windows. With the primary held open, empty pending data leaves the primary intact and a valid pending file is still read. `593668b` keeps this PR's regression focused on the bytes returned and preserved. That allows the same test to cover both the current fallback and the cleanup from #275. The two branches merge cleanly.
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 'port/3747-read-pending-pipeline-library:andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'

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 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git rebase 'main'
git switch 'main'
git merge --ff-only 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git rebase 'main'
git switch 'main'
git merge --no-ff 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'main'
git merge --squash 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'main'
git merge --ff-only 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git switch 'main'
git merge 'andrewpozdnakov7-jpg-port/3747-read-pending-pipeline-library'
git push origin 'main'
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!232
No description provided.