Repository navigation
Conversation
D3D12 keeps borrowing the serialized library after creation, so reading the file kept a private copy for the whole run. Keep a read-only view and its handles beside the library and deny write and delete sharing. Flush each save to a staging file and publish it under a fresh generation. The next open takes the newest generation and reclaims older files that are no longer held. The original filename is still accepted as the first generation. GPU-free tests check the bytes and tag, empty and missing files, write and rename protection, and fresh opens after saves. An ignored synthetic test measures process-private memory for a 256 MiB blob.
…o, loads fall back Review follow-ups to mapping the pipeline library: - A periodic save held its lock through the whole write and flush of a library of hundreds of MB, and the workers call it after every pipeline: each waited for the save. A periodic save now gives way to one under way; the shutdown save still waits for it. - A save cut short left a staging file as big as the library, named for its process, which nothing removed. At the next load those of processes that are no longer running are removed. - The load took the newest generation or nothing: an empty newest file, or one another process held for the moment, started an empty library though older ones were there. It now takes the newest file that opens, newest by when it was written and then by generation, so a library a build that writes only the original filename saved later is not outvoted by an older numbered file. - Names compare without case, as the file system does, and the loops that look for a free staging name or generation are bounded. Tests: mapped_blob_survives_saves now checks which staging files go, and mapped_blob_takes_the_newest_file_that_opens covers the fallback and the original filename written later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hared Second review's follow-ups: a load removed every file but the one it opened, so a newer one that did not open for the moment (another process holding it, or a time before its real one after the clock was set back) was lost. Only older ones go now. A staging file is no longer shared while it is written, and only "no such process" counts as a process that ended; the test sets the file times itself instead of relying on their resolution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Pipeline library mapped, not read into memory — possible duplicate of #2129; if both exist, one should be closed. Mapping avoids a full read+alloc, good for startup memory.
|
One integration detail for the pipeline-cache PRs: at I ran |
|
Closing as a duplicate of #2129, which was opened a few minutes before this one and also removes the save-time copy that @Dathinel points out above. What this branch adds beyond it (read-only sharing of the mapped file, numbered files instead of a rename, removal of staging files left by ended runs, a periodic save that gives way to one under way) is written up on #2129; the branch stays at AI-assisted (Claude Code). |
What is wrong
pipeline/library.rsloads the host pipeline library withstd::fs::read(host-pipelines.bin)and keeps theVec<u8>beside theID3D12PipelineLibrary1for the whole run (Library::_blob), because D3D12 borrows the serialized bytes for as long as the library object lives. The file grows with every run's new pipelines, to hundreds of megabytes, and all of it is private committed memory of the process for the run.What changes
MappedBlob: file handle, section and view kept beside the library). Its pages are file-backed, so they cost no private memory and the system can drop them.ERROR_ACCESS_DENIED. That is what makes a mapping safe to keep under D3D12.host-pipelines.bin.<n>withnone higher than any present (MoveFileExWwithout replace, so two savers cannot take the same name). Older files are removed where they can be; the one this run maps stays until it ends.host-pipelines.bincounts as the first, so an existing library is picked up.save(false)after every pipeline. The shutdown save still waits.The pre-built list (
tag) is still computed over the bytes the library was made from.Measured (synthetic, no GPU and no title)
A 256 MiB library file, private memory of the test process (
PrivateUsage):Vec(as onmain)About 256 MiB less private memory for a 256 MiB library, for as long as the run lasts. The title's own library size varies by machine and run; I did not run the title.
Tests
GPU-free, in
pipeline::library::tests:mapped_blob_matches_file: the mapped bytes and theirtagare the file's.mapped_blob_survives_saves: with a mapping held, an in-place write, a truncation and a rename over the file all fail and the mapped bytes stay. Saves publish new generations, and a fresh load sees the newest. Older files go once unmapped. A dead process's staging file goes; this process's stays.mapped_blob_skips_missing_and_empty_files.mapped_blob_takes_the_newest_file_that_opens: an empty newest generation falls back to the one before. An original-name file written after the numbered ones (a build that writes only that name) wins.mapped_blob_private_memory(ignored): the measurement above.The two existing tests that build a library on a device now go through a mapped temporary file.
cargo test -p victory-gpu --features diagnosticswithVICTORY_D3D12_WARP=1(software adapter): 150 passed, 0 failed, 3 ignored.cargo clippy -p victory-gpu --all-targets --all-features -- -D warningsis clean.Limits
host-pipelines.bin, which this one removes once it has published a numbered file. Switching such a build in starts with an empty library, which costs pipeline compilation, not correctness.Credit
The fork
fxceless/victory-forkmaps this file and reports 1,352 MB saved. It also traced a device loss to the file being replaced while mapped, which is what the read-only share mode and the numbered files rule out here. The idea is theirs; the code is written formain.AI-assisted (Claude Code, with a Codex sub-agent for the first version). No game data was used.
🤖 Generated with Claude Code