mem-probe: say how full the shared texture blocks are (RT-MEMPROBE-TEXTURE-BLOCKS) #2547

Closed
Tyrannys wants to merge 2 commits from upstream-pr/2547 into main
Tyrannys commented 2026-11-28 01:45:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T01:45:03Z.


Claimed in the coordination issue as: RT-MEMPROBE-TEXTURE-BLOCKS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231847971).

What and why

With LEONIDA_MEM_PROBE, the breakdown line counts the shared texture blocks (src/image_memory.h) only as driver allocations: texture blocks 4934 (77). In recent world runs they are the largest consumer of device-local memory, 4.9-6.5 GiB, and they never shrink. The line could not say whether that is texture data or free space kept inside the blocks: one empty block is kept per memory type, and released ranges leave holes.

The breakdown now adds, after the texture blocks:

texture blocks 4934 (77) [21000 textures in 4100 MiB, 834 MiB free inside the blocks (2 empty blocks, largest free piece 64)]

(numbers from the unit test, not a run). ImageMemoryPool::stats() gains what it needs: the bytes the ranges hold, the empty blocks and the largest free piece. They are read under the pool's own lock, once a probe tick. DeviceShare carries them to memory_breakdown::format. Nothing else changes; the bracket is left out when a device has no texture blocks.

Tested

  • image_memory_test: a full block has every byte in use and no free piece. With one block full, one emptied and one in another memory type: 65 MiB used of 192 MiB, 1 empty block, largest free piece 64 MiB.
  • memory_breakdown_test: the line carries the new bracket after the texture blocks, with the free bytes computed from block bytes minus used. Without the share it is left out.
  • Both pass; gta6rt_d3d12_com builds (MSVC 17, Release). CPU only, no GPU, no game data.

GPUs tested: n/a (CPU tests).

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5535489603 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T01:45:03Z. --- Claimed in the coordination issue as: RT-MEMPROBE-TEXTURE-BLOCKS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231847971). ### What and why With `LEONIDA_MEM_PROBE`, the breakdown line counts the shared texture blocks (`src/image_memory.h`) only as driver allocations: `texture blocks 4934 (77)`. In recent world runs they are the largest consumer of device-local memory, 4.9-6.5 GiB, and they never shrink. The line could not say whether that is texture data or free space kept inside the blocks: one empty block is kept per memory type, and released ranges leave holes. The breakdown now adds, after the texture blocks: ``` texture blocks 4934 (77) [21000 textures in 4100 MiB, 834 MiB free inside the blocks (2 empty blocks, largest free piece 64)] ``` (numbers from the unit test, not a run). `ImageMemoryPool::stats()` gains what it needs: the bytes the ranges hold, the empty blocks and the largest free piece. They are read under the pool's own lock, once a probe tick. `DeviceShare` carries them to `memory_breakdown::format`. Nothing else changes; the bracket is left out when a device has no texture blocks. ### Tested - `image_memory_test`: a full block has every byte in use and no free piece. With one block full, one emptied and one in another memory type: 65 MiB used of 192 MiB, 1 empty block, largest free piece 64 MiB. - `memory_breakdown_test`: the line carries the new bracket after the texture blocks, with the free bytes computed from block bytes minus used. Without the share it is left out. - Both pass; `gta6rt_d3d12_com` builds (MSVC 17, Release). CPU only, no GPU, no game data. GPUs tested: n/a (CPU tests). AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
akimfomin commented 2026-11-28 01:59:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by akimfomin on 2026-11-28T01:59:50Z.


The new live/free split can distinguish an active texture peak from retained allocator reserve. KytyPS5 #1394 has a useful independent mixed-size churn case, and AnyXboxX #550 distinguishes empty reserve at a budget threshold. A compact control for output would compare the same live byte count in two traces with different largest free spans. Peak block bytes alone would make them look the same.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232057097 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7232057097). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:59:50Z. --- The new live/free split can distinguish an active texture peak from retained allocator reserve. [KytyPS5 #1394](https://github.com/KytyPS5/KytyPS5/pull/1394) has a useful independent mixed-size churn case, and [AnyXboxX #550](https://github.com/LooperSalty/AnyXboxX/pull/550) distinguishes empty reserve at a budget threshold. A compact control for output would compare the same live byte count in two traces with different largest free spans. Peak block bytes alone would make them look the same.
Tyrannys commented 2026-11-28 02:08:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T02:08:48Z.


@akimfomin thank you for the pointers and the control idea. I added our own synthetic version in 627335d69 (image_memory_test, churn_stats), written here, not taken from either project:

  • A seeded mixed-size churn (64 KiB to 8 MiB textures, about a third of the steps releasing a random live one, 4000 steps). At every step it checks that the used bytes equal the live ranges' sum, the range count matches, and at most one block is empty. A drained pool keeps one empty block as a single free piece.
  • Your control: two pools with the same 32 MiB live in one 64 MiB block. One is packed; the other has every other texture of a full block released. They report the same used and block bytes, but a largest free piece of 32 MiB against 1 MiB. Block bytes alone would not tell them apart.

