Repository navigation
GPU: a pipeline library save the host has no memory for waits, not aborts (1.7 GB library on NVIDIA) - #2007
Conversation
…orts The library is serialised into one buffer of its whole size, allocated infallibly. On NVIDIA the library holds each pipeline's machine code, about 1.7 GB after translate --cache --pipelines, and a save in the world aborted the process: 'memory allocation of 2650101862 bytes failed' (RTX 4050 Laptop, 32 GB). The buffer is now reserved fallibly; without memory the save is left for later (the pipelines stay counted as added). 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 save with insufficient host memory waits instead of aborting — OOM-path hardening; correct fail-slow behavior for an emulator.
|
Triage verdict — Keep the fallible allocation; preserve early-list retries ( Evidence
Checks and limits
Next step
This verification was AI-assisted. |
…ory for waits, not aborts (1.7 GB library on NVIDIA)
|
Automated triage for the maintainers. Merge candidate.
Optional follow-up, also raised in the earlier review comment: when only the early list is dirty, CI: passing ( Generated by Claude Code |
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 Marvisak#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 asked for fallibly, so a save the host has no memory for is left for later instead of aborting (as Marvisak#2007 does for today's buffer). 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. - `a_save_buffer_the_host_cannot_give_is_an_error`. Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
…ory for waits, not aborts (1.7 GB library on NVIDIA)
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 Marvisak#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 Marvisak#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 <36782933+fxceless@users.noreply.github.com>
Problem
library::saveserialises the pipeline library withvec![0u8; GetSerializedSize()]. On NVIDIA the library holds each pipeline's machine code: aftertranslate --cache --pipelinesit is about 1.7 GB on an RTX 4050 Laptop, where the README mentions about 4 MB on AMD. A save in the world then aborted the whole process:(32 GB RAM, about 21 GB committed by the process at that point.)
Fix
The buffer is reserved with
try_reserve_exact. Without memory, the save logs a warning and returns. The pipelines stay counted as added, so the next save tries again.Verified
a_save_buffer_the_host_cannot_give_is_refused; thepipeline::librarytests pass (9).cargo clippy -p victory-gpu --all-targets -- -D warningsis clean.Related: the size itself (one blob rewritten whole every 20 s) is worth splitting on NVIDIA, but that is a larger change.
Only
crates/victory-gpu/src/pipeline/library.rschanges.AI-assisted.
🤖 Generated with Claude Code