gpu: keep the snapshot pool sorted; binary-search take/insert instead of scan + re-sort #3384

Open
github-bot wants to merge 2 commits from github-bot/gh-3384 into main AGit
Owner

@⁠borosf on GitHub · 2026-11-26 21:14 UTC · original
borosf:vibe/pool-scan-842ca5 → main · +86 −32 · 1 files · 2 commits · open

What

0dd0f3d (andrewpozdnakov7-jpg's combined resolution) taken as abc64683: one PR now carries the whole
snapshot-pool change.

  • Sorted best fit — the pool stays ordered by capacity, largest first. take is one partition_point
    plus a remove of the smallest buffer that fits; give_back inserts at the partition point. This replaces
    the linear scan on every take and the re-sort on every return.
  • main's retention — give_back keeps the largest buffers up to POOL_BYTES (512 MiB), unchanged.
  • Retry from #2153 — when no pooled buffer fits and the fresh try_reserve_exact fails, take logs
    snapshot allocation failed; freeing the idle pool, clears the idle pool, and reserves once more instead
    of aborting the snapshot.
  • Own-pool test — the_snapshot_pool_preserves_best_fit_and_order builds a SnapshotPool of its own
    instead of driving the shared POOL, so it no longer races the other shadow::tests that take snapshots.

Credits: Co-authored-by: andrewpozdnakov7-jpg (the combined resolution, 0dd0f3d) and
Co-authored-by: desplmfao (the allocation retry, #2153) are both on the commit.

Claimed on #1633 (pool maintenance follows the sweep claims).

Measurement (Windows 11 x64, B580, synthetic Vec pool of 2,000 buffers, debug build, 3 rounds)

cargo test -p victory-gpu --lib --locked -- --test-threads=1 --exact shadow::tests::bench_old_pool --nocapture   (temp bench, removed after)
2000x (take 16 KiB + give back) at pool 2000:  OLD 305.6 / 300.9 / 289.4 ms  vs  NEW 30.3 / 35.9 / 34.3 ms  (~8.8x median)
2000x take-only:                              OLD ~67-73 ms               vs  NEW ~4.0-5.0 ms             (~15.5x median)

Per snapshot segment per frame this removes the O(pool) scan and the O(pool log pool) sort under the global
POOL mutex.

Verification (head abc64683, Windows 11 x64, B580)

  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1 — 11 passed, 0 failed, including
    shadow::tests::the_snapshot_pool_preserves_best_fit_and_order
  • cargo test -p victory-gpu --lib --no-fail-fast -- --test-threads=1 — 230 passed, 2 failed, 1 ignored;
    the two are the known B580 baseline (#1744/#1829):
    descriptor::host::tests::dynamic_slots_are_held_until_released and
    memory::tests::lists_share_a_table_and_copies_keep_their_views
  • clippy clean -D warnings, default features and --all-features
  • fmt gate: shadow.rs 39 hunks = origin/main baseline (39)
  • cargo xtask policy — 191 files ok

Synthetic tests only; no game data used.

**@⁠borosf** on GitHub · 2026-11-26 21:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384) `borosf:vibe/pool-scan-842ca5` → `main` · +86 −32 · 1 files · 2 commits · open ## What `0dd0f3d` (andrewpozdnakov7-jpg's combined resolution) taken as `abc64683`: one PR now carries the whole snapshot-pool change. - **Sorted best fit** — the pool stays ordered by capacity, largest first. `take` is one `partition_point` plus a `remove` of the smallest buffer that fits; `give_back` inserts at the partition point. This replaces the linear scan on every take and the re-sort on every return. - **`main`'s retention** — `give_back` keeps the largest buffers up to `POOL_BYTES` (512 MiB), unchanged. - **Retry from #2153** — when no pooled buffer fits and the fresh `try_reserve_exact` fails, `take` logs `snapshot allocation failed; freeing the idle pool`, clears the idle pool, and reserves once more instead of aborting the snapshot. - **Own-pool test** — `the_snapshot_pool_preserves_best_fit_and_order` builds a `SnapshotPool` of its own instead of driving the shared `POOL`, so it no longer races the other `shadow::tests` that take snapshots. Credits: `Co-authored-by: andrewpozdnakov7-jpg` (the combined resolution, `0dd0f3d`) and `Co-authored-by: desplmfao` (the allocation retry, #2153) are both on the commit. Claimed on #1633 (pool maintenance follows the sweep claims). ## Measurement (Windows 11 x64, B580, synthetic Vec pool of 2,000 buffers, debug build, 3 rounds) ``` cargo test -p victory-gpu --lib --locked -- --test-threads=1 --exact shadow::tests::bench_old_pool --nocapture (temp bench, removed after) 2000x (take 16 KiB + give back) at pool 2000: OLD 305.6 / 300.9 / 289.4 ms vs NEW 30.3 / 35.9 / 34.3 ms (~8.8x median) 2000x take-only: OLD ~67-73 ms vs NEW ~4.0-5.0 ms (~15.5x median) ``` Per snapshot segment per frame this removes the O(pool) scan and the O(pool log pool) sort under the global `POOL` mutex. ## Verification (head `abc64683`, Windows 11 x64, B580) - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1` — 11 passed, 0 failed, including `shadow::tests::the_snapshot_pool_preserves_best_fit_and_order` - `cargo test -p victory-gpu --lib --no-fail-fast -- --test-threads=1` — 230 passed, 2 failed, 1 ignored; the two are the known B580 baseline (#1744/#1829): `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views` - clippy clean `-D warnings`, default features and `--all-features` - fmt gate: `shadow.rs` 39 hunks = `origin/main` baseline (39) - `cargo xtask policy` — 191 files ok Synthetic tests only; no game data used.
pooled() scanned the whole pool for the smallest fitting buffer and
give_back() re-sorted it on every return. The pool is now kept sorted by
capacity (largest first): take is one partition_point, give_back inserts
at the partition point. Same best-fit and POOL_BYTES semantics.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:06:11 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 21:29 UTC · original · approved these changes

LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Maintaining the snapshot pool in sorted order and binary-searching on take/insert preserves best-fit allocation semantics without repeated scans and re-sorts.
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11 passed, 0 failed (including the_pool_stays_sorted_and_best_fit_without_resorting).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 21:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#pullrequestreview-6080648408) · **approved these changes** LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Maintaining the snapshot pool in sorted order and binary-searching on take/insert preserves best-fit allocation semantics without repeated scans and re-sorts. - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: 11 passed, 0 failed (including `the_pool_stays_sorted_and_best_fit_without_resorting`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 21:41 UTC · original · approved these changes

Looks clean and preserves exact best-fit and POOL_BYTES retention semantics.

Verified all accesses to POOL in crates/victory-gpu/src/shadow.rs (pooled at line 105, give_back at line 123, and the new test at line 1315): keeping POOL descending by capacity ensures partition_point(|v| v.capacity() >= n).checked_sub(1) selects the smallest buffer that fits (remove(i) preserves the sorted order) and give_back inserts in sorted order before retain trims to POOL_BYTES.

Verification on origin/main (63bcca43):

  • cargo xtask policy: ok (191 files ok)
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics): clean
  • cargo test --locked -p victory-gpu --features diagnostics -- shadow::tests:: with VICTORY_D3D12_DEBUG=1: 10/10 passed on RTX 5090 (200 take/return cycles at pool size 2,000 in 1.52 ms) and 10/10 passed on WARP (1.56 ms)
  • Additional edge-case check covering empty pool, n = 0, duplicate capacities, n > max, and POOL_BYTES overflow eviction: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 21:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#pullrequestreview-6080767114) · **approved these changes** Looks clean and preserves exact best-fit and `POOL_BYTES` retention semantics. Verified all accesses to `POOL` in `crates/victory-gpu/src/shadow.rs` (`pooled` at line 105, `give_back` at line 123, and the new test at line 1315): keeping `POOL` descending by capacity ensures `partition_point(|v| v.capacity() >= n).checked_sub(1)` selects the smallest buffer that fits (`remove(i)` preserves the sorted order) and `give_back` inserts in sorted order before `retain` trims to `POOL_BYTES`. Verification on `origin/main` (`63bcca43`): - `cargo xtask policy`: ok (`191 files ok`) - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`): clean - `cargo test --locked -p victory-gpu --features diagnostics -- shadow::tests::` with `VICTORY_D3D12_DEBUG=1`: 10/10 passed on RTX 5090 (200 take/return cycles at pool size 2,000 in 1.52 ms) and 10/10 passed on WARP (1.56 ms) - Additional edge-case check covering empty pool, `n = 0`, duplicate capacities, `n > max`, and `POOL_BYTES` overflow eviction: passed.
Author
Owner

@⁠passerbyyhx on GitHub · 2026-11-26 22:33 UTC · original

Independent Release check on Windows 11 26H2 / i9-14900HX (Rust 1.98.1, AC, Balanced). I compared 63bcca43 with 2b0d14c using the real shadow::pooled and give_back functions with pre-touched synthetic buffers. Each of 12 pairs used fresh processes and alternated run order. Each cell timed 40,000 take/return cycles after warming up.

Kept buffers Fixed request, parent → PR ns/cycle Mixed requests, parent → PR ns/cycle PR faster, fixed / mixed
8 46.02 → 41.54 50.42 → 41.72 9/12 · 10/12
128 689.19 → 148.18 757.80 → 169.64 12/12 · 12/12
2,000 11,527.38 → 1,428.74 9,042.99 → 1,300.31 12/12 · 12/12

The 8-buffer timing ranges overlap. At 128 and 2,000 buffers the head was faster in every pair for both request patterns. Both revisions passed the same best-fit, miss, equal-capacity and exact-512-MiB retention checks. An oversized return emptied the pool on both revisions.

This measures the hot single-threaded pool cycle. It leaves title frame time and lock contention unmeasured. Synthetic fixture

AI-assisted with Codex.

**@⁠passerbyyhx** on GitHub · 2026-11-26 22:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7204778651) Independent Release check on Windows 11 26H2 / i9-14900HX (Rust 1.98.1, AC, Balanced). I compared `63bcca43` with `2b0d14c` using the real `shadow::pooled` and `give_back` functions with pre-touched synthetic buffers. Each of 12 pairs used fresh processes and alternated run order. Each cell timed 40,000 take/return cycles after warming up. | Kept buffers | Fixed request, parent → PR ns/cycle | Mixed requests, parent → PR ns/cycle | PR faster, fixed / mixed | | ---: | ---: | ---: | ---: | | 8 | 46.02 → 41.54 | 50.42 → 41.72 | 9/12 · 10/12 | | 128 | 689.19 → 148.18 | 757.80 → 169.64 | 12/12 · 12/12 | | 2,000 | 11,527.38 → 1,428.74 | 9,042.99 → 1,300.31 | 12/12 · 12/12 | The 8-buffer timing ranges overlap. At 128 and 2,000 buffers the head was faster in every pair for both request patterns. Both revisions passed the same best-fit, miss, equal-capacity and exact-512-MiB retention checks. An oversized return emptied the pool on both revisions. This measures the hot single-threaded pool cycle. It leaves title frame time and lock contention unmeasured. [Synthetic fixture](https://github.com/passerbyyhx/VIctory/commit/a410ed17808a4ecb9a86dcc6b12cc2247cf87acc) AI-assisted with Codex.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 22:34 UTC · original

Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX:

  • shadow::tests::the_pool_stays_sorted_and_best_fit_without_resorting by name: 1 passed.
  • cargo test -p victory-gpu --lib: 232 passed / 0 failed / 1 ignored (unpatched 63bcca4 here: 231).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 22:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7204796984) Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX: - `shadow::tests::the_pool_stays_sorted_and_best_fit_without_resorting` by name: 1 passed. - `cargo test -p victory-gpu --lib`: 232 passed / 0 failed / 1 ignored (unpatched `63bcca4` here: 231). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. Synthetic only. AI-assisted.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 23:06 UTC · original

