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

Closed
github-bot wants to merge 2 commits from github-bot/gh-2547 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-28 01:45 UTC · original
Tyrannys:claude/memprobe-texture-blocks → main · +106 −5 · 5 files · 2 commits · closed without merging

Claimed in the coordination issue as: RT-MEMPROBE-TEXTURE-BLOCKS (#1608).

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

**@⁠Tyrannys** on GitHub · 2026-11-28 01:45 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547) `Tyrannys:claude/memprobe-texture-blocks` → `main` · +106 −5 · 5 files · 2 commits · closed without merging Claimed in the coordination issue as: RT-MEMPROBE-TEXTURE-BLOCKS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). ### 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)
The breakdown line counted the texture blocks only as driver allocations
("texture blocks N (n)"), so a run could not tell whether 5-6 GiB of
blocks held that much texture data or kept free space. The line now adds,
after the texture blocks, the textures in them, the bytes those take, the
bytes free inside the blocks, the empty blocks and the largest free
piece. ImageMemoryPool::stats() gains the used bytes, empty blocks and
largest free piece it needs.

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

@⁠akimfomin on GitHub · 2026-11-28 01:59 UTC · original

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.

**@⁠akimfomin** on GitHub · 2026-11-28 01:59 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7232057097) 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.
A seeded churn of textures from 64 KiB to 8 MiB checks at every step that
the used bytes are the live ranges' sum and at most one block is empty,
and that a drained pool keeps one empty block as one free piece. Two
pools with the same 32 MiB live in one block, one packed and one with
every other texture released, report the same used and block bytes but a
largest free piece of 32 MiB against 1 MiB. Suggested in review by
akimfomin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-28 02:08 UTC · original

@⁠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).

**@⁠Tyrannys** on GitHub · 2026-11-28 02:08 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7232162430) @⁠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).
Author
Owner

@⁠zmasi on GitHub · 2026-11-28 07:05 UTC · original

#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

**@⁠zmasi** on GitHub · 2026-11-28 07:05 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7235708263) #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
Author
Owner

@⁠lixonik on GitHub · 2026-11-28 09:28 UTC · original · approved these changes

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).

**@⁠lixonik** on GitHub · 2026-11-28 09:28 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#pullrequestreview-6096961241) · **approved these changes** 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).
Author
Owner

@⁠KelboLive on GitHub · 2026-11-30 17:02 UTC · original

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).

**@⁠KelboLive** on GitHub · 2026-11-30 17:02 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7285615727) 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).
Author
Owner

@⁠aslan2142 on GitHub · 2026-12-01 16:46 UTC · original

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.

**@⁠aslan2142** on GitHub · 2026-12-01 16:46 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2547#issuecomment-7318188129) 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.
github-bot closed this pull request 2026-12-01 16:56:13 +00:00

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/ubiquitarianism--leonida!2547
No description provided.