GPU: the memory map tells the process heap's segments from other heaps' #459

Open
github-bot wants to merge 2 commits from github-bot/gh-459 into main AGit
Owner

@⁠IxMxAMAR on GitHub · 2026-11-25 01:12 UTC · original
IxMxAMAR:gpu/memory-map-heap-owners → main · +172 −7 · 1 files · 2 commits · open

The memory map counts every private allocation of 0xFD0000 bytes (an NT heap segment) as "process heap segments", and OWN's comment reads them as "ours, the graphics runtime's and the driver's alike". On an RX 9070 XT nearly all of them belonged to another heap: AMD's shader compiler (amdxc64.dll) keeps a heap of its own, and while it compiled compute 39f0e9aeb156a61c without end (see #172) that heap grew to 13.8, 24.3 and 31.9 GB at 4, 6.5 and 9.5 min, until the process ran out of commit. That heap is not in the process's heap list either, so UMDH never shows it; it took an outside probe of the segment headers to find it.

Change

  • segment_heap(base) reads a segment's header (64-bit HEAP_SEGMENT: signature 0xffeeffee at +0x10, the owning heap at +0x28) through ReadProcessMemory on our own process, so an unreadable page fails the call instead of faulting.
  • In the memory map, the 0xFD0000 allocations whose header names the process heap keep their line; the others get a kind of their own at the end of KINDS (segments of other heaps (private, 15.8 MB each)), so the existing kinds keep their numbers and text.
  • A new line names the biggest other heaps: memory map, heaps other than the process heap (N, the biggest first): heap 0x…: 31910 MB in 2109 segments; … (heap 0 for allocations whose header could not be read).
  • OWN's comment says other heaps count apart.

One header read per such allocation, during the walk that already runs on its own thread.

Tests

  • New copystat::heap_tests::segments_name_their_heap: the process heap's first segment names it; a private heap (HeapCreate) filled with 20,000 blocks adds a segment whose header names that heap, not the process heap; a block address is no segment.
  • cargo test -p victory-gpu --lib: 112 passed; with --features diagnostics: 120 passed. cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --all-features: clean.

Made with the help of an AI.

**@⁠IxMxAMAR** on GitHub · 2026-11-25 01:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/459) `IxMxAMAR:gpu/memory-map-heap-owners` → `main` · +172 −7 · 1 files · 2 commits · open The memory map counts every private allocation of `0xFD0000` bytes (an NT heap segment) as "process heap segments", and `OWN`'s comment reads them as "ours, the graphics runtime's and the driver's alike". On an RX 9070 XT nearly all of them belonged to another heap: AMD's shader compiler (`amdxc64.dll`) keeps a heap of its own, and while it compiled `compute 39f0e9aeb156a61c` without end (see #172) that heap grew to 13.8, 24.3 and 31.9 GB at 4, 6.5 and 9.5 min, until the process ran out of commit. That heap is not in the process's heap list either, so UMDH never shows it; it took an outside probe of the segment headers to find it. ## Change - `segment_heap(base)` reads a segment's header (64-bit `HEAP_SEGMENT`: signature `0xffeeffee` at +0x10, the owning heap at +0x28) through `ReadProcessMemory` on our own process, so an unreadable page fails the call instead of faulting. - In the memory map, the `0xFD0000` allocations whose header names the process heap keep their line; the others get a kind of their own at the end of `KINDS` (`segments of other heaps (private, 15.8 MB each)`), so the existing kinds keep their numbers and text. - A new line names the biggest other heaps: `memory map, heaps other than the process heap (N, the biggest first): heap 0x…: 31910 MB in 2109 segments; …` (heap 0 for allocations whose header could not be read). - `OWN`'s comment says other heaps count apart. One header read per such allocation, during the walk that already runs on its own thread. ## Tests - New `copystat::heap_tests::segments_name_their_heap`: the process heap's first segment names it; a private heap (`HeapCreate`) filled with 20,000 blocks adds a segment whose header names that heap, not the process heap; a block address is no segment. - `cargo test -p victory-gpu --lib`: 112 passed; with `--features diagnostics`: 120 passed. `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--all-features`: clean. Made with the help of an AI.
The memory map counted every private allocation of 0xFD0000 bytes (the size of
an NT heap segment) as "process heap segments". On an RX 9070 XT nearly all of
them belonged to another heap: AMD's shader compiler (amdxc64.dll) keeps a
heap of its own, and while it compiled compute 39f0e9aeb156a61c without end
that heap grew to 13.8, 24.3 and 31.9 GB at 4, 6.5 and 9.5 minutes, read as
the process heap and so as "ours, the runtime's or the driver's alike". That
heap is not in the process's heap list either, so UMDH never shows it.

Each such allocation's segment header (signature 0xffeeffee at +0x10, the
owning heap at +0x28) is now read, through ReadProcessMemory so that an
unreadable page fails instead of faulting. The process heap's segments keep
their line; other heaps' segments get a kind of their own, and a new line
names the biggest other heaps with their segments and committed bytes.
A 15.8 MB allocation whose header could not be read went under "heap 0x0: N MB in 0 segments" and
counted as one of the other heaps. It now reads "N MB in M allocations with no readable heap header",
with the allocations counted, and is left out of the number of heaps. The line is worked out by
other_heaps, which a test now covers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:48 +00:00
Author
Owner

