Texture pool: sweep empty 64 MiB blocks on budget tick without residency #327

Open
finegorko wants to merge 1 commit from upstream-pr/327 into main
finegorko commented 2026-11-26 17:06:08 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by finegorko on 2026-11-26T17:06:08Z.


When VICTORY_RESIDENCY is off, pool::room() updates SPARES from SPARE_KEPT (64) to SPARE (2) at 85% VRAM, but previously never swept TEXTURES. If texture admission pauses (Pool::take() -> rested() stops running) or empty blocks are already sitting idle, up to SPARE_KEPT (4 GiB) of empty 64 MiB heaps remain held until a future allocation.

Change

  • crates/victory-gpu/src/pool.rs:
    • Mirror the residency::on() branch in pool::room(): when limit < SPARE_KEPT, try_lock() TEXTURES and call pool.reclaim(now(), limit, true).
    • Add VICTORY_POOL_RECLAIM (default on; 0 disables; A/B testable via crate::ab::pick).
    • Add unit test sweep_reclaims_empty_spares_without_new_allocations.

Measured (Windows 11, RX 7900 GRE 16 GB, Xbox Series S diag run)

  • When DXGI VRAM crossed 85% (11,973 -> 12,482 MB / 14,488 MB budget), texture pool shrunk from 6,592 MB down to 6,016 MB (-576 MB, 9 empty 64 MiB heaps released back to D3D12/DXGI) without extra texture eviction churn.
  • Note: deliberately leaves resource::let_go_idle() untouched; fragmented pools holding live textures cannot free partial 64 MiB heaps via idle eviction alone, and subtracting only empty_blocks there caused heavy thrashing in prior testing. Complementary to #297.

Validation

  • cargo test -p xtask --locked: 9 passed
  • cargo test -p victory-gpu pool::tests --locked: 9 passed
  • cargo xtask policy: 265 files ok
  • cargo build --locked --profile diag -p victory --features diagnostics: ok
<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6631592719 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/327). Originally posted by [finegorko](https://github.com/finegorko) on 2026-11-26T17:06:08Z. --- When `VICTORY_RESIDENCY` is off, `pool::room()` updates `SPARES` from `SPARE_KEPT` (64) to `SPARE` (2) at 85% VRAM, but previously never swept `TEXTURES`. If texture admission pauses (`Pool::take()` -> `rested()` stops running) or empty blocks are already sitting idle, up to `SPARE_KEPT` (4 GiB) of empty 64 MiB heaps remain held until a future allocation. ### Change - `crates/victory-gpu/src/pool.rs`: - Mirror the `residency::on()` branch in `pool::room()`: when `limit < SPARE_KEPT`, `try_lock()` `TEXTURES` and call `pool.reclaim(now(), limit, true)`. - Add `VICTORY_POOL_RECLAIM` (default on; `0` disables; A/B testable via `crate::ab::pick`). - Add unit test `sweep_reclaims_empty_spares_without_new_allocations`. ### Measured (Windows 11, RX 7900 GRE 16 GB, Xbox Series S diag run) - When DXGI VRAM crossed 85% (`11,973` -> `12,482 MB / 14,488 MB` budget), `texture pool` shrunk from `6,592 MB` down to `6,016 MB` (`-576 MB`, 9 empty 64 MiB heaps released back to D3D12/DXGI) without extra texture eviction churn. - Note: deliberately leaves `resource::let_go_idle()` untouched; fragmented pools holding live textures cannot free partial 64 MiB heaps via idle eviction alone, and subtracting only `empty_blocks` there caused heavy thrashing in prior testing. Complementary to #297. ### Validation - `cargo test -p xtask --locked`: 9 passed - `cargo test -p victory-gpu pool::tests --locked`: 9 passed - `cargo xtask policy`: 265 files ok - `cargo build --locked --profile diag -p victory --features diagnostics`: ok
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/327:upstream-pr/327'
git switch 'upstream-pr/327'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/327'
git switch 'upstream-pr/327'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/327'
git switch 'upstream-pr/327'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/327'
git switch 'main'
git merge --squash 'upstream-pr/327'
git switch 'main'
git merge --ff-only 'upstream-pr/327'
git switch 'main'
git merge 'upstream-pr/327'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!327
No description provided.