Shadow: snapshot per 64 KiB piece instead of the full copy (fixes #4520) #4927

Closed
github-bot wants to merge 7 commits from github-bot/gh-4926 into main AGit
Owner

@⁠Raesdf on GitHub · 2026-12-01 14:15 UTC · original
Raesdf:fix/snapshot-commit-4520 → main · +661 −254 · 2 files · 7 commits · closed without merging

Fixes #4521

Problem

Shadow::writing committed the snapshot at the full copy length: a 1 MiB declared range on a 256 MiB copy committed ~256 MiB.

Fix

  • Shadow::before is now a sparse Snapshot: one 64 KiB buffer per piece a declared range touches; pieces nothing declared are never allocated.
  • All snapshot readers (copy_back, differing, relay_merge, find_all, merge_under_writes, placed_copy, land_back, copy_back_done) walk piece by piece.
  • The now-unused snapshot pool (POOL, SnapshotPool, pooled, give_back, snapshots_kept, trim_snapshot_pool + its tests) is removed.
  • memory() keeps its [u64; 6] shape; the last two numbers (pool stats) are now 0.

Measurement (test from #4515, cherry-picked)

Before: first range committed +256.8 MiB, second +0.0 MiB.
After: first range committed +1.4 MiB, second +1.0 MiB.

Testing

  • cargo check -p victory-gpu: clean (only the 11 pre-existing fetch_update deprecation warnings).
  • cargo test -p victory-gpu --lib snapshot_tests: 5 passed.
  • cargo test -p victory-gpu --lib: 0 failed.
  • cargo test -p victory-gpu --lib snapshot_commit -- --ignored: 1 passed.
  • VICTORY_KEEP_SNAPSHOTS=1 VICTORY_KEEP_SNAPSHOTS_MB=1 cargo test -p victory-gpu --lib kept_snapshot_growth -- --ignored --test-threads=1: 1 passed.
  • Spare-piece pool + snapshot-bytes logging (latest commit): cargo test -p victory-gpu --lib snapshot_tests 5 passed, 1 ignored; cargo test -p victory-gpu --lib dropped_pieces -- --ignored --test-threads=1 1 passed; measurement test first range +0.6 MiB, second +1.0 MiB (first range better than +1.4: the pool reused pieces from the other test in the same run).

Overlap

  • #4515 (Kerimrode): reuses its ignored measurement test (snapshot_commit_per_declared_byte, commit 359ef8bd, cherry-picked as 4d8a86a0). If #4515 merges first, the cherry-pick can be dropped in a rebase.
  • None (no other PR touches these lines).
**@⁠Raesdf** on GitHub · 2026-12-01 14:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926) `Raesdf:fix/snapshot-commit-4520` → `main` · +661 −254 · 2 files · 7 commits · closed without merging Fixes #4521 ## Problem `Shadow::writing` committed the snapshot at the full copy length: a 1 MiB declared range on a 256 MiB copy committed ~256 MiB. ## Fix - `Shadow::before` is now a sparse `Snapshot`: one 64 KiB buffer per piece a declared range touches; pieces nothing declared are never allocated. - All snapshot readers (`copy_back`, `differing`, `relay_merge`, `find_all`, `merge_under_writes`, `placed_copy`, `land_back`, `copy_back_done`) walk piece by piece. - The now-unused snapshot pool (`POOL`, `SnapshotPool`, `pooled`, `give_back`, `snapshots_kept`, `trim_snapshot_pool` + its tests) is removed. - `memory()` keeps its `[u64; 6]` shape; the last two numbers (pool stats) are now 0. ## Measurement (test from #4515, cherry-picked) Before: first range committed +256.8 MiB, second +0.0 MiB. After: first range committed +1.4 MiB, second +1.0 MiB. ## Testing - `cargo check -p victory-gpu`: clean (only the 11 pre-existing `fetch_update` deprecation warnings). - `cargo test -p victory-gpu --lib snapshot_tests`: 5 passed. - `cargo test -p victory-gpu --lib`: 0 failed. - `cargo test -p victory-gpu --lib snapshot_commit -- --ignored`: 1 passed. - `VICTORY_KEEP_SNAPSHOTS=1 VICTORY_KEEP_SNAPSHOTS_MB=1 cargo test -p victory-gpu --lib kept_snapshot_growth -- --ignored --test-threads=1`: 1 passed. - Spare-piece pool + snapshot-bytes logging (latest commit): `cargo test -p victory-gpu --lib snapshot_tests` 5 passed, 1 ignored; `cargo test -p victory-gpu --lib dropped_pieces -- --ignored --test-threads=1` 1 passed; measurement test first range +0.6 MiB, second +1.0 MiB (first range better than +1.4: the pool reused pieces from the other test in the same run). ## Overlap - #4515 (Kerimrode): reuses its ignored measurement test (`snapshot_commit_per_declared_byte`, commit 359ef8bd, cherry-picked as 4d8a86a0). If #4515 merges first, the cherry-pick can be dropped in a rebase. - None (no other PR touches these lines).
Shadow::writing takes a snapshot the length of the whole copy for any declared range. The test prints working set and committed bytes for a 256 MiB copy with 1 MiB declared. It is #[ignore]d and asserts nothing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Step 2 of #4520 fix: `before` is now a sparse Snapshot of 64 KiB pieces, so a 1 MiB declared range commits ~1 MiB instead of the full 256 MiB copy.

Measurement: first range committed +1.4 MiB (was +256.8), second +1.0 MiB (was +0.0).
The pool is dead since step 2: snapshots are per-piece now, so POOL, SnapshotPool, pooled, give_back, snapshots_kept and trim_snapshot_pool (plus its 3 tests) go away. memory() keeps its [u64; 6] shape with the last two numbers now 0.

Measurement unchanged: first range committed +1.4 MiB, second +1.0 MiB.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 14:17:08 +00:00
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 14:23 UTC · original · reviewed

AI-assisted review; I used an AI assistant to inspect this diff.

**@⁠gut0to** on GitHub · 2026-12-01 14:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#pullrequestreview-6133216787) · **reviewed** AI-assisted review; I used an AI assistant to inspect this diff.
@ -2335,3 +2251,1 @@
assert!(pool.critical);
assert!(pool.sweep(2_000, false, false).is_empty());
assert!(!pool.critical);
fn unaligned_range_allocates_only_the_pieces_it_touches() {
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 14:23 UTC · original

Could this exercise Shadow::pieces with a Shadow whose title-memory start is not 64 KiB aligned? touch_range indexes offsets from zero, while the production mapping also depends on start; the current test therefore does not cover the unaligned-start mapping used by writing, find_all, and land_back. A range crossing an actual title-memory boundary would catch piece-index or offset errors in those paths. AI-assisted review; I used an AI assistant to inspect the diff and trace the piece-offset paths.

**@⁠gut0to** on GitHub · 2026-12-01 14:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#discussion_r4755583721) Could this exercise `Shadow::pieces` with a `Shadow` whose title-memory start is not 64 KiB aligned? `touch_range` indexes offsets from zero, while the production mapping also depends on `start`; the current test therefore does not cover the unaligned-start mapping used by `writing`, `find_all`, and `land_back`. A range crossing an actual title-memory boundary would catch piece-index or offset errors in those paths. AI-assisted review; I used an AI assistant to inspect the diff and trace the piece-offset paths.
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 14:34 UTC · original · reviewed

AI-assisted review; I used an AI assistant to inspect this diff.

**@⁠gut0to** on GitHub · 2026-12-01 14:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#pullrequestreview-6133407149) · **reviewed** AI-assisted review; I used an AI assistant to inspect this diff.
@ -6623,0 +6705,4 @@
} else if kept.1 != 0 && kept.1 != bytes {
// A later submission added pieces to the kept snapshot.
if bytes > kept.1 {
KEPT_BYTES.fetch_add(bytes - kept.1, Ordering::Relaxed);
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 14:34 UTC · original

When a snapshot is already counted, this branch adds newly allocated piece bytes without checking kept_most(). Since later writes can touch additional pieces, KEPT_BYTES can exceed the configured global cap (for example, a snapshot admitted at 1 MiB can later grow by hundreds of MiB). Could you apply the cap check to this delta and stop retaining the snapshot if it no longer fits? A regression test could admit a snapshot below the cap, grow it, and assert the total stays within the limit. AI-assisted review; I traced the accounting from writing through copy_back_done.

**@⁠gut0to** on GitHub · 2026-12-01 14:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#discussion_r4755728193) When a snapshot is already counted, this branch adds newly allocated piece bytes without checking `kept_most()`. Since later writes can touch additional pieces, `KEPT_BYTES` can exceed the configured global cap (for example, a snapshot admitted at 1 MiB can later grow by hundreds of MiB). Could you apply the cap check to this delta and stop retaining the snapshot if it no longer fits? A regression test could admit a snapshot below the cap, grow it, and assert the total stays within the limit. AI-assisted review; I traced the accounting from `writing` through `copy_back_done`.
@ -6623,0 +6705,4 @@
} else if kept.1 != 0 && kept.1 != bytes {
// A later submission added pieces to the kept snapshot.
if bytes > kept.1 {
KEPT_BYTES.fetch_add(bytes - kept.1, Ordering::Relaxed);
Author
Owner

@⁠tyr0nsur on GitHub · 2026-12-01 14:36 UTC · original

I reproduced this on Windows at 9adc3b86 with a CPU-only test of Shadow::writing and copy_back_done. With VICTORY_KEEP_SNAPSHOTS=1, VICTORY_KEEP_SNAPSHOTS_MB=1 and relay off, I declared 512 KiB on a 2 MiB unbacked copy, completed that submission, then declared the next 1 MiB and completed a second submission.

After submission PR head Tested with growth check
1 524,288 bytes 524,288 bytes
2 1,572,864 bytes 0 bytes

The same focused test fails on the PR head and passes when the growth branch checks the total after charging the delta. On refusal, subtract the entire new snapshot size from KEPT_BYTES and clear kept.1, so the existing cleanup frees the snapshot. The reservation at that point includes both the old charge and the delta.

Claude Opus 5.5 helped review the accounting. The numbers are from the local Rust test.

**@⁠tyr0nsur** on GitHub · 2026-12-01 14:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#discussion_r4755757798) I reproduced this on Windows at `9adc3b86` with a CPU-only test of `Shadow::writing` and `copy_back_done`. With `VICTORY_KEEP_SNAPSHOTS=1`, `VICTORY_KEEP_SNAPSHOTS_MB=1` and relay off, I declared 512 KiB on a 2 MiB unbacked copy, completed that submission, then declared the next 1 MiB and completed a second submission. | After submission | PR head | Tested with growth check | | --- | ---: | ---: | | 1 | 524,288 bytes | 524,288 bytes | | 2 | 1,572,864 bytes | 0 bytes | The same focused test fails on the PR head and passes when the growth branch checks the total after charging the delta. On refusal, subtract the **entire** new snapshot size from `KEPT_BYTES` and clear `kept.1`, so the existing cleanup frees the snapshot. The reservation at that point includes both the old charge and the delta. Claude Opus 5.5 helped review the accounting. The numbers are from the local Rust test.
Addresses gut0to's review on #4926: snapshot_tests only exercised an aligned start. The new test unaligned_start_round_trips_through_the_production_mapping writes and reads a range through pieces_of/piece_at with start 5*PIECE+12345 and checks only the touched pieces are allocated.
@ -2335,3 +2251,1 @@
assert!(pool.critical);
assert!(pool.sweep(2_000, false, false).is_empty());
assert!(!pool.critical);
fn unaligned_range_allocates_only_the_pieces_it_touches() {
Author
Owner

@⁠Raesdf on GitHub · 2026-12-01 14:47 UTC · original

Thanks — good catch. The snapshot_tests helpers did assume an aligned start; the mapping itself was already covered by piece_tests::pieces_cover_the_copy_as_the_compare_cuts_it (which loops over unaligned starts), but nothing round-tripped bytes through a Snapshot via the production mapping with an unaligned start. Added unaligned_start_round_trips_through_the_production_mapping in the latest commit: it uses pieces_of/piece_at with start 5 * PIECE + 12345 and checks the bytes land at the right offsets and only the touched pieces are allocated.

**@⁠Raesdf** on GitHub · 2026-12-01 14:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#discussion_r4755910003) Thanks — good catch. The `snapshot_tests` helpers did assume an aligned start; the mapping itself was already covered by `piece_tests::pieces_cover_the_copy_as_the_compare_cuts_it` (which loops over unaligned starts), but nothing round-tripped bytes through a `Snapshot` via the production mapping with an unaligned start. Added `unaligned_start_round_trips_through_the_production_mapping` in the latest commit: it uses `pieces_of`/`piece_at` with start `5 * PIECE + 12345` and checks the bytes land at the right offsets and only the touched pieces are allocated.
copy_back_done charged the growth of a kept snapshot without checking kept_most(), so KEPT_BYTES could exceed the cap (tyr0nsur reproduced 1,572,864 bytes with a 1 MiB cap). The delta is now charged only if the total still fits; otherwise the whole reservation is undone and the snapshot is dropped. Adds ignored regression test kept_snapshot_growth_past_the_cap_is_dropped (run with VICTORY_KEEP_SNAPSHOTS=1 VICTORY_KEEP_SNAPSHOTS_MB=1).
Author
Owner

@⁠Raesdf on GitHub · 2026-12-01 14:58 UTC · original
On crates/victory-gpu/src/shadow.rs line 6708 (outdated):

@@ -6612,26 +6682,46 @@ impl Shadow {
         }
         if keeps() {
             // Kept for the next submission, if it is worth it (a megabyte
-            // or more) and there is room.
+            // or more) and there is room. Counted in `KEPT_BYTES` by the
+            // snapshot's allocated pieces, not the copy's length: a kept
+            // snapshot of a 256 MiB copy with 1 MiB declared is 1 MiB.
+            // `kept.1` holds the bytes counted, so the charge stays exact
+            // when later submissions add pieces to the kept snapshot.
+            // (The `before` lock is taken while `pending` is held, as
+            // `writing` takes them.)
+            let bytes = self
+                .before
+                .lock()
+                .unwrap_or_else(|e| e.into_inner())
+                .as_ref()
+                .map_or(self.len, |snapshot| (snapshot.allocated_pieces() * PIECE) as u64);
             let mut kept = self.kept.lock().unwrap_or_else(|e| e.into_inner());
-            if !kept.1 && self.len >= 1 << 20 {
-                if KEPT_BYTES.fetch_add(self.len, Ordering::Relaxed) + self.len <= kept_most() {
-                    kept.1 = true;
+            if kept.1 == 0 && self.len >= 1 << 20 {
+                if KEPT_BYTES.fetch_add(bytes, Ordering::Relaxed) + bytes <= kept_most() {
+                    kept.1 = bytes;
                 } else {
-                    KEPT_BYTES.fetch_sub(self.len, Ordering::Relaxed);
+                    KEPT_BYTES.fetch_sub(bytes, Ordering::Relaxed);
                 }
+            } else if kept.1 != 0 && kept.1 != bytes {
+                // A later submission added pieces to the kept snapshot.
+                if bytes > kept.1 {
+                    KEPT_BYTES.fetch_add(bytes - kept.1, Ordering::Relaxed);

Thanks, both — you're right, and tyr0nsur's repro nails it. The growth branch in copy_back_done charged the delta without checking the cap. Fixed in the latest commit: the delta is only charged if the total still fits kept_most(); otherwise the whole reservation for the snapshot is undone (KEPT_BYTES -= bytes), kept.1 is cleared, and the existing cleanup drops the snapshot. Added kept_snapshot_growth_past_the_cap_is_dropped (ignored, needs VICTORY_KEEP_SNAPSHOTS=1 VICTORY_KEEP_SNAPSHOTS_MB=1): it admits 512 KiB on a 2 MiB copy, grows it by 1 MiB, and asserts KEPT_BYTES is 0 afterwards. It fails on the old head (1,572,864 bytes) and passes with the fix.

**@⁠Raesdf** on GitHub · 2026-12-01 14:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#discussion_r4756060290) On `crates/victory-gpu/src/shadow.rs` line 6708 (outdated): ```diff @@ -6612,26 +6682,46 @@ impl Shadow { } if keeps() { // Kept for the next submission, if it is worth it (a megabyte - // or more) and there is room. + // or more) and there is room. Counted in `KEPT_BYTES` by the + // snapshot's allocated pieces, not the copy's length: a kept + // snapshot of a 256 MiB copy with 1 MiB declared is 1 MiB. + // `kept.1` holds the bytes counted, so the charge stays exact + // when later submissions add pieces to the kept snapshot. + // (The `before` lock is taken while `pending` is held, as + // `writing` takes them.) + let bytes = self + .before + .lock() + .unwrap_or_else(|e| e.into_inner()) + .as_ref() + .map_or(self.len, |snapshot| (snapshot.allocated_pieces() * PIECE) as u64); let mut kept = self.kept.lock().unwrap_or_else(|e| e.into_inner()); - if !kept.1 && self.len >= 1 << 20 { - if KEPT_BYTES.fetch_add(self.len, Ordering::Relaxed) + self.len <= kept_most() { - kept.1 = true; + if kept.1 == 0 && self.len >= 1 << 20 { + if KEPT_BYTES.fetch_add(bytes, Ordering::Relaxed) + bytes <= kept_most() { + kept.1 = bytes; } else { - KEPT_BYTES.fetch_sub(self.len, Ordering::Relaxed); + KEPT_BYTES.fetch_sub(bytes, Ordering::Relaxed); } + } else if kept.1 != 0 && kept.1 != bytes { + // A later submission added pieces to the kept snapshot. + if bytes > kept.1 { + KEPT_BYTES.fetch_add(bytes - kept.1, Ordering::Relaxed); ``` Thanks, both — you're right, and tyr0nsur's repro nails it. The growth branch in `copy_back_done` charged the delta without checking the cap. Fixed in the latest commit: the delta is only charged if the total still fits `kept_most()`; otherwise the whole reservation for the snapshot is undone (`KEPT_BYTES -= bytes`), `kept.1` is cleared, and the existing cleanup drops the snapshot. Added `kept_snapshot_growth_past_the_cap_is_dropped` (ignored, needs `VICTORY_KEEP_SNAPSHOTS=1 VICTORY_KEEP_SNAPSHOTS_MB=1`): it admits 512 KiB on a 2 MiB copy, grows it by 1 MiB, and asserts `KEPT_BYTES` is 0 afterwards. It fails on the old head (1,572,864 bytes) and passes with the fix.
Author
Owner

@⁠mstrmoos on GitHub · 2026-12-01 17:39 UTC · original

I tried this in the game on an RTX 5080, and on my scene it costs frame time without saving commit.

Setup. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB. Series X, 2560x1440, DLSS Balanced, frame generation off. Standing on a pier for 120 s after a warm-up, about 5,200-5,300 draws a frame. Diagnostics build of my branch (#4836's code). This PR picked cleanly on top. Same session and switches for both runs:

frame (median) p95 p99 frames over 50 ms committed (the memory line)
without 25.0 ms 32.0 34.3 1 26,515 MB
with this PR 29.3 ms 32.9 37.0 26 27,474 MB

A second build with this PR and #4984 (switched off with VICTORY_VIEW_START_REMAINDER=0) gave 30.6 ms on the same scene earlier, against 25.9 without either. So it's two runs pointing the same way, though one of each isn't proof. With it on, the submitting thread was also waiting for the card 4.2 ms a frame, against 0.

My guess is that walking the snapshot piece by piece costs more on the merge and copy-back paths than the full copy did, and that the full-length snapshots #4521 describes aren't where this scene's commit goes. The memory() pool numbers are 0 now, so I can't see snapshot bytes directly. If you have a scene where #4521's growth shows, I'd be glad to rerun there. And if there's a cheap way to log the snapshot bytes held, the two runs above would show whether it saves anything here.

**@⁠mstrmoos** on GitHub · 2026-12-01 17:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#issuecomment-7319635231) I tried this in the game on an RTX 5080, and on my scene it costs frame time without saving commit. **Setup.** RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB. Series X, 2560x1440, DLSS Balanced, frame generation off. Standing on a pier for 120 s after a warm-up, about 5,200-5,300 draws a frame. Diagnostics build of my branch (#4836's code). This PR picked cleanly on top. Same session and switches for both runs: | | frame (median) | p95 | p99 | frames over 50 ms | committed (the memory line) | | --- | --- | --- | --- | --- | --- | | without | 25.0 ms | 32.0 | 34.3 | 1 | 26,515 MB | | with this PR | 29.3 ms | 32.9 | 37.0 | 26 | 27,474 MB | A second build with this PR and #4984 (switched off with `VICTORY_VIEW_START_REMAINDER=0`) gave 30.6 ms on the same scene earlier, against 25.9 without either. So it's two runs pointing the same way, though one of each isn't proof. With it on, the submitting thread was also waiting for the card 4.2 ms a frame, against 0. My guess is that walking the snapshot piece by piece costs more on the merge and copy-back paths than the full copy did, and that the full-length snapshots #4521 describes aren't where this scene's commit goes. The `memory()` pool numbers are 0 now, so I can't see snapshot bytes directly. If you have a scene where #4521's growth shows, I'd be glad to rerun there. And if there's a cheap way to log the snapshot bytes held, the two runs above would show whether it saves anything here.
mstrmoos's in-game test (RTX 5080, pier scene) showed the sparse snapshot
costing frame time without saving commit: 25.0 -> 29.3 ms median, committed
26,515 -> 27,474 MB. The most likely cost is one this change introduced:
every piece was a fresh Box::new([0u8; PIECE]) — a 64 KiB zeroed allocation
per piece, every submission — because the pool was removed entirely.

- Spare-piece pool (exact 64 KiB fit, capped at 512 MiB, the old pool's
  cap): a dropped snapshot's pieces go back to it (Drop for Snapshot), so
  the next submission reuses them instead of allocating and zeroing fresh
  ones. A spare is exactly one piece, so reuse can never commit more than
  the piece itself.
- memory() now reports live snapshots (count) and the bytes their pieces
  hold, in the `snapshots` rows of the memory line — the logging mstrmoos
  asked for, so the two runs can show whether the snapshot bytes drop
  anywhere on his scene.
- New (ignored, needs --test-threads=1) test: dropped pieces return to
  the pool and the counters round-trip.

Verification (Windows):
- snapshot_tests: 5 passed, 1 ignored
- dropped_pieces --ignored --test-threads=1: 1 passed
- snapshot_commit --ignored: first range +0.6 MiB, second +1.0 MiB
  (first range better than +1.4: the pool reused pieces from the other
  test in the same run)
- kept_snapshot_growth --ignored (VICTORY_KEEP_SNAPSHOTS=1,
  VICTORY_KEEP_SNAPSHOTS_MB=1): 1 passed
- cargo test -p victory-gpu --lib: 1096 passed, 1 failed
  (shared_scratch_eliminates_flight_settle_end_to_end — fails only while
  VICTORY_KEEP_SNAPSHOTS=1 is set in the window: relay() is off with kept
  snapshots, so its relay_exact() assert fails; passes alone with a clean
  environment)
github-bot closed this pull request 2026-12-01 18:30:28 +00:00
Author
Owner

@⁠Raesdf on GitHub · 2026-12-01 18:25 UTC · original

Thanks for the in-game numbers — that measurement is exactly what I can't do myself (16 GB RAM, RTX 2070).

You're right: on your scene the trade-off is bad, +4.3 ms median with no commit saved. The most likely cost is one I introduced: every piece is a fresh Box::new([0u8; PIECE]) — a 64 KiB zeroed allocation per piece, every submission — because step 3 removed the snapshot pool entirely. On main the snapshot was one uninitialized pooled Vec, reused; my change made it N fresh zeroed boxes a frame with no reuse at all. On a scene whose ranges cover most of a copy, that's pure overhead with almost nothing saved.

Latest commit adds two things:

  1. A spare-piece pool (exact 64 KiB fit, capped at 512 MiB, the old pool's cap): dropped pieces go back to it, so the next submission reuses them instead of allocating and zeroing fresh ones. Readers don't change.
  2. The logging you asked for: memory() now reports live snapshots (count) and the bytes their pieces hold, in the snapshots rows of the memory line — so the two runs can show whether the snapshot bytes actually drop anywhere on your scene.

Could you rerun the same pier scene with the new build and report the same table plus the snapshots numbers from the memory line? If the frame time is back near 25.0 ms, the pool was the cost. If it's still ~29 ms, the cost is in the merge/copy-back walking, and the next step is a fast path for snapshots that cover the whole copy — the bytes number will tell us whether there's any saving worth protecting there.

**@⁠Raesdf** on GitHub · 2026-12-01 18:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#issuecomment-7320914367) Thanks for the in-game numbers — that measurement is exactly what I can't do myself (16 GB RAM, RTX 2070). You're right: on your scene the trade-off is bad, +4.3 ms median with no commit saved. The most likely cost is one I introduced: every piece is a fresh `Box::new([0u8; PIECE])` — a 64 KiB zeroed allocation per piece, every submission — because step 3 removed the snapshot pool entirely. On main the snapshot was one uninitialized pooled Vec, reused; my change made it N fresh zeroed boxes a frame with no reuse at all. On a scene whose ranges cover most of a copy, that's pure overhead with almost nothing saved. Latest commit adds two things: 1. A spare-piece pool (exact 64 KiB fit, capped at 512 MiB, the old pool's cap): dropped pieces go back to it, so the next submission reuses them instead of allocating and zeroing fresh ones. Readers don't change. 2. The logging you asked for: `memory()` now reports live snapshots (count) and the bytes their pieces hold, in the `snapshots` rows of the memory line — so the two runs can show whether the snapshot bytes actually drop anywhere on your scene. Could you rerun the same pier scene with the new build and report the same table plus the snapshots numbers from the memory line? If the frame time is back near 25.0 ms, the pool was the cost. If it's still ~29 ms, the cost is in the merge/copy-back walking, and the next step is a fast path for snapshots that cover the whole copy — the bytes number will tell us whether there's any saving worth protecting there.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:28 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:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4926#issuecomment-7320992182) 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

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