I resolved the shadow.rs conflict between #3384 2b0d14c and #2153 c21a054 in 0dd0f3d. The merge keeps sorted best-fit reuse and the 512 MiB retention policy, and releases idle buffers before retrying a failed fresh reservation.

The original #3384 test shared the process-wide pool. One controlled peer take between the two length checks made it see 1,998 entries when it expected 1,999. The replacement uses its own pool and keeps the best-fit, sorted order, return and successful miss checks. All 11 shadow tests, strict Clippy in both configurations and asset policy passed.

Using a test-only allocator in a separate process, I rejected the first synthetic reservation. The combined code made two attempts, freed both idle buffers and returned the requested empty buffer. With a successful first reservation, there was one attempt and both idle buffers stayed.

@⁠borosf, the combined branch is ready if you coordinate the overlapping change with @⁠desplmfao. If you reapply the resolution or its pool regression, please retain the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 23:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7205265610) I resolved the `shadow.rs` conflict between #3384 `2b0d14c` and #2153 `c21a054` in [`0dd0f3d`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/0dd0f3d6a2b5dbd6f78063c196060439ceb9d5fc). The merge keeps sorted best-fit reuse and the 512 MiB retention policy, and releases idle buffers before retrying a failed fresh reservation. The original #3384 test shared the process-wide pool. One controlled peer take between the two length checks made it see 1,998 entries when it expected 1,999. The replacement uses its own pool and keeps the best-fit, sorted order, return and successful miss checks. All 11 shadow tests, strict Clippy in both configurations and asset policy passed. Using a test-only allocator in a separate process, I rejected the first synthetic reservation. The combined code made two attempts, freed both idle buffers and returned the requested empty buffer. With a successful first reservation, there was one attempt and both idle buffers stayed. @⁠borosf, the combined branch is ready if you coordinate the overlapping change with @⁠desplmfao. If you reapply the resolution or its pool regression, please retain the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-27 02:58 UTC · original

