diagnostics: print in-memory bytes per group in the memory map (#756) #1503

Manually merged
github merged 1 commit from github-bot/gh-1503 into main 2026-11-29 08:22:04 +00:00 AGit
Owner

@⁠shiman1901 on GitHub · 2026-11-28 20:57 UTC · original
shiman1901:copystat-group-in-memory → main · +152 −26 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Summary

Prints resident (in memory) bytes alongside committed bytes for each group on the memory map, other private allocations by size line (VICTORY_MEMORY_MAP=1), matching the existing per-kind summary line right above it:

  • Accumulates resident bytes per AllocationBase for kinds 5 and 6 inside the existing in_memory() K32QueryWorkingSetEx batches (zero additional syscalls).
  • Extracts a deterministic format_biggest_groups() helper (sorting by descending committed bytes, breaking ties by kind and whole size) and formats each entry as {n} of {size:.2} MB{wc}: {committed} MB ({present} MB in memory).
  • Adds 3 unit tests (copystat::memory_map_tests) covering 0 MB in memory VRAM blocks, mixed VRAM + RAM staging groups, partially committed 32 MiB arenas, ordering, and limit clamping.

Why this helps (from #756)

In #756, a VICTORY_MEMORY_MAP=1 dump showed write-combined (buffers shared with the card) 8630 MB (1545 MB in memory) with 65 of 64.00 MB write-combined: 4158 MB, which initially looked like a multi-GB host upload leak.

Probing D3D12 with VirtualQuery + K32QueryWorkingSetEx on an RTX 3060 (driver 621.35, 21 test cases) showed that NVIDIA exposes CreateHeap(D3D12_HEAP_TYPE_DEFAULT, 64 MiB) (exact pool.rs:826-835 flags) as 64.00 MB PAGE_WRITECOMBINE with committed = 64.00 MB and resident = 0.00 MB — accounting for 58 × 64 MB (pool::TEXTURES) + 5 × 64 MB (pool::STAGING) in that group.

Showing ({present} MB in memory) on each group immediately separates 0 MB in memory VRAM heaps from live host UPLOAD / staging buffers in future memory-map logs:

before: ... (committed): 1 of 64.00 MB write-combined: 64 MB
after:  ... (committed, in memory): 1 of 64.00 MB write-combined: 64 MB (0 MB in memory)

Scope & compatibility

  • Diagnostics-only (#[cfg(all(windows, feature = "diagnostics"))]); zero gameplay, rendering, or allocator behavior change.
  • Checked scripts/, tests/, and docs/ — nothing parses the biggest groups log line.
  • Touches only crates/victory-gpu/src/copystat.rs (lines 556–791 + tests at EOF); does not conflict with #548 (HEAP allocator) or overlap #803 / #916 / #1182.

Verification

Verified on GitHub windows-latest CI via fork workflow (noting pre-existing Rust 1.98 clippy lints in untouched shadow.rs:1708 and victory-shader/src/emit/mod.rs:2768):

  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings -A clippy::manual_is_multiple_of -A clippy::let_and_return — 0 warnings in copystat.rs (including new tests).
  • cargo test -p victory-gpu --lib --all-features --locked memory_map_tests — 3/3 passed (vram_blocks_show_nothing_in_memory, a_group_says_what_of_it_is_in_memory, biggest_are_first_and_equal_sizes_keep_the_same_order).
  • Full disclosure: no game assets on this PC, so not run inside the title; verified via diagnostics unit tests and standalone D3D12 VirtualQuery / QueryWorkingSetEx probes on RTX 3060 (driver 621.35). Written with AI assistance; code and tests reviewed line by line.
**@⁠shiman1901** on GitHub · 2026-11-28 20:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1503) `shiman1901:copystat-group-in-memory` → `main` · +152 −26 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC ### Summary Prints resident (`in memory`) bytes alongside committed bytes for each group on the `memory map, other private allocations by size` line (`VICTORY_MEMORY_MAP=1`), matching the existing per-kind summary line right above it: - Accumulates resident bytes per `AllocationBase` for kinds 5 and 6 inside the existing `in_memory()` `K32QueryWorkingSetEx` batches (**zero additional syscalls**). - Extracts a deterministic `format_biggest_groups()` helper (sorting by descending committed bytes, breaking ties by kind and whole size) and formats each entry as `{n} of {size:.2} MB{wc}: {committed} MB ({present} MB in memory)`. - Adds 3 unit tests (`copystat::memory_map_tests`) covering `0 MB in memory` VRAM blocks, mixed VRAM + RAM staging groups, partially committed 32 MiB arenas, ordering, and limit clamping. ### Why this helps (from #756) In `#756`, a `VICTORY_MEMORY_MAP=1` dump showed `write-combined (buffers shared with the card) 8630 MB (1545 MB in memory)` with `65 of 64.00 MB write-combined: 4158 MB`, which initially looked like a multi-GB host upload leak. Probing D3D12 with `VirtualQuery` + `K32QueryWorkingSetEx` on an RTX 3060 (driver `621.35`, 21 test cases) showed that NVIDIA exposes `CreateHeap(D3D12_HEAP_TYPE_DEFAULT, 64 MiB)` (exact `pool.rs:826-835` flags) as `64.00 MB PAGE_WRITECOMBINE` with **`committed = 64.00 MB` and `resident = 0.00 MB`** — accounting for `58 × 64 MB` (`pool::TEXTURES`) + `5 × 64 MB` (`pool::STAGING`) in that group. Showing `({present} MB in memory)` on each group immediately separates `0 MB in memory` VRAM heaps from live host `UPLOAD` / staging buffers in future memory-map logs: before: ... (committed): 1 of 64.00 MB write-combined: 64 MB after: ... (committed, in memory): 1 of 64.00 MB write-combined: 64 MB (0 MB in memory) ### Scope & compatibility - Diagnostics-only (`#[cfg(all(windows, feature = "diagnostics"))]`); zero gameplay, rendering, or allocator behavior change. - Checked `scripts/`, `tests/`, and `docs/` — nothing parses the `biggest groups` log line. - Touches only `crates/victory-gpu/src/copystat.rs` (lines 556–791 + tests at EOF); does not conflict with `#548` (`HEAP` allocator) or overlap `#803` / `#916` / `#1182`. ### Verification Verified on GitHub `windows-latest` CI via fork workflow (noting pre-existing Rust 1.98 clippy lints in untouched `shadow.rs:1708` and `victory-shader/src/emit/mod.rs:2768`): - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings -A clippy::manual_is_multiple_of -A clippy::let_and_return` — **0 warnings** in `copystat.rs` (including new tests). - `cargo test -p victory-gpu --lib --all-features --locked memory_map_tests` — **3/3 passed** (`vram_blocks_show_nothing_in_memory`, `a_group_says_what_of_it_is_in_memory`, `biggest_are_first_and_equal_sizes_keep_the_same_order`). - Full disclosure: no game assets on this PC, so not run inside the title; verified via diagnostics unit tests and standalone D3D12 `VirtualQuery` / `QueryWorkingSetEx` probes on RTX 3060 (driver `621.35`). Written with AI assistance; code and tests reviewed line by line.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 21:02:40 +00:00
github-bot changed title from diagnostics: print in-memory bytes per group in the memory map to [pr-diagnostics][memory][NVIDIA] diagnostics: print in-memory bytes per group in the memory map (#756) 2026-11-28 21:25:14 +00:00
github-bot changed title from [pr-diagnostics][memory][NVIDIA] diagnostics: print in-memory bytes per group in the memory map (#756) to diagnostics: print in-memory bytes per group in the memory map (#756) 2026-11-28 21:37:41 +00:00
github manually merged commit dba7be68da into main 2026-11-29 08:22:04 +00:00
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/trustno1-coder--VIctory-NVIDIA!1503
No description provided.