Log the texture pool's blocks and free ranges on request #411

Closed
github-bot wants to merge 661 commits from github-bot/gh-411 into main AGit
Owner

@⁠safesearch77 on GitHub · 2026-11-28 13:25 UTC · original
safesearch77:feat/pool-stats-census → main · +60238 −5432 · 206 files · 661 commits · closed without merging

VICTORY_POOL_STATS=1 (off by default) adds one log line every five seconds from the sweep. It describes the texture pool:

  • the blocks and how full they are, in quarters
  • the bytes free in the blocks, and in how many ranges
  • the largest free range, and the bytes in ranges of 1 MiB or more
  • the pieces still resting
  • live textures by piece size (<= 64 KiB, <= 256 KiB, <= 1 MiB, <= 4 MiB, larger)
  • how many live textures could sit at 4 KiB placements but don't, and what they'd hold there

The last count is nonzero only under VICTORY_POOL_SMALL=0 or with the AMD default. On other cards Vice-Tay already places small textures at 4 KiB.

The goal is to show pool fragmentation without a capture. Blocks only go back to the card when they are wholly empty, so the free space inside blocks still counts as card memory in use. room() already subtracts pool::texture_room() from use. This line shows how that free space is split up.

Placement doesn't change. Each texture made or released costs two relaxed counter updates. With the switch on, it also costs one GetResourceAllocationInfo per texture made. With VICTORY_SWEEP=0 the line doesn't appear.

Ported from trustno1-coder/VIctory-NVIDIA@ecfa1a6 (1mosce). Changes from the original:

  • The doc comment drops a measurement that was taken under VICTORY_POOL_SMALL=0, which is not Vice-Tay's default.
  • Added a docs/this-fork.md entry under "Measuring".

Verification (Linux, GE-Proton11-14 Wine runner, x86_64-pc-windows-msvc)

  • Scope of the Wine runs: CPU-side tests pass under Wine. GPU-backed tests return early because crate::host::host() is None (no D3D12 host in that harness). Both new census tests (pool::tests::the_census_counts_what_is_free_resting_and_how_full_blocks_are and pool::tests::textures_are_counted_by_their_piece) are pure CPU tests, so they do run and pass.
  • cargo +1.98.1 test -p victory-gpu --lib (Wine): 524 passed; 5 failed (default) and 590 passed; 6 failed (--features diagnostics), matching untouched main (fe7c6e5); zero new failures.
  • cargo +1.98.1 clippy -p victory-gpu --all-targets -- -D warnings: clean, both default and --features diagnostics.
  • cargo +1.98.1 xtask policy: asset policy: 322 files ok.
  • Live Series S run under Proton + vkd3d-proton (RTX 4070 Laptop 8 GB, CachyOS, GE-Proton11-14-viewtree, Wayland, DLSS Quality, VICTORY_POOL_STATS=1, VICTORY_VRAM_HEADROOM_MB=1024), captured cleanly every 5s, e.g.:
    texture blocks (VICTORY_POOL_STATS=1): 26 of them (1664 MB), 688 MB held by 14740 textures, 972 MB free now in 4729 ranges (the largest 65536 KB; 683 MB of it in ranges of 1 MiB and more), 2 MB resting, 2 blocks empty; blocks by how full: 12 under a quarter, 4 under a half, 4 under three quarters, 6 above; textures by their piece: 13999 of 64 KiB (163 MB), 359 to 256 KiB (47 MB), 228 to 1 MiB (127 MB), 138 to 4 MiB (250 MB), 16 larger (99 MB); 0 of them could lie at multiples of 4 KiB and would hold 0 MB where they hold 0 MB