I measured the shared pool under contention on an Apple M1 (Rust 1.98.1, optimized), comparing base 63bcca43 with PR 2b0d14c9. Four workers started together and each ran 1,024 take/return cycles through the production mutex, rotating requests across four prefilled size classes (1–4 KiB). Every take returned the expected capacity, and the final pool contained exactly the starting capacities on both revisions.

Buffers in pool Base ns/cycle PR ns/cycle Pairs won by PR
16 136 156 3/12
128 1,316 334 12/12
512 3,289 1,251 12/12

Each time is median wall time divided by the cycles completed across all four workers. I alternated revision order across 12 pairs. At 128 and 512 buffers the improvement also held in every pair with one and two workers. The small pool showed no consistent gain.

AI-assisted with Codex.

**@⁠rezioliver-collab** on GitHub · 2026-11-27 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7208597205) I measured the shared pool under contention on an Apple M1 (Rust 1.98.1, optimized), comparing base 63bcca43 with PR 2b0d14c9. Four workers started together and each ran 1,024 take/return cycles through the production mutex, rotating requests across four prefilled size classes (1–4 KiB). Every take returned the expected capacity, and the final pool contained exactly the starting capacities on both revisions. | Buffers in pool | Base ns/cycle | PR ns/cycle | Pairs won by PR | | ---: | ---: | ---: | ---: | | 16 | 136 | 156 | 3/12 | | 128 | 1,316 | 334 | 12/12 | | 512 | 3,289 | 1,251 | 12/12 | Each time is median wall time divided by the cycles completed across all four workers. I alternated revision order across 12 pairs. At 128 and 512 buffers the improvement also held in every pair with one and two workers. The small pool showed no consistent gain. AI-assisted with Codex.
Author
Owner

