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

Closed
github-bot wants to merge 1 commit from github-bot/gh-1337 into main AGit
Owner

@⁠Agam77055 on GitHub · 2026-11-28 17:39 UTC · original
Agam77055:pr/texture-pool-best-fit → main · +192 −17 · 2 files · 1 commits · closed without merging

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.

**@⁠Agam77055** on GitHub · 2026-11-28 17:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337) `Agam77055:pr/texture-pool-best-fit` → `main` · +192 −17 · 2 files · 1 commits · closed without merging 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.
On an RTX 5060 Laptop the card stood over its budget for a whole session
(7.0-7.24 GB in use against 6.8-6.9 GB) with 1.6-1.9 GB free inside the
texture blocks: the room test counts those holes as room, and eviction by
age only made more of them, since a block goes back to the system only
when it is empty.

- pool.rs: a texture takes the fullest block it fits in, in the range that
  leaves least over (VICTORY_POOL_FIT=first: first fit, as before); Ranges
  keep their total; block_of() and block_held() for eviction; the census
  line and a line of evictions every five seconds in every run.
- resource.rs: under pressure the sweep takes copies of their own first,
  then those in the blocks textures hold least of (VICTORY_EVICT_ORDER=age:
  the longest idle first, as before); eviction_counts().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 17:41:21 +00:00
github-bot force-pushed github-bot/gh-1337 from 5e24669b4c to 19f0fbe02d 2026-11-28 18:02:49 +00:00 Compare
github-bot closed this pull request 2026-11-28 19:24:58 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-28 19:22 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-11-28 19:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337#issuecomment-7244499667) 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.
Author
Owner

@⁠spook40 on GitHub · 2026-11-29 01:20 UTC · original

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).
**@⁠spook40** on GitHub · 2026-11-29 01:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1337#issuecomment-7248718306) ### 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

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