Pipeline library: the newer save takes the old one's place even while the run before still holds it #3747

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

@⁠stasadance on GitHub · 2026-11-30 05:53 UTC · original
stasadance:fix/library-next-under-wine → main · +19 −1 · 1 files · 1 commits · open

What it changes

Under Wine, renaming a file over one that is still mapped is refused. When the previous run's driver teardown still holds the old pipeline library while the next run starts, the newer library saved beside it (.next) never took its place: the start mapped the old file and the previous run's new pipelines were lost (in one case a run that had translated 3,031 new shaders).

The start now asks again for up to 20 s, and if the old file still can't be replaced, reads the newer library from beside it instead of mapping the old one. A save that does get renamed over the library removes any older one left beside it.

How it was tested

  • GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X
  • Before: host-pipelines.next was 684,866,400 B beside the older 682,804,088 B library; the next start logged "the host pipeline library saved last could not take the old one's place" and mapped the older one.
  • After: host-pipelines.next 1,273,989,232 B beside the older 1,273,936,760 B library; the next start loaded the library at 1,273,989,232 B, the newer one.
  • cargo test passed for the crates it touches: native cargo test cannot build victory-gpu on a Linux host (same on main), so no; cargo xwin clippy for the Windows target adds no warning over current main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3698 (clean exits, which give the driver time to let go of the file).
**@⁠stasadance** on GitHub · 2026-11-30 05:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3747) `stasadance:fix/library-next-under-wine` → `main` · +19 −1 · 1 files · 1 commits · open ## What it changes Under Wine, renaming a file over one that is still mapped is refused. When the previous run's driver teardown still holds the old pipeline library while the next run starts, the newer library saved beside it (`.next`) never took its place: the start mapped the old file and the previous run's new pipelines were lost (in one case a run that had translated 3,031 new shaders). The start now asks again for up to 20 s, and if the old file still can't be replaced, reads the newer library from beside it instead of mapping the old one. A save that does get renamed over the library removes any older one left beside it. ## How it was tested - GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X - Before: `host-pipelines.next` was 684,866,400 B beside the older 682,804,088 B library; the next start logged "the host pipeline library saved last could not take the old one's place" and mapped the older one. - After: `host-pipelines.next` 1,273,989,232 B beside the older 1,273,936,760 B library; the next start loaded the library at 1,273,989,232 B, the newer one. - `cargo test` passed for the crates it touches: native `cargo test` cannot build `victory-gpu` on a Linux host (same on main), so no; `cargo xwin clippy` for the Windows target adds no warning over current main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3698 (clean exits, which give the driver time to let go of the file).
Under Wine a rename over a mapped file is refused, and the run before can
still hold the old file while its driver teardown runs. The start asks again
for 20 s, then reads the newer library from beside the old one instead of
mapping the old one. A save renamed over
the library's file removes an older one left beside it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 05:57:17 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-30 06:11 UTC · original · approved these changes

Tested locally merged onto main (41adb551).

  • Merge: Clean merge in crates/victory-gpu/src/pipeline/library.rs.
  • Tests (RTX 5090): cargo test -p victory-gpu --lib pipeline::library:: passed (13 passed; 0 failed, including the_library_file_is_mapped_and_replaced, concurrent_write_atomically_never_fails_or_truncates, and a_replaced_library_file_still_reads_from_the_disk) with 0 new warnings.

Clean fix allowing newer pipeline library saves to replace older mapped files cleanly on Windows. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-30 06:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3747#pullrequestreview-6107617634) · **approved these changes** Tested locally merged onto `main` (`41adb551`). - **Merge**: Clean merge in `crates/victory-gpu/src/pipeline/library.rs`. - **Tests (RTX 5090)**: `cargo test -p victory-gpu --lib pipeline::library::` passed (`13 passed; 0 failed`, including `the_library_file_is_mapped_and_replaced`, `concurrent_write_atomically_never_fails_or_truncates`, and `a_replaced_library_file_still_reads_from_the_disk`) with 0 new warnings. Clean fix allowing newer pipeline library saves to replace older mapped files cleanly on Windows. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 07:19 UTC · original

I tested the native Windows file-selection path on current release/main 41adb551, then with #3747 0571ced applied as d3d4cfb. The test uses tiny generated files and the real Blob::of and replace_library functions. A read handle on the old file excludes delete sharing, and Windows confirmed the replacement was denied in each blocked case.

Scenario Main 41adb551 With #3747
Old handle closes after 650 ms Chooses the old file Promotes .next and chooses it after 0.76 s
Old handle stays open Chooses the old file Chooses .next in memory after 20.18 s, leaving the old file in place
A newer save succeeds while a stale .next is present Next startup promotes the stale file Next startup uses the newly saved file

