gpu(native): VICTORY_TRACE_HEAP_SET reports what the heaps keep resident that no bound table named for N frames (#79) #292

Manually merged
github merged 1 commit from github-bot/gh-292 into gh-pr/292/base 2026-11-27 10:48:33 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-27 09:06 UTC · original
Olima34:diag/heap-set → main · +155 −0 · 6 files · 1 commits · merged 2026-11-27 10:37 UTC

Refs #79. This is the diagnostic asked for there, so that 16 and 24 GB Macs can send the same table as the 48 GB one. It is off by default.

What it logs. With VICTORY_TRACE_HEAP_SET=<frames>, every 64 frames (with the native draws so far line), it logs what the descriptor heaps' residency sets hold. Textures and buffers are counted apart, and each underlying allocation is counted once over all heaps: a texture view counts as its parent's memory. The total is split three ways:

  • all of it;
  • idle: named by a table a draw or dispatch bound, but not within the last <frames> frames, which is what a time-based eviction could free;
  • never: never named by a bound table.

Each entry's last use is noted where tables are remirrored (NativeHeap::used). Entries a shader reaches by indexing the heap itself aren't seen, so idle and never are upper bounds.

For testers:

VICTORY_TRACE_HEAP_SET=300 tools/macos/run-native.sh --seconds 300 --console series-s <game folder>
grep "heap set:" runs/<date>/victory.log | tail -5

Compare the totals with the Mac's RAM and with the heap_set_mb= of the native draws so far lines, and check whether idle stays at 0.

Reference (M5 Pro, 48 GB, Series S, world frames 2176–2496, 300 frames): 9.2 GB of textures and 7.6 GB of buffers (the title's pools) in the sets. 0 MB idle, and 8.3 GB of textures never named by a bound table.

Test: heap_allocations_give_each_allocation_once_with_its_latest_use (Metal) checks that a view counts with its parent and keeps the latest use over the entries.

Checks: victory-gpu and victory-metal tests pass on arm64 (373). Windows clippy is clean with -D warnings, cargo xtask policy passes, and docs/native-host.md lists the switch.

**@⁠Olima34** on GitHub · 2026-11-27 09:06 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/292) `Olima34:diag/heap-set` → `main` · +155 −0 · 6 files · 1 commits · merged 2026-11-27 10:37 UTC Refs #79. This is the diagnostic asked for there, so that 16 and 24 GB Macs can send the same table as the 48 GB one. It is off by default. **What it logs.** With `VICTORY_TRACE_HEAP_SET=<frames>`, every 64 frames (with the `native draws so far` line), it logs what the descriptor heaps' residency sets hold. Textures and buffers are counted apart, and each underlying allocation is counted once over all heaps: a texture view counts as its parent's memory. The total is split three ways: - **all of it;** - **idle:** named by a table a draw or dispatch bound, but not within the last `<frames>` frames, which is what a time-based eviction could free; - **never:** never named by a bound table. Each entry's last use is noted where tables are remirrored (`NativeHeap::used`). Entries a shader reaches by indexing the heap itself aren't seen, so idle and never are upper bounds. **For testers:** ```bash VICTORY_TRACE_HEAP_SET=300 tools/macos/run-native.sh --seconds 300 --console series-s <game folder> grep "heap set:" runs/<date>/victory.log | tail -5 ``` Compare the totals with the Mac's RAM and with the `heap_set_mb=` of the `native draws so far` lines, and check whether idle stays at 0. **Reference** (M5 Pro, 48 GB, Series S, world frames 2176–2496, 300 frames): 9.2 GB of textures and 7.6 GB of buffers (the title's pools) in the sets. 0 MB idle, and 8.3 GB of textures never named by a bound table. **Test:** `heap_allocations_give_each_allocation_once_with_its_latest_use` (Metal) checks that a view counts with its parent and keeps the latest use over the entries. **Checks:** victory-gpu and victory-metal tests pass on arm64 (373). Windows clippy is clean with `-D warnings`, `cargo xtask policy` passes, and `docs/native-host.md` lists the switch.
A diagnostic for #79, off by default. With VICTORY_TRACE_HEAP_SET=<frames>,
every 64 frames (with the "native draws so far" line) it logs what the
descriptor heaps' residency sets hold, textures and buffers apart, each
underlying allocation counted once over all heaps (a texture view is its
parent's memory), split three ways: all of it; "idle", named by a table
a draw or dispatch bound, but not within the last <frames> frames; and
"never" named by a bound table. Each entry's last use is noted where
tables are remirrored (NativeHeap::used). Entries a shader reaches by
indexing the heap itself are not seen, so idle and never are upper
bounds.

On an M5 Pro, 48 GB, Series S, world frames 2176-2496 with <frames> 300:
9.2 GB of textures and 7.6 GB of buffers (the title's pools) in the sets,
0 MB idle, 8.3 GB of textures never named by a bound table.

Test: heap_allocations_give_each_allocation_once_with_its_latest_use
(Metal; a view counts with its parent, the latest use over the entries).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 09:08:44 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 10:37 UTC · original

Thank you. Merged.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 10:37 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/292#issuecomment-7216112883) Thank you. Merged.
github-bot changed target branch from main to gh-pr/292/base 2026-11-27 10:48:31 +00:00
github manually merged commit c9f7672b01 into gh-pr/292/base 2026-11-27 10:48:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.