GPU: bound idle staging, shadow snapshot, arena, and list scratch pools #3442

Open
github-bot wants to merge 1 commit from github-bot/gh-3442 into main AGit
Owner

@⁠Luislariosss on GitHub · 2026-11-27 02:23 UTC · original
Luislariosss:feat/gpu-pool-bounds → main · +150 −40 · 3 files · 1 commits · open

Summary

Bounds four idle GPU/host memory pools that previously retained over 1 GiB of Private Commit across steady-state frames:

  1. Texture staging chunks (texture.rs): lower default CHUNKS_KEPT from 16 (512 MiB of D3D12_HEAP_TYPE_UPLOAD) to 4 (128 MiB), overridable via VICTORY_TEXTURE_STAGING_CHUNKS, and lower KEPT_BYTES for oversized power-of-two staging buffers from 64 MiB to 16 MiB (still covering the 12.7 MiB movie upload path). Excess chunks are drained and dropped outside CHUNKS.lock().
  2. Shadow writeback snapshot pool (shadow.rs): lower default POOL_BYTES from 512 MiB to 128 MiB, overridable via VICTORY_SHADOW_POOL_MB.
  3. Shadow view arena (shadow.rs): release completely empty 16 MiB ArenaChunks past ARENA_SPARE = 1 (preserving existing Slice indices via Option<ArenaChunk> slots and dropping released ID3D12Resources outside ARENA.lock()).
  4. Command-list scratch chunks (host.rs): on HostList::reset(), trim grown scratch chunks past 1 MiB (keeping at least the first chunk, and dropping excess chunks outside scratch.lock()).

Validation

  • cargo test -p victory-gpu --lib -- texture:: shadow:: host::tests::list_scratch: 14/14 passed (including new env-override and excess-arena-chunk release assertions).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics): clean.
  • cargo xtask policy: 191 files ok.
  • 75-second live run comparison on the local stack (2,048 frames presented, 0 errors):
    • Steady-state Private Commit: 11,636.1 MiB → 10,700.5 MiB (−935.6 MiB)
    • Peak Private Commit: 11,636.1 MiB → 11,319.4 MiB (−316.7 MiB)
    • Working Set: 6,882.4 MiB → 6,016.8 MiB (−865.6 MiB)
**@⁠Luislariosss** on GitHub · 2026-11-27 02:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3442) `Luislariosss:feat/gpu-pool-bounds` → `main` · +150 −40 · 3 files · 1 commits · open ### Summary Bounds four idle GPU/host memory pools that previously retained over 1 GiB of Private Commit across steady-state frames: 1. **Texture staging chunks (`texture.rs`)**: lower default `CHUNKS_KEPT` from `16` (512 MiB of `D3D12_HEAP_TYPE_UPLOAD`) to `4` (128 MiB), overridable via `VICTORY_TEXTURE_STAGING_CHUNKS`, and lower `KEPT_BYTES` for oversized power-of-two staging buffers from `64 MiB` to `16 MiB` (still covering the 12.7 MiB movie upload path). Excess chunks are drained and dropped outside `CHUNKS.lock()`. 2. **Shadow writeback snapshot pool (`shadow.rs`)**: lower default `POOL_BYTES` from `512 MiB` to `128 MiB`, overridable via `VICTORY_SHADOW_POOL_MB`. 3. **Shadow view arena (`shadow.rs`)**: release completely empty 16 MiB `ArenaChunk`s past `ARENA_SPARE = 1` (preserving existing `Slice` indices via `Option<ArenaChunk>` slots and dropping released `ID3D12Resource`s outside `ARENA.lock()`). 4. **Command-list scratch chunks (`host.rs`)**: on `HostList::reset()`, trim grown scratch chunks past `1 MiB` (keeping at least the first chunk, and dropping excess chunks outside `scratch.lock()`). ### Validation - `cargo test -p victory-gpu --lib -- texture:: shadow:: host::tests::list_scratch`: 14/14 passed (including new env-override and excess-arena-chunk release assertions). - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`): clean. - `cargo xtask policy`: 191 files ok. - 75-second live run comparison on the local stack (`2,048` frames presented, `0` errors): - Steady-state Private Commit: **11,636.1 MiB → 10,700.5 MiB (−935.6 MiB)** - Peak Private Commit: **11,636.1 MiB → 11,319.4 MiB (−316.7 MiB)** - Working Set: **6,882.4 MiB → 6,016.8 MiB (−865.6 MiB)**
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:34:40 +00:00
Author
Owner

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

LGTM — verified on Windows (RTX 5090):

  • cargo test -p victory-gpu --lib shadow:: (10/10), texture:: (3/3, including staging_chunks_kept_defaults_to_four_and_respects_env), and host:: (34/34 excluding the pre-existing origin/main RTX 5090 dynamic_slots_are_held_until_released failure) all passed
  • cargo clippy -p victory-gpu --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

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

