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

Closed
mcozcan wants to merge 2 commits from upstream-pr/4579 into main
mcozcan commented 2026-11-30 23:12:00 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mcozcan on 2026-11-30T23:12:00Z.


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 (#4296).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4305 (prelude OOM retry on 8 GB cards: another allocation, the same kind of fallback), #2234 (snapshot pool).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575482306 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579). Originally posted by [mcozcan](https://github.com/mcozcan) on 2026-11-30T23:12:00Z. --- ## 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 (#4296). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4305 (prelude OOM retry on 8 GB cards: another allocation, the same kind of fallback), #2234 (snapshot pool).
andrewpozdnakov7-jpg commented 2026-12-01 16:35:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T16:35:44Z.


#4985 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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7317866024 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7317866024). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T16:35:44Z. --- #4985 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://github.com/trustno1-coder/VIctory-NVIDIA/issues/4985#issuecomment-7317847542) 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.
mcozcan commented 2026-12-01 17:03:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mcozcan on 2026-12-01T17:03:12Z.


@andrewpozdnakov7-jpg thanks for the #4985 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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7318674132 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7318674132). Originally posted by [mcozcan](https://github.com/mcozcan) on 2026-12-01T17:03:12Z. --- @andrewpozdnakov7-jpg thanks for the #4985 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.
andrewpozdnakov7-jpg commented 2026-12-01 17:45:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T17:45:50Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7319811525 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7319811525). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T17:45:50Z. --- 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.
trustno1-coder commented 2026-12-01 18:37:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:37:12Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321229466 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4579#issuecomment-7321229466). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:37:12Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!4579
No description provided.