image_memory_test passes. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232162430 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7232162430). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T02:08:48Z. --- @akimfomin thank you for the pointers and the control idea. I added our own synthetic version in 627335d69 (`image_memory_test`, `churn_stats`), written here, not taken from either project: - A seeded mixed-size churn (64 KiB to 8 MiB textures, about a third of the steps releasing a random live one, 4000 steps). At every step it checks that the used bytes equal the live ranges' sum, the range count matches, and at most one block is empty. A drained pool keeps one empty block as a single free piece. - Your control: two pools with the same 32 MiB live in one 64 MiB block. One is packed; the other has every other texture of a full block released. They report the same used and block bytes, but a largest free piece of 32 MiB against 1 MiB. Block bytes alone would not tell them apart. `image_memory_test` passes. AI-assisted (Claude Code).
zmasi commented 2026-11-28 07:05:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T07:05:23Z.


#2547 | head 627335d693 (merged cleanly with main 09c1539483) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(image_memory|memory_breakdown|d3d12_existing_heap)$" --output-on-failure (LEONIDA_VK_VALIDATION=1, LEONIDA_MEM_PROBE=1) | red on main: image_memory_test.cpp and memory_breakdown_test.cpp fail to compile (C2039: used_bytes, empty_blocks, largest_free missing on ImageMemoryPool::Stats, and texture_blocks / block_* missing on DeviceShare) | green on PR+main: 3/3 CTests pass (image_memory including churn_stats 4,000-step mixed-size churn and packed-vs-holed largest-free checks, memory_breakdown formatting texture blocks 4934 (1) [21000 textures in 4100 MiB, 834 MiB free inside the blocks (2 empty blocks, largest free piece 64)], and d3d12_existing_heap on RTX 3090 with LEONIDA_MEM_PROBE=1); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235708263 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7235708263). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T07:05:23Z. --- #2547 | head 627335d693509f6cdd6a18a7271c9948d087db6d (merged cleanly with main 09c153948386fd658fe2f999f6176efbaa8c8345) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(image_memory|memory_breakdown|d3d12_existing_heap)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`, `LEONIDA_MEM_PROBE=1`) | red on main: `image_memory_test.cpp` and `memory_breakdown_test.cpp` fail to compile (`C2039`: `used_bytes`, `empty_blocks`, `largest_free` missing on `ImageMemoryPool::Stats`, and `texture_blocks` / `block_*` missing on `DeviceShare`) | green on PR+main: `3/3` CTests pass (`image_memory` including `churn_stats` 4,000-step mixed-size churn and packed-vs-holed largest-free checks, `memory_breakdown` formatting `texture blocks 4934 (1) [21000 textures in 4100 MiB, 834 MiB free inside the blocks (2 empty blocks, largest free piece 64)]`, and `d3d12_existing_heap` on RTX 3090 with `LEONIDA_MEM_PROBE=1`); `check_no_game_data.py` `0` violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes
lixonik commented 2026-11-28 09:28:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T09:28:00Z.

Review: APPROVED


Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).

Adding used_bytes, empty_blocks, and largest_free to ImageMemoryPool::Stats, surfacing them in memory_breakdown::format, and verifying mixed-size churn and fragmentation in image_memory_test is clean and non-intrusive.

Tests run

  • cmake --build <build> --target image_memory_test memory_breakdown_test gta6rt_d3d12_com: built cleanly.
  • ctest --output-on-failure -R "^(image_memory|memory_breakdown)$": 2/2 passed.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6096961241 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#pullrequestreview-6096961241). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T09:28:00Z. **Review:** APPROVED --- Reviewed the diff and tested merged onto `main` (`493867366`) with Ninja Release (MSVC). Adding `used_bytes`, `empty_blocks`, and `largest_free` to `ImageMemoryPool::Stats`, surfacing them in `memory_breakdown::format`, and verifying mixed-size churn and fragmentation in `image_memory_test` is clean and non-intrusive. ### Tests run - `cmake --build <build> --target image_memory_test memory_breakdown_test gta6rt_d3d12_com`: built cleanly. - `ctest --output-on-failure -R "^(image_memory|memory_breakdown)$"`: **2/2 passed**. AI-assisted (Antigravity, Gemini).
KelboLive commented 2026-11-30 17:02:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T17:02:07Z.


Independent check on Windows (not the author), at 627335d69.

  • image_memory_test: pass — textures share blocks, and released ranges are used again.
  • memory_breakdown_test: pass (memory_breakdown: ok), including the new block-occupancy fields.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7285615727 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7285615727). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T17:02:07Z. --- Independent check on Windows (not the author), at `627335d69`. - `image_memory_test`: **pass** — `textures share blocks, and released ranges are used again`. - `memory_breakdown_test`: **pass** (`memory_breakdown: ok`), including the new block-occupancy fields. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. AI-assisted: yes (opencode).
aslan2142 commented 2026-12-01 16:46:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:46:01Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318188129 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7318188129). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:46:01Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

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
ProjectLeonida/mandy!2547
No description provided.