GPU: map the pipeline library's file instead of reading it into memory #2129

Open
github-bot wants to merge 3 commits from github-bot/gh-2129 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 05:44 UTC · original
0xkn0wh3r3:gpu/mapped-pipeline-library → main · +683 −53 · 1 files · 3 commits · open

The problem

The host pipeline library is read into memory at start and kept for the whole run: D3D12 reads the bytes a library was made from for as long as it lives. Each save then builds a second full-size copy to write out. Measured on fxceless/victory-fork, the library was 1,352 MB, all of it in the process's own memory.

The fix

  • The library file is mapped instead of read (Blob::Mapped). Only the pages D3D12 touches are in memory, and Windows can drop them without writing anything.
  • A save serialises straight into a mapped staging file (upstream's unique naming) and renames it over the library.
  • The mapped file stays open while mapped. Otherwise a save that renames over it makes Windows discard the old contents, and pages read back as zeros, which D3D12 takes for stored pipelines (this removed the device in the fork's runs).
  • The mapped file is opened sharing read and delete only. No other process can write it in place or truncate it while D3D12 reads it (sharing violation). A save can still rename over it: delete sharing is what the rename needs, and read-only sharing refuses it.
  • A load removes staging files (host-pipelines.bin.tmp-*, and the early and pre-build lists' files) left by runs that ended during a save. A file is removed only if its process ID is not running: "no such process" (error 87) or exited. Denied access counts as running.
  • Every save goes to host-pipelines.next first and is renamed from there over the library, the step a start also takes. If a system refuses to replace a mapped file, the new library waits there and takes over at the next start; the pending file is always the newest library saved.
  • VICTORY_LIBRARY_MAP=0 restores the old behaviour. Its buffer (and the fallback when a staging file can't be mapped) is #2007's fallible zeroed, so a save without memory is still left for later instead of aborting, with #2007's warning.

Ported from fxceless/victory-fork (commit 578d459): the mapping only, re-applied on top of upstream's concurrent loads, unique staging files and pre-build list.

Testing

  • New tests:
    • the_library_file_is_mapped_and_replaced: a save replaces a mapped library while the old mapping still reads the old bytes; the next start reads the new one; a failed serialisation leaves the library as it was and no staging file behind.
    • a_replaced_library_file_still_reads_from_the_disk: an 8 MiB file written past the system cache still reads correctly page by page after being replaced. It fails with the file closed: page 16 reads zeros here.
    • the_next_start_reads_the_library_saved_last: with the library held, saves wait as the pending file (a newer one replacing an older); released, the next save replaces the library and leaves no pending file.
    • a_mapped_library_file_cannot_be_written_meanwhile: while mapped, opening the file to write or truncate fails with a sharing violation; reading it and a save's rename over it work.
    • staging_names_give_their_process, staging_files_of_ended_runs_are_removed: staging files whose process ended are removed (no such process, or exited with a handle held). Those of this process, of a running process, of PID 4 and other files are kept.
  • pipelines_load_on_many_threads_at_once now opens its library from a mapped file.
  • Memory (library_file_memory, ignored measurement, release): for a 256 MiB library file, reading it into memory adds 256.5 MiB of private memory; mapping it and reading every page adds 0.5 MiB.
  • Mutation checks, each caught:
    change fails
    write sharing added back a_mapped_library_file_cannot_be_written_meanwhile
    read-only sharing that test, plus the two replace tests (the rename is refused)
    no clean-up at load staging_files_of_ended_runs_are_removed
    denied access taken as ended same
    an exited process taken as running same
  • cargo test -p victory-gpu --lib on an RTX 5070 Ti, with mapping on and with VICTORY_LIBRARY_MAP=0: all pass except the two tests that already fail on main from the NVIDIA heap cap (#1835).
  • cargo clippy -p victory-gpu --all-targets, with and without --features diagnostics: clean.
  • Not run with a game (no game data here); the 1,352 MB figure is from the fork's run.
  • A process ID reused by an unrelated process keeps that run's staging file until it ends. That is safe, and it happens rarely.
  • #2007 (merged) made the save buffer fallible; this change uses its zeroed for its buffer fallback and needs no buffer when mapping works. #2179 (merged) loads without the library's lock; the mapped bytes stay with the locked library, which is never dropped.

Rebased onto f3578e3

Re-expressed on top of #2007 and #2179: this branch's own fallible buffer and its test (a_save_buffer_the_host_cannot_give_is_an_error) are dropped in favour of #2007's zeroed and a_save_buffer_the_host_cannot_give_is_refused; a save without memory logs #2007's "saved later" warning. Saves keep #2179's lock split (loads lock nothing). cargo test -p victory-gpu --lib: all pass but the two that fail on main here (NVIDIA heap cap); clippy clean with and without --features diagnostics.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 05:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129) `0xkn0wh3r3:gpu/mapped-pipeline-library` → `main` · +683 −53 · 1 files · 3 commits · open ## The problem The host pipeline library is read into memory at start and kept for the whole run: D3D12 reads the bytes a library was made from for as long as it lives. Each save then builds a second full-size copy to write out. Measured on fxceless/victory-fork, the library was 1,352 MB, all of it in the process's own memory. ## The fix - The library file is mapped instead of read (`Blob::Mapped`). Only the pages D3D12 touches are in memory, and Windows can drop them without writing anything. - A save serialises straight into a mapped staging file (upstream's unique naming) and renames it over the library. - The mapped file stays open while mapped. Otherwise a save that renames over it makes Windows discard the old contents, and pages read back as zeros, which D3D12 takes for stored pipelines (this removed the device in the fork's runs). - The mapped file is opened sharing read and delete only. No other process can write it in place or truncate it while D3D12 reads it (sharing violation). A save can still rename over it: delete sharing is what the rename needs, and read-only sharing refuses it. - A load removes staging files (`host-pipelines.bin.tmp-*`, and the early and pre-build lists' files) left by runs that ended during a save. A file is removed only if its process ID is not running: "no such process" (error 87) or exited. Denied access counts as running. - Every save goes to `host-pipelines.next` first and is renamed from there over the library, the step a start also takes. If a system refuses to replace a mapped file, the new library waits there and takes over at the next start; the pending file is always the newest library saved. - `VICTORY_LIBRARY_MAP=0` restores the old behaviour. Its buffer (and the fallback when a staging file can't be mapped) is #2007's fallible `zeroed`, so a save without memory is still left for later instead of aborting, with #2007's warning. Ported from fxceless/victory-fork (commit 578d459): the mapping only, re-applied on top of upstream's concurrent loads, unique staging files and pre-build list. ## Testing - New tests: - `the_library_file_is_mapped_and_replaced`: a save replaces a mapped library while the old mapping still reads the old bytes; the next start reads the new one; a failed serialisation leaves the library as it was and no staging file behind. - `a_replaced_library_file_still_reads_from_the_disk`: an 8 MiB file written past the system cache still reads correctly page by page after being replaced. It fails with the file closed: page 16 reads zeros here. - `the_next_start_reads_the_library_saved_last`: with the library held, saves wait as the pending file (a newer one replacing an older); released, the next save replaces the library and leaves no pending file. - `a_mapped_library_file_cannot_be_written_meanwhile`: while mapped, opening the file to write or truncate fails with a sharing violation; reading it and a save's rename over it work. - `staging_names_give_their_process`, `staging_files_of_ended_runs_are_removed`: staging files whose process ended are removed (no such process, or exited with a handle held). Those of this process, of a running process, of PID 4 and other files are kept. - `pipelines_load_on_many_threads_at_once` now opens its library from a mapped file. - Memory (`library_file_memory`, ignored measurement, release): for a 256 MiB library file, reading it into memory adds 256.5 MiB of private memory; mapping it and reading every page adds 0.5 MiB. - Mutation checks, each caught: | change | fails | |---|---| | write sharing added back | `a_mapped_library_file_cannot_be_written_meanwhile` | | read-only sharing | that test, plus the two replace tests (the rename is refused) | | no clean-up at load | `staging_files_of_ended_runs_are_removed` | | denied access taken as ended | same | | an exited process taken as running | same | - `cargo test -p victory-gpu --lib` on an RTX 5070 Ti, with mapping on and with `VICTORY_LIBRARY_MAP=0`: all pass except the two tests that already fail on `main` from the NVIDIA heap cap (#1835). - `cargo clippy -p victory-gpu --all-targets`, with and without `--features diagnostics`: clean. ## Not covered / Related - Not run with a game (no game data here); the 1,352 MB figure is from the fork's run. - A process ID reused by an unrelated process keeps that run's staging file until it ends. That is safe, and it happens rarely. - #2007 (merged) made the save buffer fallible; this change uses its `zeroed` for its buffer fallback and needs no buffer when mapping works. #2179 (merged) loads without the library's lock; the mapped bytes stay with the locked library, which is never dropped. ### Rebased onto f3578e3 Re-expressed on top of #2007 and #2179: this branch's own fallible buffer and its test (`a_save_buffer_the_host_cannot_give_is_an_error`) are dropped in favour of #2007's `zeroed` and `a_save_buffer_the_host_cannot_give_is_refused`; a save without memory logs #2007's "saved later" warning. Saves keep #2179's lock split (loads lock nothing). `cargo test -p victory-gpu --lib`: all pass but the two that fail on `main` here (NVIDIA heap cap); clippy clean with and without `--features diagnostics`.
The host pipeline library was read into a buffer at start and kept for
the whole run, because the host reads the bytes a library was made from
for as long as it lives; a save serialised the whole library into a
second buffer and wrote it out. On fxceless/victory-fork a world run's
library was 1,352 MB, all of it in the process's own memory; a save of
a 1.7 GB library failing for lack of memory is what #2007 handles.

The file is now mapped: its pages are the file's, only those the host
reads are in memory, and the system can drop them without writing them
anywhere. A save serialises the library straight into a mapping of a
uniquely named staging file and renames it over the library.

The mapped file's handle stays open while it is mapped. A save renames
over the file this run has mapped, and with the handle closed Windows
gives up the old file's contents, so pages of the mapping not in memory
then read as zeros, which the host would take for stored pipelines (the
fork lost the device that way). Where a system refuses to replace a
mapped file, the new library waits as `host-pipelines.next` and takes
the old one's place at the next start. `VICTORY_LIBRARY_MAP=0` reads and
writes through buffers, as before; that buffer, and the one used where a
staging file cannot be mapped, is #2007's fallible one, so a save the
host has no memory for is still left for later instead of aborting.

Ported from fxceless/victory-fork (commit 578d459): the mapping only, on
top of upstream's concurrent loads, unique staging files and pre-build
list (not that commit's other library changes).

Tests:
- `the_library_file_is_mapped_and_replaced`: a mapped file reads as its
  bytes; a save through a mapped staging file replaces the mapped
  library, the old mapping still reads the old bytes, the next start
  reads the new ones, the returned tag is the new bytes', no staging
  file is left, and a failed serialisation leaves the library as it was.
- `a_replaced_library_file_still_reads_from_the_disk`: an 8 MiB file
  written past the system cache, mapped, then replaced by a save; every
  page still reads as the old file. With the handle closed it fails
  (page 16 reads zeros on an RTX 5070 Ti host).
- `pipelines_load_on_many_threads_at_once` now opens its library from a
  mapped file.

Co-authored-by: fxceless <[email protected]>
The library's file was opened with the standard library's sharing (read,
write and delete), so another process could write it in place or
truncate it while the host reads the mapping. It is now opened sharing
read and delete only: writing or truncating it fails with a sharing
violation, while a save still renames the new library over it (delete
sharing is what that needs; read-only sharing refuses the rename).

A run that ended during a save left its staging file behind for good:
the name carries the process ID, and the library's is as big as the
library. A load now removes the staging files of our three files whose
process has ended: no such process (only that refusal counts; denied
access is a running process), or exited with only a handle left.

Tests:
- a_mapped_library_file_cannot_be_written_meanwhile
- staging_names_give_their_process
- staging_files_of_ended_runs_are_removed
- library_file_memory (ignored measurement): 256 MiB file, 256.5 MiB
  private read into memory, 0.5 MiB mapped.
A save renamed the new library over the library's file and wrote it to
`host-pipelines.next` only when that rename failed; a later save whose
rename worked left that older pending file in place, and the next start
renamed it over the newer library (reported on the PR by Dathinel).

Every save now goes to `host-pipelines.next` first and is renamed from
there over the library's file, the step a start also takes. The pending
file is therefore always the newest library saved, or not there: a save
that replaces the library takes it along, and one that cannot is it. A
pending file that cannot itself be replaced (held open without delete
sharing) fails the save, which leaves the library saved before it for
the next start.

`staging_files_of_ended_runs_are_removed` no longer starts processes:
an ID no process can have (IDs are multiples of four from a far smaller
table) stands for an ended run, and this process and PID 4 for running
ones. The case of an exited process whose handle is still held is no
longer covered by a test.

Tests:
- `the_next_start_reads_the_library_saved_last`: the library held
  without delete sharing, two saves wait as the pending file (the second
  replacing the first); released, the next save replaces the library and
  leaves no pending file, and a start reads it. A held pending file fails
  the save and the start reads the one before. It fails on the previous
  code at the stale pending file.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:35 +00:00
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 05:52 UTC · original

I opened #2132 for the same change four minutes after this one, without having seen it; I'm closing mine in favour of this PR, which also takes the save-time copy away. Three things from that work that may be useful here, from synthetic tests on Windows 11 (no GPU, no title):

  1. The share mode decides whether a rename over the mapped file works. With the mapped file opened sharing read access only, an in-place write, a truncation and std::fs::rename over it all fail (the rename with ERROR_ACCESS_DENIED, 5). So your choice of File::open's default sharing (read, write and delete) is what makes the rename work. Its price is that any other process may also write the mapped file in place while D3D12 reads it, and nothing here would notice. I went the other way in #2132 (read-only sharing and a new numbered file per save) for that reason. Whether an in-place writer is realistic here is a judgment call; I mention it because the fork's device loss came from exactly this file changing under the mapping.
  2. A staging file left by a process that ended during a save is never removed. It is as big as the library, the name carries the process ID, so it never repeats, and nothing deletes host-pipelines.bin.tmp-* later. Killing a hung run is routine, so they pile up. In #2132 a load removes those whose process is no longer running (OpenProcess; only "no such process", error 87, counts as ended).
  3. A number for the memory claim: a 256 MiB library file cost 256.5 MiB of private memory read into a Vec and 0.5 MiB mapped (PrivateUsage before and after the load).

AI-assisted (Claude Code). No game data was used.

**@⁠r4tedx** on GitHub · 2026-11-25 05:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7154213503) I opened #2132 for the same change four minutes after this one, without having seen it; I'm closing mine in favour of this PR, which also takes the save-time copy away. Three things from that work that may be useful here, from synthetic tests on Windows 11 (no GPU, no title): 1. **The share mode decides whether a rename over the mapped file works.** With the mapped file opened sharing read access only, an in-place write, a truncation and `std::fs::rename` over it all fail (the rename with `ERROR_ACCESS_DENIED`, 5). So your choice of `File::open`'s default sharing (read, write and delete) is what makes the rename work. Its price is that any other process may also write the mapped file in place while D3D12 reads it, and nothing here would notice. I went the other way in #2132 (read-only sharing and a new numbered file per save) for that reason. Whether an in-place writer is realistic here is a judgment call; I mention it because the fork's device loss came from exactly this file changing under the mapping. 2. **A staging file left by a process that ended during a save is never removed.** It is as big as the library, the name carries the process ID, so it never repeats, and nothing deletes `host-pipelines.bin.tmp-*` later. Killing a hung run is routine, so they pile up. In #2132 a load removes those whose process is no longer running (`OpenProcess`; only "no such process", error 87, counts as ended). 3. **A number for the memory claim:** a 256 MiB library file cost 256.5 MiB of private memory read into a `Vec` and 0.5 MiB mapped (`PrivateUsage` before and after the load). AI-assisted (Claude Code). No game data was used.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 06:11 UTC · original · edited 2026-11-25 06:19 UTC

A pending save can replace a newer successful save at the next load. I reproduced this on Windows at fe997c5 with one process, a temporary directory, and one-byte payloads passed through write_library:

  1. Save A. Hold host-pipelines.bin open for reading with FILE_SHARE_READ only.
  2. Save B. The call succeeds and host-pipelines.next contains B.
  3. Release the handle. Save C. The call succeeds and reading host-pipelines.bin directly returns C.
  4. Call Blob::of(dir). Expected C, got B.

replace_library leaves the previous pending file when the later rename to the canonical path succeeds. Blob::of then promotes that pending file before reading. This sequence would make a useful regression test for whichever ordering scheme you choose. It checks the cache bytes on reopen; no driver, game data, or concurrent writers were involved. AI-assisted.

Follow-up on 2ef0c75. The same regression still reopens generation 2 after generation 3 was saved. Optional fix and regression test: publish each completed save to the pending name first, then try to promote it. The patch applies cleanly to your updated head. With it, the pipeline-library tests passed on Windows (15 passed, one memory measurement ignored), including both a still-held and a released canonical file.

One tradeoff I verified: if the pending file itself is held without delete sharing, the new save returns an error and preserves the previous successful save. The old code reported success in that case but reopened the previous pending bytes anyway. These checks used one process; cross-process ordering and crash durability remain untested.

**@⁠Dathinel** on GitHub · 2026-11-25 06:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7154542083) · edited 2026-11-25 06:19 UTC A pending save can replace a **newer successful save** at the next load. I reproduced this on Windows at `fe997c5` with one process, a temporary directory, and one-byte payloads passed through `write_library`: 1. Save A. Hold `host-pipelines.bin` open for reading with `FILE_SHARE_READ` only. 2. Save B. The call succeeds and `host-pipelines.next` contains B. 3. Release the handle. Save C. The call succeeds and reading `host-pipelines.bin` directly returns C. 4. Call `Blob::of(dir)`. Expected C, got **B**. `replace_library` leaves the previous pending file when the later rename to the canonical path succeeds. `Blob::of` then promotes that pending file before reading. This sequence would make a useful regression test for whichever ordering scheme you choose. It checks the cache bytes on reopen; no driver, game data, or concurrent writers were involved. AI-assisted. **Follow-up on `2ef0c75`.** The same regression still reopens generation 2 after generation 3 was saved. [Optional fix and regression test](https://github.com/Dathinel/VIctory/commit/7af7225e6084a23eda2879668ee476961b0bc32e): publish each completed save to the pending name first, then try to promote it. The patch applies cleanly to your updated head. With it, the pipeline-library tests passed on Windows (15 passed, one memory measurement ignored), including both a still-held and a released canonical file. One tradeoff I verified: if the pending file itself is held without delete sharing, the new save returns an error and preserves the previous successful save. The old code reported success in that case but reopened the previous pending bytes anyway. These checks used one process; cross-process ordering and crash durability remain untested.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 06:13 UTC · original

Thanks, all three were useful. I've pushed 2ef0c75 for them:

  1. Share mode. The mapped file is now opened sharing read and delete only. Opening it to write or to truncate fails with a sharing violation (32), and a save can still rename over it. I confirmed your finding: with read-only sharing the rename is refused, and both replace tests fail. Delete sharing is what the rename needs, and leaving out write sharing keeps other writers out. So this keeps the in-place rename without a numbered file per save. Test: a_mapped_library_file_cannot_be_written_meanwhile.
  2. Abandoned staging files. A load now removes *.tmp-<pid>-<n> files of the library, early list and pre-build list whose process has ended. As in #2132, only "no such process" (87) counts as ended when OpenProcess fails, and denied access counts as running. One addition: a process that has exited while another process still holds its handle (GetExitCodeProcess is no longer STILL_ACTIVE) also counts as ended. Tests: staging_names_give_their_process and staging_files_of_ended_runs_are_removed. The second checks a process ID with no process, an exited process with a handle held, a running process, PID 4, this process and an unrelated file.
  3. Memory. I added your measurement as an ignored test, library_file_memory. It gives the same here: 256.5 MiB private when read into memory, 0.5 MiB mapped, for a 256 MiB file. It is now in the description.

Each new check was mutation-tested (the table is in the description). cargo test -p victory-gpu --lib passes with mapping on and with VICTORY_LIBRARY_MAP=0, except the two NVIDIA #1835 failures. Clippy is clean with and without diagnostics.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 06:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7154578597) Thanks, all three were useful. I've pushed 2ef0c75 for them: 1. **Share mode.** The mapped file is now opened sharing read and delete only. Opening it to write or to truncate fails with a sharing violation (32), and a save can still rename over it. I confirmed your finding: with read-only sharing the rename is refused, and both replace tests fail. Delete sharing is what the rename needs, and leaving out write sharing keeps other writers out. So this keeps the in-place rename without a numbered file per save. Test: `a_mapped_library_file_cannot_be_written_meanwhile`. 2. **Abandoned staging files.** A load now removes `*.tmp-<pid>-<n>` files of the library, early list and pre-build list whose process has ended. As in #2132, only "no such process" (87) counts as ended when `OpenProcess` fails, and denied access counts as running. One addition: a process that has exited while another process still holds its handle (`GetExitCodeProcess` is no longer `STILL_ACTIVE`) also counts as ended. Tests: `staging_names_give_their_process` and `staging_files_of_ended_runs_are_removed`. The second checks a process ID with no process, an exited process with a handle held, a running process, PID 4, this process and an unrelated file. 3. **Memory.** I added your measurement as an ignored test, `library_file_memory`. It gives the same here: 256.5 MiB private when read into memory, 0.5 MiB mapped, for a 256 MiB file. It is now in the description. Each new check was mutation-tested (the table is in the description). `cargo test -p victory-gpu --lib` passes with mapping on and with `VICTORY_LIBRARY_MAP=0`, except the two NVIDIA #1835 failures. Clippy is clean with and without `diagnostics`.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 07:53 UTC · original

I ran the pipeline-library tests at 2ef0c75 on native Windows with D3D12 WARP. The suite returned 14 passed and one ignored measurement.

I also extended the concurrent load test so it replaces the canonical file while the original library still owns its mapped view. A freshly opened library must load the newly added compute PSO, and the threads must still load the original PSOs from the old mapping. The extended suite passed with mapping enabled. When I deliberately republished the previous snapshot, the added assertion failed at the load of the new PSO with HRESULT 0x80070057.

Optional regression test on your exact head. If you fold the test into your commit, please retain this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic shaders only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 07:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7156376247) I ran the pipeline-library tests at **2ef0c75** on native Windows with D3D12 WARP. The suite returned 14 passed and one ignored measurement. I also extended the concurrent load test so it replaces the canonical file while the original library still owns its mapped view. A freshly opened library must load the newly added compute PSO, and the threads must still load the original PSOs from the old mapping. The extended suite passed with mapping enabled. When I deliberately republished the previous snapshot, the added assertion failed at the load of the new PSO with HRESULT 0x80070057. [Optional regression test on your exact head](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/f040754987f36aebae5be12fa0f33698b4f39eae). If you fold the test into your commit, please retain this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic shaders only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:48 UTC · original · edited 2026-11-26 01:21 UTC

Automated triage for the maintainers.

Merge candidate (unchanged). The push since the last triage (3294cf6 to 7577fdb) rebases onto current main and now merges cleanly, including the earlier textual conflict with #2007. In crates/victory-gpu/src/pipeline/library.rs, the branch's own fallible buffer is dropped in favour of main's zeroed (an OutOfMemory error still leaves the save for later, with #2007's warning). write_atomically and the new write_library both keep main's WRITING lock and unique staging names. main's concurrent_write_atomically_never_fails_or_truncates test is kept. The rest is as reviewed before:

  • replace_library renames each save through host-pipelines.next.
  • The mapped file is opened with read and delete sharing only and stays open while mapped.
  • remove_abandoned removes staging files only for ended processes. It queries processes and spawns none.

Optional, as before: the module doc and the share-mode comment cite run figures and the fork, which would sit better in the PR description.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7160201958) · edited 2026-11-26 01:21 UTC <!-- victory-triage v1 head=7577fdb6cbcfbb82e5dc216a9e12712318b85390 verdict=merge-candidate at=2026-11-26T01:21:21Z --> Automated triage for the maintainers. **Merge candidate (unchanged).** The push since the last triage (`3294cf6` to `7577fdb`) rebases onto current `main` and now merges cleanly, including the earlier textual conflict with #2007. In `crates/victory-gpu/src/pipeline/library.rs`, the branch's own fallible buffer is dropped in favour of `main`'s `zeroed` (an `OutOfMemory` error still leaves the save for later, with #2007's warning). `write_atomically` and the new `write_library` both keep `main`'s `WRITING` lock and unique `staging` names. `main`'s `concurrent_write_atomically_never_fails_or_truncates` test is kept. The rest is as reviewed before: - `replace_library` renames each save through `host-pipelines.next`. - The mapped file is opened with read and delete sharing only and stays open while mapped. - `remove_abandoned` removes staging files only for ended processes. It queries processes and spawns none. Optional, as before: the module doc and the share-mode comment cite run figures and the fork, which would sit better in the PR description. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Slay326 on GitHub · 2026-11-25 14:13 UTC · original

Measured on an RTX 3070 with a 3,843 MB library (27,160 pipelines): read whole it is one 3,665 MB private allocation for the run, and save rewrote all of it six times in 130 s with made=0 (only the early list had changed), each time with a second copy in memory: process commit swung between 37.6 and 42.1 GB. With both PRs merged, process commit at start is 10.3 GB instead of 15.6 GB, and no save rewrites the library in a 480 s run.

AI-assisted.

**@⁠Slay326** on GitHub · 2026-11-25 14:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7164939204) Measured on an RTX 3070 with a 3,843 MB library (27,160 pipelines): read whole it is one 3,665 MB private allocation for the run, and `save` rewrote all of it six times in 130 s with `made=0` (only the early list had changed), each time with a second copy in memory: process commit swung between 37.6 and 42.1 GB. With both PRs merged, process commit at start is 10.3 GB instead of 15.6 GB, and no save rewrites the library in a 480 s run. AI-assisted.
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 18:37 UTC · original

Thanks. Both points are fixed in 3294cf6.

  • Stale pending file: every save is now renamed to host-pipelines.next first, then from there over the library, which is the same step a start takes in Blob::of. So a pending file is either the newest save or absent. A save that can't replace the library leaves its bytes in .next, and the next save replaces them. If .next itself is held open, that save fails and the previous library is what the next start reads.
    • @⁠Dathinel, this is the ordering you described. I wrote it fresh rather than taking the linked commit.
    • The new test the_next_start_reads_the_library_saved_last covers your sequence, with the library both held and released, plus a held .next failing the save. It fails on 2ef0c75.
  • Spawned processes: staging_files_of_ended_runs_are_removed no longer starts any. A PID no process can have stands in for an ended run, and this process and PID 4 stand in for running ones. The cost is that the "exited but its handle still held" branch is no longer tested. Covering it would take one short-lived cmd /c exit 0 child, if you'd rather keep that.

@⁠andrewpozdnakov7-jpg, thanks for the concurrent-replacement test. I'd rather keep it as your own commit. If the maintainer wants it in, it can go in as it is. @⁠Slay326, thanks for the commit-charge numbers: 15.6 → 10.3 GB at start with no full rewrites is the effect I was after.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7171178283) Thanks. Both points are fixed in 3294cf6. - **Stale pending file:** every save is now renamed to `host-pipelines.next` first, then from there over the library, which is the same step a start takes in `Blob::of`. So a pending file is either the newest save or absent. A save that can't replace the library leaves its bytes in `.next`, and the next save replaces them. If `.next` itself is held open, that save fails and the previous library is what the next start reads. - @⁠Dathinel, this is the ordering you described. I wrote it fresh rather than taking the linked commit. - The new test `the_next_start_reads_the_library_saved_last` covers your sequence, with the library both held and released, plus a held `.next` failing the save. It fails on 2ef0c75. - **Spawned processes:** `staging_files_of_ended_runs_are_removed` no longer starts any. A PID no process can have stands in for an ended run, and this process and PID 4 stand in for running ones. The cost is that the "exited but its handle still held" branch is no longer tested. Covering it would take one short-lived `cmd /c exit 0` child, if you'd rather keep that. @⁠andrewpozdnakov7-jpg, thanks for the concurrent-replacement test. I'd rather keep it as your own commit. If the maintainer wants it in, it can go in as it is. @⁠Slay326, thanks for the commit-charge numbers: 15.6 → 10.3 GB at start with no full rewrites is the effect I was after.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 05:49 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Pipeline library file mapped instead of read into memory — possible duplicate of #2132 (same pipeline-library mapping change); maintainer should pick one.

**@⁠catminou4** on GitHub · 2026-11-25 05:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#pullrequestreview-6052484454) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Pipeline library file mapped instead of read into memory — **possible duplicate of #2132** (same pipeline-library mapping change); maintainer should pick one.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:39 UTC · original

@⁠0xkn0wh3r3 I checked how the current mapped-library save composes with #2327. The exact heads 7577fdb and e4edac7 conflict in save(). 8eecc26 keeps both heads as parents. It keeps mapped serialization and the pending-file replacement, and restores the taken dirty marks if the mapped write or either list write fails.

On Windows app-local Agility/WARP, the same temp-directory fixture failed a save of each list, removed the block and retried without a new key. Both lists were recovered and the prebuilt list matched the saved library tag. The existing mapped-file replacement and newest-pending-file tests passed. Library suite 19 passed, 1 ignored. Full GPU diagnostics 255 passed, 2 ignored. Strict all-feature GPU Clippy passed.

This is an integration reference if both changes are taken. If moving the probe separately, please preserve the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> when folding it into another commit. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#issuecomment-7193665658) @⁠0xkn0wh3r3 I checked how the current mapped-library save composes with #2327. The exact heads `7577fdb` and `e4edac7` conflict in `save()`. [`8eecc26`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8eecc26f2ff78b000a29bedb8027aae8cae84094) keeps both heads as parents. It keeps mapped serialization and the pending-file replacement, and restores the taken dirty marks if the mapped write or either list write fails. On Windows app-local Agility/WARP, the same temp-directory fixture failed a save of each list, removed the block and retried without a new key. Both lists were recovered and the prebuilt list matched the saved library tag. The existing mapped-file replacement and newest-pending-file tests passed. Library suite 19 passed, 1 ignored. Full GPU diagnostics 255 passed, 2 ignored. Strict all-feature GPU Clippy passed. This is an integration reference if both changes are taken. If moving the probe separately, please preserve the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` when folding it into another commit. AI-assisted with Codex.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 14:15 UTC · original · approved these changes

Reviewed and verified 7577fdb6 (clean merge onto origin/main 63bcca43) on Windows 11 x64 with NVIDIA GeForce RTX 5090 and D3D12 WARP (VICTORY_D3D12_DEBUG=1, Rust 1.98.1).

  • Lifetime & drop ordering: Shared.loads drops before state, Library.library drops before _blob, Mapped::drop calls UnmapViewOfFile before _file closes, and open() drops a rejected blob before creating an empty library. FILE_SHARE_READ | FILE_SHARE_DELETE and the .next two-step publish handle live replacement cleanly.
  • Working-set verification: --release --ignored library_file_memory on RTX 5090 measured 256 MiB library file: 256.5 MiB private read into memory, 0.5 MiB mapped.
  • Non-blocking follow-up / composition notes:
    • Checking len <= isize::MAX before slice::from_raw_parts(_mut) in Mapped::bytes/bytes_mut, logging .bin replacement vs pending .next distinctly (with the rename error), and deferring full-file tag() until the library is accepted and PREBUILT_FILE exists would tighten edge cases further.
    • As noted above, composing save()'s dirty-state rollback on failure with #2327 (or #2803) is well worth keeping when both land.

Local verification at 7577fdb6 (and merged onto origin/main at 75e9d626): xtask policy (190 files ok), cargo clippy -p victory-gpu --all-targets (default and --all-features, 0 warnings), and pipeline::library::tests under VICTORY_D3D12_DEBUG=1 passed on both RTX 5090 (17/17, 1 ignored) and WARP (17/17, 1 ignored). Approving.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2129#pullrequestreview-6075630035) · **approved these changes** Reviewed and verified `7577fdb6` (clean merge onto `origin/main` `63bcca43`) on Windows 11 x64 with **NVIDIA GeForce RTX 5090** and **D3D12 WARP** (`VICTORY_D3D12_DEBUG=1`, Rust 1.98.1). - **Lifetime & drop ordering:** `Shared.loads` drops before `state`, `Library.library` drops before `_blob`, `Mapped::drop` calls `UnmapViewOfFile` before `_file` closes, and `open()` drops a rejected blob before creating an empty library. `FILE_SHARE_READ | FILE_SHARE_DELETE` and the `.next` two-step publish handle live replacement cleanly. - **Working-set verification:** `--release --ignored library_file_memory` on RTX 5090 measured **`256 MiB library file: 256.5 MiB private read into memory, 0.5 MiB mapped`**. - **Non-blocking follow-up / composition notes:** - Checking `len <= isize::MAX` before `slice::from_raw_parts(_mut)` in `Mapped::bytes`/`bytes_mut`, logging `.bin` replacement vs pending `.next` distinctly (with the rename error), and deferring full-file `tag()` until the library is accepted and `PREBUILT_FILE` exists would tighten edge cases further. - As noted above, composing `save()`'s dirty-state rollback on failure with #2327 (or #2803) is well worth keeping when both land. Local verification at `7577fdb6` (and merged onto `origin/main` at `75e9d626`): `xtask policy` (`190 files ok`), `cargo clippy -p victory-gpu --all-targets` (`default` and `--all-features`, 0 warnings), and `pipeline::library::tests` under `VICTORY_D3D12_DEBUG=1` passed on both RTX 5090 (`17/17`, 1 ignored) and WARP (`17/17`, 1 ignored). Approving.
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/2129/head:github-bot/gh-2129'
git switch 'github-bot/gh-2129'

Merge

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