@⁠IxMxAMAR on GitHub · 2026-11-25 02:37 UTC · original

Seen in the game, same run (c96b4f2 with this PR, RX 9070 XT):

memory map, heaps other than the process heap (5, the biggest first): heap 0x2602c0f0000: 237 MB in 164 segments; heap 0x2602c600000: 132 MB in 10 segments; heap 0x2602c1e0000: 82 MB in 27 segments; heap 0x2602c440000: 80 MB in 45 segments; heap 0x2602c360000: 24 MB in 35 segments

with process heap segments (private, 15.8 MB each) 2474 MB next to segments of other heaps (private, 15.8 MB each) 556 MB in the map line. With 39f0e9aeb156a61c compiling normally on this base, the other heaps stayed under 1 GB; on the older base, the AMD compiler's heap was the one that grew past 30 GB.

**@⁠IxMxAMAR** on GitHub · 2026-11-25 02:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/459#issuecomment-7150959159) Seen in the game, same run (`c96b4f2` with this PR, RX 9070 XT): ``` memory map, heaps other than the process heap (5, the biggest first): heap 0x2602c0f0000: 237 MB in 164 segments; heap 0x2602c600000: 132 MB in 10 segments; heap 0x2602c1e0000: 82 MB in 27 segments; heap 0x2602c440000: 80 MB in 45 segments; heap 0x2602c360000: 24 MB in 35 segments ``` with `process heap segments (private, 15.8 MB each) 2474 MB` next to `segments of other heaps (private, 15.8 MB each) 556 MB` in the map line. With `39f0e9aeb156a61c` compiling normally on this base, the other heaps stayed under 1 GB; on the older base, the AMD compiler's heap was the one that grew past 30 GB.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 10:59 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head 99a7e54 into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them); with --all-features it fails with the same number of errors as main (4). This PR adds none and removes none. cargo test --workspace --locked: 555 passed, 0 failed, 11 ignored, two runs (main alone: 555 passed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 10:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/459#issuecomment-7160438662) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `99a7e54` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins`, `depth_written`, a sort; PR #841 fixes them); with `--all-features` it fails with the same number of errors as `main` (4). This PR adds none and removes none. `cargo test --workspace --locked`: 555 passed, 0 failed, 11 ignored, two runs (`main` alone: 555 passed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/copystat.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/459/head:github-bot/gh-459'
git switch 'github-bot/gh-459'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-459'
git switch 'github-bot/gh-459'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-459'
git switch 'github-bot/gh-459'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-459'
git switch 'main'
git merge --squash 'github-bot/gh-459'
git switch 'main'
git merge --ff-only 'github-bot/gh-459'
git switch 'main'
git merge 'github-bot/gh-459'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.