Texture pools: size-class slab pools for 256K-2M textures (fix stranded space of the single TLSF medium pool) #587

Closed
opened 2026-10-09 03:39:21 +00:00 by sky_line · 1 comment
Owner

Measured on 2026-10-09 in a heavy sim. Raising the medium texture pool limit from 256 KB to 2 MB had two effects:

  • Good: live allocations went from 3,254 to 879, and padding from 119 MB to 12 MB. Region-crossing hitches also felt better.
  • Bad: the single TLSF medium pool (8 MB blocks) sat at 74% occupancy, with 767 MB of free space stranded in partly used blocks. Mixed sizes from 256K to 2M leave holes that later allocations can't use.

Design

Size-class slab pools. SL textures are power-of-two dimensions, so their memory requirements cluster in a series that roughly doubles each step: ~352K, ~704K, ~1.4M, ~2.8M.

  • Give each class its own VMA pool, block = 8–16 slots, and suballocate exact-size slots.
  • A freed slot is always reusable by the same class, so there is no external fragmentation in steady state.
  • Derive the class boundaries from the measured driver sizes. The VKMem tex size bands line now logs the 16 most common exact sizes. Add a few % of headroom per class.
  • Sizes that don't fit a class go to a small TLSF fallback pool, or stay dedicated above the limit (> ~2–4 MB).
  • Release empty blocks promptly, and keep per-class block counts bounded.

Stats

Per-class occupancy and stranded bytes go in the VKMem tex pools line.

Backstop (only if still needed after measuring)

A budgeted background defrag: move images into fuller blocks with a GPU copy and a bindless slot rewrite, then free the old image after its fence. Skip images with uploads, sharpen or encode in flight, media textures, and direct image/view holders.

Done when

In a heavy sim:

  • allocations stay under ~1000;
  • texture pool occupancy is ≥ 90% steady state;
  • stranded space is under ~150 MB;
  • VRAM frees properly after leaving a region.
Measured on 2026-10-09 in a heavy sim. Raising the medium texture pool limit from 256 KB to 2 MB had two effects: - **Good:** live allocations went from 3,254 to 879, and padding from 119 MB to 12 MB. Region-crossing hitches also felt better. - **Bad:** the single TLSF medium pool (8 MB blocks) sat at **74% occupancy, with 767 MB of free space stranded** in partly used blocks. Mixed sizes from 256K to 2M leave holes that later allocations can't use. ## Design **Size-class slab pools.** SL textures are power-of-two dimensions, so their memory requirements cluster in a series that roughly doubles each step: ~352K, ~704K, ~1.4M, ~2.8M. - Give each class its own VMA pool, block = 8–16 slots, and suballocate exact-size slots. - A freed slot is always reusable by the same class, so there is no external fragmentation in steady state. - Derive the class boundaries from the measured driver sizes. The VKMem `tex size bands` line now logs the 16 most common exact sizes. Add a few % of headroom per class. - Sizes that don't fit a class go to a small TLSF fallback pool, or stay dedicated above the limit (> ~2–4 MB). - Release empty blocks promptly, and keep per-class block counts bounded. ## Stats Per-class occupancy and stranded bytes go in the VKMem `tex pools` line. ## Backstop (only if still needed after measuring) A budgeted background defrag: move images into fuller blocks with a GPU copy and a bindless slot rewrite, then free the old image after its fence. Skip images with uploads, sharpen or encode in flight, media textures, and direct image/view holders. ## Done when In a heavy sim: - allocations stay under ~1000; - texture pool occupancy is ≥ 90% steady state; - stranded space is under ~150 MB; - VRAM frees properly after leaving a region.
sky_line added this to the Slipstream project 2026-10-09 03:39:21 +00:00
Author
Owner

Shipped in a published release and tested; closing (testing-lane sweep 2026-10-11).

Shipped in a published release and tested; closing (testing-lane sweep 2026-10-11).
sky_line 2026-10-11 13:25:14 +00:00
Sign in to join this conversation.
No milestone
No project
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
sky_line/Slipstream#587
No description provided.