Texture pool: fullest block and best range first, eviction from the emptiest blocks (8 GB card stays under budget) #1337

Closed
Agam77055 wants to merge 1 commit from upstream-pr/1337 into main
Agam77055 commented 2026-11-28 17:39:53 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Agam77055 on 2026-11-28T17:39:53Z.


On an 8 GB card the texture pool kept the card over its budget for a whole session. Free space inside the 64 MB texture blocks counted as room, but eviction by age only made more of those holes, because a block goes back to the system only when it is empty.

PC: RTX 5060 Laptop 8 GB (driver 621.40), i7-13620H, 24 GB RAM, Windows 11 26300. Series S, DLSS Performance, VICTORY_TEXTURE_POOL=1, VICTORY_SLOT_EVICT=1.

What changes

  • pool.rs:
    • A texture goes into the fullest block it fits in, at the free range that leaves least over. VICTORY_POOL_FIT=first gives the old first fit.
    • Ranges keeps its total.
    • New block_of() and block_held() let eviction know which block a texture lies in and how much of each block is held.
    • The pool census and a line of evictions since the start are logged every five seconds in every run.
  • resource.rs: under pressure, the sweep takes textures with allocations of their own first, then textures from the blocks least held, then by age. VICTORY_EVICT_ORDER=age gives the old order, longest idle first. Adds eviction_counts().

Measured

The texture queue's room lines, first fifth of each run left out. Same switches in both runs; the only difference is this change.

before with this change
Card memory in use (median) 7,167 MB 5,968 MB
Card budget (median) 6,890 MB 6,615 MB
Room lines over budget 100 % 0 %
Free inside texture blocks (median) 1,634 MB 620 MB

Later runs with more changes on top stayed under budget (5,510–5,547 MB in use against about 6,660 MB). One run each, in different scenes, on one PC, so take the exact figures with that in mind.

Tests

cargo test -p victory-gpu --lib: 455 passed, 0 failed, 36 ignored on Windows. That includes the_best_range_leaves_least_over_and_the_total_follows. The tests also caught a wrap in the leftover computation (then_some evaluated size - len for ranges too small), now computed only for ranges that fit.

Tested and written with an AI assistant (Claude Code); the runs were on my machine. No game files attached.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5542905951 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337). Originally posted by [Agam77055](https://github.com/Agam77055) on 2026-11-28T17:39:53Z. --- On an 8 GB card the texture pool kept the card over its budget for a whole session. Free space inside the 64 MB texture blocks counted as room, but eviction by age only made more of those holes, because a block goes back to the system only when it is empty. **PC:** RTX 5060 Laptop 8 GB (driver 621.40), i7-13620H, 24 GB RAM, Windows 11 26300. Series S, DLSS Performance, `VICTORY_TEXTURE_POOL=1`, `VICTORY_SLOT_EVICT=1`. ### What changes - **`pool.rs`:** - A texture goes into the fullest block it fits in, at the free range that leaves least over. `VICTORY_POOL_FIT=first` gives the old first fit. - `Ranges` keeps its total. - New `block_of()` and `block_held()` let eviction know which block a texture lies in and how much of each block is held. - The pool census and a line of evictions since the start are logged every five seconds in every run. - **`resource.rs`:** under pressure, the sweep takes textures with allocations of their own first, then textures from the blocks least held, then by age. `VICTORY_EVICT_ORDER=age` gives the old order, longest idle first. Adds `eviction_counts()`. ### Measured The texture queue's room lines, first fifth of each run left out. Same switches in both runs; the only difference is this change. | | before | with this change | |---|---:|---:| | Card memory in use (median) | 7,167 MB | 5,968 MB | | Card budget (median) | 6,890 MB | 6,615 MB | | Room lines over budget | 100 % | 0 % | | Free inside texture blocks (median) | 1,634 MB | 620 MB | Later runs with more changes on top stayed under budget (5,510–5,547 MB in use against about 6,660 MB). One run each, in different scenes, on one PC, so take the exact figures with that in mind. ### Tests `cargo test -p victory-gpu --lib`: 455 passed, 0 failed, 36 ignored on Windows. That includes `the_best_range_leaves_least_over_and_the_total_follows`. The tests also caught a wrap in the leftover computation (`then_some` evaluated `size - len` for ranges too small), now computed only for ranges that fit. Tested and written with an AI assistant (Claude Code); the runs were on my machine. No game files attached.
trustno1-coder commented 2026-11-28 19:22:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:22:46Z.


Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244499667 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337#issuecomment-7244499667). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:22:46Z. --- Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.
spook40 commented 2026-11-29 01:20:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by spook40 on 2026-11-29T01:20:28Z.


Test Results — 8 GB RTX 3060 Ti (1080to1440, 60 fps)

Tested against this PR on an 8 GB RTX 3060 Ti (noting main has moved on since PR #1337 was opened):

  • PR #1337 baseline (pool.rs + resource.rs): Cut internal block waste from ~1.6 GB down to 649 MB across 48 blocks (3,072 MB), with let_go_idle evicting 154 MB (1,382 textures), but 0 blocks empty—so no VRAM blocks returned to the system and the card remained at no room.
  • Emptiable-block priority + finishing current block (resource.rs): Tripled idle evictions to 494 MB (2,124 textures, only 31 re-uploads) and drained a block down to ~55.7 MB free, still with 0 blocks empty (998 MB free across 49 blocks; 7,112 MB vs. 6,208 MB room line).
  • Small (≤ 256 KiB) / large block segregation (pool.rs): Reached 53 blocks (3,392 MB) with 1,242 MB free across 18 half-empty blocks and 0 blocks empty, because even a single pinned texture keeps a 64 MiB block resident.
  • 16 MiB block test (BLOCK = 16 << 20): Hit a host state prelude did not record (The parameter is incorrect. (0x80070057)) shortly after startup (1 block / 16 MB).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7248718306 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337#issuecomment-7248718306). Originally posted by [spook40](https://github.com/spook40) on 2026-11-29T01:20:28Z. --- ### Test Results — 8 GB RTX 3060 Ti (`1080to1440`, `60 fps`) Tested against this PR on an 8 GB RTX 3060 Ti (noting `main` has moved on since PR #1337 was opened): - **PR #1337 baseline (`pool.rs` + `resource.rs`):** Cut internal block waste from ~1.6 GB down to **649 MB** across **48 blocks (3,072 MB)**, with `let_go_idle` evicting **154 MB** (`1,382` textures), but **`0 blocks empty`**—so no VRAM blocks returned to the system and the card remained at `no room`. - **Emptiable-block priority + finishing current block (`resource.rs`):** Tripled idle evictions to **494 MB** (`2,124` textures, only `31` re-uploads) and drained a block down to ~55.7 MB free, still with **`0 blocks empty`** (`998 MB` free across `49` blocks; `7,112 MB` vs. `6,208 MB` room line). - **Small (≤ 256 KiB) / large block segregation (`pool.rs`):** Reached **53 blocks (3,392 MB)** with **1,242 MB free** across `18` half-empty blocks and **`0 blocks empty`**, because even a single pinned texture keeps a 64 MiB block resident. - **16 MiB block test (`BLOCK = 16 << 20`):** Hit `a host state prelude did not record (The parameter is incorrect. (0x80070057))` shortly after startup (`1` block / `16 MB`).

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