@⁠borosf on GitHub · 2026-11-27 06:38 UTC · original

Three independent verifications, all pointing the same way — thank you.

  • @⁠passerbyyhx: 128 kept buffers 689.19 → 148.18 ns/cycle, 2,000 buffers 11,527.38 → 1,428.74 (12/12 pairs both request patterns); 8 buffers within noise.
  • @⁠rezioliver-collab: under four-worker contention, 128 → 334 vs 1,316 ns/cycle and 512 → 1,251 vs 3,289 (12/12 pairs), 16 buffers no consistent gain.
  • @⁠Jackster: Radeon RX 7900 XTX, 232 passed / 0 failed / 1 ignored (main: 231), clippy clean, the new test by name passes.

That is the shape the change predicts: the win is partition_point/insert on a sorted vector replacing a full scan plus sort, so it grows with the pool and disappears when the pool is small enough for the scan to beat the search.

On @⁠andrewpozdnakov7-jpg's note about the combined branch and the overlapping change: I will not reapply that resolution without agreeing the shape with @⁠desplmfao first, and if I do, the Git author stays or the Co-authored-by: line goes in — the same rule as #3224.

Synthetic fixtures only, no game data.

**@⁠borosf** on GitHub · 2026-11-27 06:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7211715218) Three independent verifications, all pointing the same way — thank you. - @⁠passerbyyhx: 128 kept buffers 689.19 → 148.18 ns/cycle, 2,000 buffers 11,527.38 → 1,428.74 (12/12 pairs both request patterns); 8 buffers within noise. - @⁠rezioliver-collab: under four-worker contention, 128 → 334 vs 1,316 ns/cycle and 512 → 1,251 vs 3,289 (12/12 pairs), 16 buffers no consistent gain. - @⁠Jackster: Radeon RX 7900 XTX, 232 passed / 0 failed / 1 ignored (main: 231), clippy clean, the new test by name passes. That is the shape the change predicts: the win is `partition_point`/`insert` on a sorted vector replacing a full scan plus sort, so it grows with the pool and disappears when the pool is small enough for the scan to beat the search. On @⁠andrewpozdnakov7-jpg's note about the combined branch and the overlapping change: I will not reapply that resolution without agreeing the shape with @⁠desplmfao first, and if I do, the Git author stays or the `Co-authored-by:` line goes in — the same rule as #3224. Synthetic fixtures only, no game data.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-27 08:20 UTC · original · edited 2026-11-27 09:08 UTC

