GPU: the pipeline library is mapped, not read into memory #2130
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2132"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T05:45:56Z.
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
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:49:03Z.
Review: COMMENTED
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.
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T05:49:15Z.
One integration detail for the pipeline-cache PRs: at
226ab31c, loading uses the new mapped backing, whilesave()still allocatesvec![0u8; l.library.GetSerializedSize()]before callingSerialize. The load-side memory measurement therefore leaves the separate save-time allocation in #2007 open.I ran
git merge-tree --write-tree <left> <right>on the three pairs of PR heads. Each reports a content conflict incrates/victory-gpu/src/pipeline/library.rs. If this generation-based version lands, the fallible reservation from #2007 needs to be reapplied to its save path. #2129 takes a different route there (mapped staging file with a fallible buffer fallback). This is a source and merge check only; I didn't measure peak save memory. AI-assisted.Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T05:52:02Z.
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
r4tedx:gpu/pipeline-library-mappedif any of it is wanted there.AI-assisted (Claude Code).
upstream-sync referenced this pull request2026-11-25 15:04:06 +00:00
upstream-sync referenced this pull request2026-11-26 00:03:14 +00:00
upstream-sync referenced this pull request2026-11-26 06:03:43 +00:00
Pull request closed