**@⁠safesearch77** on GitHub · 2026-11-28 13:25 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/411) `safesearch77:feat/pool-stats-census` → `main` · +60238 −5432 · 206 files · 661 commits · closed without merging `VICTORY_POOL_STATS=1` (off by default) adds one log line every five seconds from the sweep. It describes the texture pool: - the blocks and how full they are, in quarters - the bytes free in the blocks, and in how many ranges - the largest free range, and the bytes in ranges of 1 MiB or more - the pieces still resting - live textures by piece size (`<= 64 KiB`, `<= 256 KiB`, `<= 1 MiB`, `<= 4 MiB`, larger) - how many live textures could sit at 4 KiB placements but don't, and what they'd hold there The last count is nonzero only under `VICTORY_POOL_SMALL=0` or with the AMD default. On other cards Vice-Tay already places small textures at 4 KiB. The goal is to show pool fragmentation without a capture. Blocks only go back to the card when they are wholly empty, so the free space inside blocks still counts as card memory in use. `room()` already subtracts `pool::texture_room()` from use. This line shows how that free space is split up. Placement doesn't change. Each texture made or released costs two relaxed counter updates. With the switch on, it also costs one `GetResourceAllocationInfo` per texture made. With `VICTORY_SWEEP=0` the line doesn't appear. Ported from `trustno1-coder/VIctory-NVIDIA@ecfa1a6` (`1mosce`). Changes from the original: - The doc comment drops a measurement that was taken under `VICTORY_POOL_SMALL=0`, which is not Vice-Tay's default. - Added a `docs/this-fork.md` entry under "Measuring". ### Verification (Linux, `GE-Proton11-14` Wine runner, `x86_64-pc-windows-msvc`) - **Scope of the Wine runs:** CPU-side tests pass under Wine. GPU-backed tests return early because `crate::host::host()` is `None` (no D3D12 host in that harness). Both new census tests (`pool::tests::the_census_counts_what_is_free_resting_and_how_full_blocks_are` and `pool::tests::textures_are_counted_by_their_piece`) are pure CPU tests, so they do run and pass. - `cargo +1.98.1 test -p victory-gpu --lib` (Wine): `524 passed; 5 failed` (default) and `590 passed; 6 failed` (`--features diagnostics`), matching untouched `main` (`fe7c6e5`); zero new failures. - `cargo +1.98.1 clippy -p victory-gpu --all-targets -- -D warnings`: clean, both default and `--features diagnostics`. - `cargo +1.98.1 xtask policy`: `asset policy: 322 files ok`. - Live Series S run under Proton + `vkd3d-proton` (RTX 4070 Laptop 8 GB, CachyOS, `GE-Proton11-14-viewtree`, Wayland, DLSS Quality, `VICTORY_POOL_STATS=1`, `VICTORY_VRAM_HEADROOM_MB=1024`), captured cleanly every 5s, e.g.: `texture blocks (VICTORY_POOL_STATS=1): 26 of them (1664 MB), 688 MB held by 14740 textures, 972 MB free now in 4729 ranges (the largest 65536 KB; 683 MB of it in ranges of 1 MiB and more), 2 MB resting, 2 blocks empty; blocks by how full: 12 under a quarter, 4 under a half, 4 under three quarters, 6 above; textures by their piece: 13999 of 64 KiB (163 MB), 359 to 256 KiB (47 MB), 228 to 1 MiB (127 MB), 138 to 4 MiB (250 MB), 16 larger (99 MB); 0 of them could lie at multiples of 4 KiB and would hold 0 MB where they hold 0 MB`
VICTORY_POOL_STATS=1 (off by default) adds one line to the log every five
seconds, from the sweep: the texture blocks and how full they are in
quarters, the bytes free in them and in how many ranges, the largest range
and the bytes in ranges of 1 MiB and more, the pieces that still rest, and
the live textures by the size of their piece. It also counts the textures
that could sit at 4 KiB placements but do not, which shows what
VICTORY_POOL_SMALL=0 or the AMD default costs.

How pieces are cut does not change. A texture costs two counter updates
when it is made and when it goes; with the switch on, it also costs one
GetResourceAllocationInfo call.

Ported from trustno1-coder/VIctory-NVIDIA ecfa1a6 (1mosce).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 13:36:50 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-29 11:35 UTC · original

Thanks for the pool diagnostics. The distinction between total free bytes and the largest contiguous range is useful for fragmentation. Please keep logging and collection overhead negligible when the option is off.

**@⁠TaynanGT** on GitHub · 2026-11-29 11:35 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/411#issuecomment-7255219839) Thanks for the pool diagnostics. The distinction between total free bytes and the largest contiguous range is useful for fragmentation. Please keep logging and collection overhead negligible when the option is off.
Author
Owner

@⁠safesearch77 on GitHub · 2026-11-29 13:20 UTC · original

Gated counted(...) in both texture() and release() behind if stats_on(), so when VICTORY_POOL_STATS is off (the default) neither LIVE nor SMALLER atomic counters are updated per texture allocation/release — only the cached OnceLock check runs (verified by code inspection). Also switched stats() to sum live piece bytes instead of reading HELD (removed in #439's f581aea), and added pool_stats_switch_is_off_unless_set_to_one to test env-var parsing across unset, empty, 0, true, and 1. Once #439 lands, I'm happy to rebase the remaining 3 mechanical hunks in pool.rs (census() beside reusable_bytes(), release(), and texture()) onto main.

Verified with Wine victory-gpu --lib -- pool::tests (13/13 pass), clippy --all-targets -- -D warnings, and cargo xtask policy (322 files ok).

**@⁠safesearch77** on GitHub · 2026-11-29 13:20 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/411#issuecomment-7256460062) Gated `counted(...)` in both `texture()` and `release()` behind `if stats_on()`, so when `VICTORY_POOL_STATS` is off (the default) neither `LIVE` nor `SMALLER` atomic counters are updated per texture allocation/release — only the cached `OnceLock` check runs (verified by code inspection). Also switched `stats()` to sum `live` piece bytes instead of reading `HELD` (removed in `#439`'s `f581aea`), and added `pool_stats_switch_is_off_unless_set_to_one` to test env-var parsing across unset, empty, `0`, `true`, and `1`. Once `#439` lands, I'm happy to rebase the remaining 3 mechanical hunks in `pool.rs` (`census()` beside `reusable_bytes()`, `release()`, and `texture()`) onto `main`. Verified with Wine `victory-gpu --lib -- pool::tests` (`13/13` pass), `clippy --all-targets -- -D warnings`, and `cargo xtask policy` (`322 files ok`).
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-29 14:39 UTC · original

Thanks for gating the counters when pool statistics are disabled. Keeping the default allocation and release path free of atomic updates is important. I will retain the switch test and check the census against the current pool implementation before integrating the remaining hunks.

**@⁠TaynanGT** on GitHub · 2026-11-29 14:39 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/411#issuecomment-7257468797) Thanks for gating the counters when pool statistics are disabled. Keeping the default allocation and release path free of atomic updates is important. I will retain the switch test and check the census against the current pool implementation before integrating the remaining hunks.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:08 UTC · original

main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:08 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/411#issuecomment-7285788400) `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.
github-bot closed this pull request 2026-11-30 17:14:28 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.