Snapshot of a private CPU mirror: in pool-sized pieces before the run ends #4580

Closed
github-bot wants to merge 2 commits from github-bot/gh-4579 into main AGit
Owner

@⁠mcozcan on GitHub · 2026-11-30 23:12 UTC · original
mcozcan:pr/snapshot-pieces → main · +115 −15 · 2 files · 2 commits · closed without merging

What it changes

When the packed upload of a submission cannot be allocated, snapshot_private_ranges snapshots only the dirty bytes, in one upload buffer of their whole sum. On a PC at its commit limit that buffer is refused too and the run ends:

WARN  no upload buffer error=... (0x8007000E) size=797179904
WARN  no upload buffer error=... (0x8007000E) size=94371840
ERROR could not snapshot 94371840 dirty bytes from a private CPU mirror

Now, when the whole buffer is refused, the snapshot goes in pieces of at most 4 MiB (SNAPSHOT_PIECE, pool::BUFFER_MOST): pieces that size are cut from the pool's upload blocks, memory already committed, where one has room (and each piece is asked again once the spares are freed, as every upload buffer is). Only a piece still refused ends the run, as before. All the pieces go into the plan's fallback_uploads, kept until retirement as the single buffer was. Nothing waits for memory here: the caller holds the submission lock (and with the relay QUEUE_ORDER, which the landing thread needs), so a wait would stall every submission and free nothing.

How it was tested

  • GPU and profile: RTX 5070 12 GB, Ryzen 5 9600X, 32 GB RAM (20 GB page file at the time), Windows 11 26300, driver 621.24. Series X, 2560x1440, DLSS Performance, DLSS frame generation 2x.
  • Before: the run ended as above during the world's first load (crashes.log: "could not snapshot 94371840 dirty bytes").
  • After: not reproduced since: the page file on this PC was raised to 32 GB, so the 6-minute run after the change never reached the commit limit. The fallback path itself is covered by the updated unit test (dirty bytes only, through the pieces).
  • For shader changes: none.
  • cargo test -p victory-gpu --lib passed for this branch; host::upcheck::tests::private_upload_fallback_snapshots_only_dirty_bytes follows the new signature and still checks that only the dirty bytes are copied. The two failures list::thin::tests::bindings_record_no_work and shader_cache::tests::every_switch_of_the_translator_is_in_the_key fail on main too (#4297).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4306 (prelude OOM retry on 8 GB cards: another allocation, the same kind of fallback), #2234 (snapshot pool).
**@⁠mcozcan** on GitHub · 2026-11-30 23:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579) `mcozcan:pr/snapshot-pieces` → `main` · +115 −15 · 2 files · 2 commits · closed without merging ## What it changes When the packed upload of a submission cannot be allocated, `snapshot_private_ranges` snapshots only the dirty bytes, in one upload buffer of their whole sum. On a PC at its commit limit that buffer is refused too and the run ends: ``` WARN no upload buffer error=... (0x8007000E) size=797179904 WARN no upload buffer error=... (0x8007000E) size=94371840 ERROR could not snapshot 94371840 dirty bytes from a private CPU mirror ``` Now, when the whole buffer is refused, the snapshot goes in pieces of at most 4 MiB (`SNAPSHOT_PIECE`, `pool::BUFFER_MOST`): pieces that size are cut from the pool's upload blocks, memory already committed, where one has room (and each piece is asked again once the spares are freed, as every upload buffer is). Only a piece still refused ends the run, as before. All the pieces go into the plan's `fallback_uploads`, kept until retirement as the single buffer was. Nothing waits for memory here: the caller holds the submission lock (and with the relay `QUEUE_ORDER`, which the landing thread needs), so a wait would stall every submission and free nothing. ## How it was tested - GPU and profile: RTX 5070 12 GB, Ryzen 5 9600X, 32 GB RAM (20 GB page file at the time), Windows 11 26300, driver 621.24. Series X, 2560x1440, DLSS Performance, DLSS frame generation 2x. - Before: the run ended as above during the world's first load (crashes.log: "could not snapshot 94371840 dirty bytes"). - After: not reproduced since: the page file on this PC was raised to 32 GB, so the 6-minute run after the change never reached the commit limit. The fallback path itself is covered by the updated unit test (dirty bytes only, through the pieces). - For shader changes: none. - `cargo test -p victory-gpu --lib` passed for this branch; `host::upcheck::tests::private_upload_fallback_snapshots_only_dirty_bytes` follows the new signature and still checks that only the dirty bytes are copied. The two failures `list::thin::tests::bindings_record_no_work` and `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` fail on `main` too (#4297). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4306 (prelude OOM retry on 8 GB cards: another allocation, the same kind of fallback), #2234 (snapshot pool).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 23:13:55 +00:00
github-bot force-pushed github-bot/gh-4579 from 27065c382d to 0fc96f45ec 2026-12-01 00:05:16 +00:00 Compare
Author
Owner

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

#4986 has another report of the exact failure this PR handles. The 21,766,144-byte upload returned 0x8007000E immediately before the snapshot failed with that same byte count. Log breakdown