@⁠borosf thanks for checking first. Yes, please take @⁠andrewpozdnakov7-jpg's combined resolution (0dd0f3d) into this PR: sorted best-fit, main's 512 MiB retention, and the retry from #2153 (free the idle pool and reserve once more when a fresh reservation fails). Then only one PR touches pooled/give_back, and his own-pool test fixes the shared-pool race in the original test as well. Once this PR carries the retry, I'll close #2153 in favour of it. @⁠andrewpozdnakov7-jpg's Co-authored-by should stay as he asked.

**@⁠desplmfao** on GitHub · 2026-11-27 08:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7213424197) · edited 2026-11-27 09:08 UTC @⁠borosf thanks for checking first. Yes, please take @⁠andrewpozdnakov7-jpg's combined resolution (`0dd0f3d`) into this PR: sorted best-fit, `main`'s 512 MiB retention, and the retry from #2153 (free the idle pool and reserve once more when a fresh reservation fails). Then only one PR touches `pooled`/`give_back`, and his own-pool test fixes the shared-pool race in the original test as well. Once this PR carries the retry, I'll close #2153 in favour of it. @⁠andrewpozdnakov7-jpg's `Co-authored-by` should stay as he asked.
Takes andrewpozdnakov7-jpg's combined resolution (0dd0f3d): the sorted best-fit
take and the binary-search insert stay, main's 512 MiB retention stays, and the
retry from #2153 goes in -- a snapshot whose fresh reservation fails frees the
idle pool and reserves once more instead of aborting. The pool becomes a
SnapshotPool with `take` and `give_back`, and its test uses a pool of its own
rather than the shared one, which also fixes the race the shared pool left in
the original test.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Co-authored-by: desplmfao <[email protected]>

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
Author
Owner

@⁠borosf on GitHub · 2026-11-27 08:48 UTC · original

Done — 0dd0f3d is in as abc64683, so this PR now carries the whole snapshot-pool change in one place:

  • sorted best fit: take is one partition_point + remove, give_back inserts at the partition point (the linear scan and the per-return re-sort are gone)
  • main's 512 MiB retention, unchanged
  • the retry from #2153: when no pooled buffer fits and the fresh try_reserve_exact fails, it warns, clears the idle pool, and reserves once more instead of aborting the snapshot
  • the pool is a SnapshotPool with take/give_back, and the_snapshot_pool_preserves_best_fit_and_order builds its own pool rather than driving the shared POOL, so it no longer races the other shadow::tests that take snapshots

Both Co-authored-by trailers are on the commit: andrewpozdnakov7-jpg for the combined resolution and desplmfao for the retry. @⁠desplmfao — you said no credit was needed for the 15 lines, but the request in this thread was to credit you too, so the trailer is on the commit; say the word and I will drop it.

