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

Open
IxMxAMAR wants to merge 2 commits from upstream-pr/459 into main
IxMxAMAR commented 2026-11-25 01:12:17 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by IxMxAMAR on 2026-11-25T01:12:17Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594817086 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/459). Originally posted by [IxMxAMAR](https://github.com/IxMxAMAR) on 2026-11-25T01:12:17Z. --- 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 commented 2026-11-25 03:06:35 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by IxMxAMAR on 2026-11-25T02:37:13Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7150959159 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/459#issuecomment-7150959159). Originally posted by [IxMxAMAR](https://github.com/IxMxAMAR) on 2026-11-25T02:37:13Z. --- 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.
MamaLeVrai commented 2026-11-25 11:10:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T10:59:22Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7160438662 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/459#issuecomment-7160438662). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T10:59:22Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/459:upstream-pr/459'
git switch 'upstream-pr/459'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/459'
git switch 'upstream-pr/459'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/459'
git switch 'upstream-pr/459'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/459'
git switch 'main'
git merge --squash 'upstream-pr/459'
git switch 'main'
git merge --ff-only 'upstream-pr/459'
git switch 'main'
git merge 'upstream-pr/459'
git push origin 'main'
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
fxceless/victory-fork!459
No description provided.