I checked the test on 0fc96f45. It snapshots seven dirty bytes and only changes which variable owns the upload. It doesn't force the first allocation to fail, so in a healthy test run it still exercises the single-buffer path. Could the test reject only that first allocation and use a dirty range crossing the 4 MiB boundary? Then the existing readback assertions can check the piecewise path, including that bytes outside the dirty ranges stay untouched.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 16:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7317866024) #4986 has another report of the exact failure this PR handles. The 21,766,144-byte upload returned `0x8007000E` immediately before the snapshot failed with that same byte count. [Log breakdown](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/issues/4986) I checked the test on `0fc96f45`. It snapshots seven dirty bytes and only changes which variable owns the upload. It doesn't force the first allocation to fail, so in a healthy test run it still exercises the single-buffer path. Could the test reject only that first allocation and use a dirty range crossing the 4 MiB boundary? Then the existing readback assertions can check the piecewise path, including that bytes outside the dirty ranges stay untouched.
Author
Owner

@⁠mcozcan on GitHub · 2026-12-01 17:03 UTC · original

@⁠andrewpozdnakov7-jpg thanks for the #4986 report, and you're right about the test. On 0fc96f45 it only moved the upload into a Vec. The first allocation never fails there, so it checks the single-buffer path and nothing else.

I've prepared the test you describe. It will go on this branch once it's built and run here, which can't happen for the next few hours:

  • snapshot_private_ranges now hands its allocations to snapshot_private_ranges_with, which takes the buffer maker as a parameter. The run path calls it with upload_buffer, so the code it runs is the same.
  • New test a_snapshot_refused_whole_goes_in_pieces (host/upcheck.rs): the destination is 8 MiB + 64 bytes, and the dirty ranges are (2, 5) and (4 MiB - 7, 8 MiB + 9), so one range is longer than a piece and crosses the 4 MiB mark. Its maker refuses only the first request (the whole sum) and makes the rest with upload_buffer.
  • It checks the sizes asked for, which must be [4 MiB + 19, 3, 4 MiB, 16]: the small range alone because the next piece doesn't fit beside it, then a full piece, then the tail. It checks that three uploads are kept, and then reads back every byte of the destination. Bytes in the dirty ranges must match the source, which is overwritten with 0xff after recording. Every other byte must still be the 0xcc fill. The source pattern never contains 0xcc or 0xff, so a byte that was skipped or copied late shows up.

The existing seven-byte test stays as the single-buffer case.

**@⁠mcozcan** on GitHub · 2026-12-01 17:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7318674132) @⁠andrewpozdnakov7-jpg thanks for the #4986 report, and you're right about the test. On `0fc96f45` it only moved the upload into a `Vec`. The first allocation never fails there, so it checks the single-buffer path and nothing else. I've prepared the test you describe. It will go on this branch once it's built and run here, which can't happen for the next few hours: - `snapshot_private_ranges` now hands its allocations to `snapshot_private_ranges_with`, which takes the buffer maker as a parameter. The run path calls it with `upload_buffer`, so the code it runs is the same. - New test `a_snapshot_refused_whole_goes_in_pieces` (`host/upcheck.rs`): the destination is 8 MiB + 64 bytes, and the dirty ranges are `(2, 5)` and `(4 MiB - 7, 8 MiB + 9)`, so one range is longer than a piece and crosses the 4 MiB mark. Its maker refuses only the first request (the whole sum) and makes the rest with `upload_buffer`. - It checks the sizes asked for, which must be `[4 MiB + 19, 3, 4 MiB, 16]`: the small range alone because the next piece doesn't fit beside it, then a full piece, then the tail. It checks that three uploads are kept, and then reads back every byte of the destination. Bytes in the dirty ranges must match the source, which is overwritten with `0xff` after recording. Every other byte must still be the `0xcc` fill. The source pattern never contains `0xcc` or `0xff`, so a byte that was skipped or copied late shows up. The existing seven-byte test stays as the single-buffer case.
Author
Owner

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

I ran the exact snapshot helper and both test bodies from 319b7019 on Windows with Rust 1.98.1 and the D3D12 WARP adapter. Both passed in a standalone harness with committed D3D12 buffers.

The new test refused the 4,194,323-byte request, then recorded three uploads of 3, 4,194,304 and 16 bytes. After the GPU fence completed, every dirty byte matched the original source despite the source being overwritten after recording, and every byte outside the dirty ranges retained the sentinel. The seven-byte test also passed on the single-buffer path. This covers the copied bytes and the allocation split in isolation. The outstanding field check is recovery on the original machine under sustained memory pressure.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 17:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7319811525) I ran the exact snapshot helper and both test bodies from `319b7019` on Windows with Rust 1.98.1 and the D3D12 WARP adapter. Both passed in a standalone harness with committed D3D12 buffers. The new test refused the 4,194,323-byte request, then recorded three uploads of 3, 4,194,304 and 16 bytes. After the GPU fence completed, every dirty byte matched the original source despite the source being overwritten after recording, and every byte outside the dirty ranges retained the sentinel. The seven-byte test also passed on the single-buffer path. This covers the copied bytes and the allocation split in isolation. The outstanding field check is recovery on the original machine under sustained memory pressure.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:37 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7321229466) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
github-bot closed this pull request 2026-12-01 18:43:01 +00:00

Pull request closed

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!4580
No description provided.