Verification at abc64683 (Windows 11 x64, Arc B580): shadow:: 11 passed / 0 failed including the new test; full victory-gpu lib 230 passed, 2 failed, 1 ignored, the two being the known B580 baseline (#1744/#1829, dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views); clippy clean with -D warnings for default and --all-features; fmt gate on shadow.rs 39 hunks = origin/main baseline; cargo xtask policy 191 files ok.

I also rewrote the three hunks of the combined resolution that rustfmt would have reformatted (static POOL, the warn!, and the capacities closure in the test) so the fmt gate stays at the baseline count — content unchanged. #2153 can be closed in favour of this one whenever you want.

Synthetic tests only, no game data used.

**@⁠borosf** on GitHub · 2026-11-27 08:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7213938297) Done — `0dd0f3d` is in as `abc64683`, so this PR now carries the whole snapshot-pool change in one place: - sorted best fit: `take` is one `partition_point` + `remove`, `give_back` inserts at the partition point (the linear scan and the per-return re-sort are gone) - `main`'s 512 MiB retention, unchanged - the retry from #2153: when no pooled buffer fits and the fresh `try_reserve_exact` fails, it warns, clears the idle pool, and reserves once more instead of aborting the snapshot - the pool is a `SnapshotPool` with `take`/`give_back`, and `the_snapshot_pool_preserves_best_fit_and_order` builds its own pool rather than driving the shared `POOL`, so it no longer races the other `shadow::tests` that take snapshots Both `Co-authored-by` trailers are on the commit: `andrewpozdnakov7-jpg` for the combined resolution and `desplmfao` for the retry. @⁠desplmfao — you said no credit was needed for the 15 lines, but the request in this thread was to credit you too, so the trailer is on the commit; say the word and I will drop it. Verification at `abc64683` (Windows 11 x64, Arc B580): `shadow::` 11 passed / 0 failed including the new test; full `victory-gpu` lib 230 passed, 2 failed, 1 ignored, the two being the known B580 baseline (#1744/#1829, `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`); clippy clean with `-D warnings` for default and `--all-features`; fmt gate on `shadow.rs` 39 hunks = `origin/main` baseline; `cargo xtask policy` 191 files ok. I also rewrote the three hunks of the combined resolution that rustfmt would have reformatted (`static POOL`, the `warn!`, and the `capacities` closure in the test) so the fmt gate stays at the baseline count — content unchanged. #2153 can be closed in favour of this one whenever you want. Synthetic tests only, no game data used.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-27 09:07 UTC · original

@⁠borosf thanks, that's exactly it, and the trailer is fine as it is. #2153 is closed in favour of this PR.

**@⁠desplmfao** on GitHub · 2026-11-27 09:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7214307747) @⁠borosf thanks, that's exactly it, and the trailer is fine as it is. #2153 is closed in favour of this PR.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-27 09:08 UTC · original · edited 2026-11-27 09:10 UTC

@⁠borosf a correction to my earlier comment: please keep the Co-authored-by: desplmfao trailer. The "no credit needed" line was Claude's mistake (the AI assistant that drafts these comments for me), not something I asked for. Thanks for keeping it in anyway.

**@⁠desplmfao** on GitHub · 2026-11-27 09:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7214330765) · edited 2026-11-27 09:10 UTC @⁠borosf a correction to my earlier comment: please keep the `Co-authored-by: desplmfao` trailer. The "no credit needed" line was Claude's mistake (the AI assistant that drafts these comments for me), not something I asked for. Thanks for keeping it in anyway.
Author
Owner

@⁠borosf on GitHub · 2026-11-27 10:50 UTC · original

Good — the Co-authored-by: desplmfao trailer is on the commit (abc64683), as is andrewpozdnakov7-jpg's, so nothing needs changing on my side. Thanks for the correction and for closing #2153 in favour of this one.

Current state: head abc64683, one file (crates/victory-gpu/src/shadow.rs), mergeable, CI green (2m43s). shadow:: 11/11 locally including the_snapshot_pool_preserves_best_fit_and_order; full victory-gpu lib 230 passed / 2 failed / 1 ignored, the two being the known B580 baseline (#1744/#1829); clippy clean for default and --all-features; fmt gate 39 = origin/main baseline; cargo xtask policy 191 files ok.

**@⁠borosf** on GitHub · 2026-11-27 10:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3384#issuecomment-7216372046) Good — the `Co-authored-by: desplmfao` trailer is on the commit (`abc64683`), as is `andrewpozdnakov7-jpg`'s, so nothing needs changing on my side. Thanks for the correction and for closing #2153 in favour of this one. Current state: head `abc64683`, one file (`crates/victory-gpu/src/shadow.rs`), mergeable, CI green (2m43s). `shadow::` 11/11 locally including `the_snapshot_pool_preserves_best_fit_and_order`; full `victory-gpu` lib 230 passed / 2 failed / 1 ignored, the two being the known B580 baseline (#1744/#1829); clippy clean for default and `--all-features`; fmt gate 39 = `origin/main` baseline; `cargo xtask policy` 191 files ok.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3384/head:github-bot/gh-3384'
git switch 'github-bot/gh-3384'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3384'
git switch 'github-bot/gh-3384'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3384'
git switch 'github-bot/gh-3384'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3384'
git switch 'main'
git merge --squash 'github-bot/gh-3384'
git switch 'main'
git merge --ff-only 'github-bot/gh-3384'
git switch 'main'
git merge 'github-bot/gh-3384'
git push origin 'main'
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/Marvisak--VIctory!3384
No description provided.