**@⁠Dukestar69** on GitHub · 2026-11-27 02:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/3442#pullrequestreview-6082687714) · **approved these changes** LGTM — verified on Windows (RTX 5090): - `cargo test -p victory-gpu --lib shadow::` (10/10), `texture::` (3/3, including `staging_chunks_kept_defaults_to_four_and_respects_env`), and `host::` (34/34 excluding the pre-existing `origin/main` RTX 5090 `dynamic_slots_are_held_until_released` failure) all passed - `cargo clippy -p victory-gpu --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-27 02:40 UTC · original · approved these changes

Looks good to me — clean, disciplined idle-pool trimming across scratch, snapshot, arena, and texture staging pools with proper lock-free resource drops and safe env-var parsing.

Review & Verification Notes

  • crates/victory-gpu/src/host.rs:1792-1812: HostList::reset trims scratch chunks past 1 MiB (keeping at least one chunk) only when the list is idle, dropping excess chunks outside self.scratch.lock().
  • crates/victory-gpu/src/shadow.rs:120-148, 711-715, 1137-1295: VICTORY_SHADOW_POOL_MB uses saturating_mul(1 << 20) safely across 0, invalid, and huge inputs; Arena tracks live slots as Vec<Option<ArenaChunk>>, returns completely empty chunks past ARENA_SPARE to be dropped after arena() releases the lock, reuses None holes without invalidating remaining Slice indices, and updates log_views to iterate flatten().
  • crates/victory-gpu/src/texture.rs:115-205: recycle() lowers default idle retention (KEPT_BYTES = 16 MiB, DEFAULT_CHUNKS_KEPT = 4, overridable via VICTORY_TEXTURE_STAGING_CHUNKS) and drops excess chunks outside CHUNKS.lock().
  • Verified locally on 5876166d:
    • cargo xtask policy passes (191 files ok).
    • cargo clippy -p victory-gpu (--lib, --tests, and --features diagnostics --lib/--tests, -D warnings) is clean.
    • shadow::tests (9/9) and texture::tests (3/3) pass on discrete D3D12 hardware (VICTORY_D3D12_DEBUG=1, VICTORY_D3D12_GBV=1) and WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1, VICTORY_D3D12_WARP=1).
    • Also verified edge-case probes on discrete D3D12: pool_bytes_for bounds (0, negative, non-numeric, usize::MAX), Arena empty-chunk eviction & None-slot reuse preserving live slice indices, and HostList::reset trimming 4 scratch chunks back down to 1 (524,288 B).
**@⁠fuzeofficlal** on GitHub · 2026-11-27 02:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3442#pullrequestreview-6082778484) · **approved these changes** Looks good to me — clean, disciplined idle-pool trimming across scratch, snapshot, arena, and texture staging pools with proper lock-free resource drops and safe env-var parsing. ### Review & Verification Notes - `crates/victory-gpu/src/host.rs:1792-1812`: `HostList::reset` trims scratch chunks past `1 MiB` (keeping at least one chunk) only when the list is idle, dropping excess chunks outside `self.scratch.lock()`. - `crates/victory-gpu/src/shadow.rs:120-148, 711-715, 1137-1295`: `VICTORY_SHADOW_POOL_MB` uses `saturating_mul(1 << 20)` safely across `0`, invalid, and huge inputs; `Arena` tracks live slots as `Vec<Option<ArenaChunk>>`, returns completely empty chunks past `ARENA_SPARE` to be dropped after `arena()` releases the lock, reuses `None` holes without invalidating remaining `Slice` indices, and updates `log_views` to iterate `flatten()`. - `crates/victory-gpu/src/texture.rs:115-205`: `recycle()` lowers default idle retention (`KEPT_BYTES = 16 MiB`, `DEFAULT_CHUNKS_KEPT = 4`, overridable via `VICTORY_TEXTURE_STAGING_CHUNKS`) and drops excess chunks outside `CHUNKS.lock()`. - Verified locally on `5876166d`: - `cargo xtask policy` passes (`191 files ok`). - `cargo clippy -p victory-gpu` (`--lib`, `--tests`, and `--features diagnostics` `--lib`/`--tests`, `-D warnings`) is clean. - `shadow::tests` (`9/9`) and `texture::tests` (`3/3`) pass on discrete D3D12 hardware (`VICTORY_D3D12_DEBUG=1`, `VICTORY_D3D12_GBV=1`) and WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`, `VICTORY_D3D12_WARP=1`). - Also verified edge-case probes on discrete D3D12: `pool_bytes_for` bounds (`0`, negative, non-numeric, `usize::MAX`), `Arena` empty-chunk eviction & `None`-slot reuse preserving live slice indices, and `HostList::reset` trimming 4 scratch chunks back down to 1 (`524,288` B).
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/3442/head:github-bot/gh-3442'
git switch 'github-bot/gh-3442'

Merge

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