The identical Windows fixture failed all three checks on main and passed all three with the PR. That verifies the denied-rename paths separately from the earlier normal-path library tests. These timings cover cache selection with generated bytes, before driver deserialization.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 07:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3747#issuecomment-7271604904) I tested the native Windows file-selection path on current release/main `41adb551`, then with #3747 `0571ced` applied as `d3d4cfb`. The test uses tiny generated files and the real `Blob::of` and `replace_library` functions. A read handle on the old file excludes delete sharing, and Windows confirmed the replacement was denied in each blocked case. | Scenario | Main `41adb551` | With #3747 | | --- | --- | --- | | Old handle closes after 650 ms | Chooses the old file | Promotes `.next` and chooses it after 0.76 s | | Old handle stays open | Chooses the old file | Chooses `.next` in memory after 20.18 s, leaving the old file in place | | A newer save succeeds while a stale `.next` is present | Next startup promotes the stale file | Next startup uses the newly saved file | The identical Windows fixture failed all three checks on main and passed all three with the PR. That verifies the denied-rename paths separately from the earlier normal-path library tests. These timings cover cache selection with generated bytes, before driver deserialization. AI-assisted with OpenAI Codex.
# Conflicts:
#	crates/victory-gpu/src/pipeline/library.rs
Author
Owner

@⁠stasadance on GitHub · 2026-12-01 02:13 UTC · original

Merged current main (e1251c3) into this branch (0d18b8a). Main's new replace_library already writes a newer save to NEXT_FILE instead of renaming over the library, so that half of this PR is gone and main's version is kept. What's left is the Wine part: read_scoped retried the NEXT_FILE → library rename only once. Now it retries every 250 ms for up to 20 s, and if Wine still refuses, it reads NEXT_FILE into memory and uses it instead of falling back to the old library with saving off. The diff against main is now that one block in pipeline/library.rs. Windows-target clippy builds with no new warnings. The in-game run in the description was on the pre-merge branch.

**@⁠stasadance** on GitHub · 2026-12-01 02:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3747#issuecomment-7298373912) Merged current main (e1251c3) into this branch (0d18b8a). Main's new `replace_library` already writes a newer save to `NEXT_FILE` instead of renaming over the library, so that half of this PR is gone and main's version is kept. What's left is the Wine part: `read_scoped` retried the `NEXT_FILE` → library rename only once. Now it retries every 250 ms for up to 20 s, and if Wine still refuses, it reads `NEXT_FILE` into memory and uses it instead of falling back to the old library with saving off. The diff against main is now that one block in `pipeline/library.rs`. Windows-target clippy builds with no new warnings. The in-game run in the description was on the pre-merge branch.
github-bot force-pushed github-bot/gh-3747 from 0d18b8ad25 to 3419ebd048 2026-12-01 02:58:52 +00:00 Compare
Author
Owner

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

On 3419ebd0, the promotion loop keeps the library writer lock while it sleeps, potentially blocking a parallel save for the whole 20-second wait.

f1559d739e903fcf334f709dd23a27dc45b9971a acquires the lock for each rename and releases it between attempts. A competing run can update or promote the pending save during the wait. If the pending name goes away because another run promoted it, the reader continues with the primary file. Review commit

I exercised the exact lock and promotion code on Windows with small synthetic library files. A regular file handle prevented the first replacement. The original loop blocked the competing save and loaded the earlier pending bytes. The patch let the other writer save and then promoted and loaded the newest bytes. The staged policy passed. The file-sharing fixture used native Windows, so a Proton retest of this commit would confirm the reported environment.

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 12:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3747#issuecomment-7310688654) On `3419ebd0`, the promotion loop keeps the library writer lock while it sleeps, potentially blocking a parallel save for the whole 20-second wait. f1559d739e903fcf334f709dd23a27dc45b9971a acquires the lock for each rename and releases it between attempts. A competing run can update or promote the pending save during the wait. If the pending name goes away because another run promoted it, the reader continues with the primary file. [Review commit](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/f1559d739e903fcf334f709dd23a27dc45b9971a) I exercised the exact lock and promotion code on Windows with small synthetic library files. A regular file handle prevented the first replacement. The original loop blocked the competing save and loaded the earlier pending bytes. The patch let the other writer save and then promoted and loaded the newest bytes. The staged policy passed. The file-sharing fixture used native Windows, so a Proton retest of this commit would confirm the reported environment. 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/3747/head:github-bot/gh-3747'
git switch 'github-bot/gh-3747'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3747'
git switch 'github-bot/gh-3747'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3747'
git switch 'github-bot/gh-3747'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3747'
git switch 'main'
git merge --squash 'github-bot/gh-3747'
git switch 'main'
git merge --ff-only 'github-bot/gh-3747'
git switch 'main'
git merge 'github-bot/gh-3747'
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!3747
No description provided.