um: add VICTORY_PAGES=wc, VICTORY_UM_CARD_MB, and opt-in VICTORY_PAGE_YIELD_PCT #165

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

@⁠eirik200 on GitHub · 2026-12-02 05:42 UTC · original
pr/um-wc-cold-yield → main · +245 −17 · 3 files · 2 commits · closed without merging

Summary

Three small, opt-in / safety improvements to unified-memory page residency on 16 GiB cards:

  1. VICTORY_PAGES=wc mode (um.rs, um/residency.rs): Moves pages only in write-combined pools (1w, 5w), leaving plain CPU-read/written pools (7, 15) in system RAM. In open-world runs on RX 9060 XT, letting all pools move caused 92% CPU-touch thrashing (114,609 of 124,585 promoted pages immediately pulled back on CPU touch), whereas VICTORY_PAGES=0 exiled 5w (including the 64 MiB HW RT BVH) to system RAM. VICTORY_PAGES=wc keeps 5w in VRAM with zero CPU-touch ping-pong on pools 7/15. Default behavior (VICTORY_PAGES unset or 1) is unchanged.
  2. Yield cold VRAM pages before the texture eviction line (um/residency.rs): Write-combined pools like 1w (~2.2 GiB) start in VRAM, and the page governor previously only evicted cold pages when < 384 MiB VRAM was free — while the texture governor (host::vram_keep) starts evicting textures at 80% of budget (~2.9 GiB free). When adapter VRAM reaches 78%, residency now gently demotes cold-only pages (idle >= 30 s / never read by the card for >= 30 s, never touching warm pages) down toward 75%. In a 10-minute run on RX 9060 XT this shed 1.56 GiB of unread 1w pages (2,096 MB -> 532 MB, 30,571 cold pages down) while keeping 100% of active 5w (254/255 MB) in VRAM.
  3. VICTORY_UM_CARD_MB override (um.rs): Optional env var to cap unified-memory VRAM room (clamped to 256 MiB..reached, default unchanged).

Testing

  • JOBS=6 ./build.sh check passes cleanly.
  • Unit tests only_write_combined_pools_move_when_asked and cold_pages_yield_before_the_texture_eviction_line added.
  • Tested across 10-minute open-world driving run on RX 9060 XT (16 GiB, RADV, HW RT on, FSR 4 Quality): 0 crashes, 1w shrank from 2,096 MB to 532 MB, 5w stayed 254/255 MB in VRAM.
**@⁠eirik200** on GitHub · 2026-12-02 05:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/165) `pr/um-wc-cold-yield` → `main` · +245 −17 · 3 files · 2 commits · closed without merging ## Summary Three small, opt-in / safety improvements to unified-memory page residency on 16 GiB cards: 1. **`VICTORY_PAGES=wc` mode (`um.rs`, `um/residency.rs`):** Moves pages only in write-combined pools (`1w`, `5w`), leaving plain CPU-read/written pools (`7`, `15`) in system RAM. In open-world runs on RX 9060 XT, letting all pools move caused 92% CPU-touch thrashing (114,609 of 124,585 promoted pages immediately pulled back on CPU touch), whereas `VICTORY_PAGES=0` exiled `5w` (including the 64 MiB HW RT BVH) to system RAM. `VICTORY_PAGES=wc` keeps `5w` in VRAM with zero CPU-touch ping-pong on pools `7`/`15`. Default behavior (`VICTORY_PAGES` unset or `1`) is unchanged. 2. **Yield cold VRAM pages before the texture eviction line (`um/residency.rs`):** Write-combined pools like `1w` (~2.2 GiB) start in VRAM, and the page governor previously only evicted cold pages when `< 384 MiB` VRAM was free — while the texture governor (`host::vram_keep`) starts evicting textures at 80% of budget (~2.9 GiB free). When adapter VRAM reaches 78%, `residency` now gently demotes cold-only pages (idle `>= 30 s` / never read by the card for `>= 30 s`, never touching warm pages) down toward 75%. In a 10-minute run on RX 9060 XT this shed 1.56 GiB of unread `1w` pages (`2,096 MB -> 532 MB`, 30,571 cold pages down) while keeping 100% of active `5w` (`254/255 MB`) in VRAM. 3. **`VICTORY_UM_CARD_MB` override (`um.rs`):** Optional env var to cap unified-memory VRAM room (clamped to `256 MiB..reached`, default unchanged). ## Testing - `JOBS=6 ./build.sh check` passes cleanly. - Unit tests `only_write_combined_pools_move_when_asked` and `cold_pages_yield_before_the_texture_eviction_line` added. - Tested across 10-minute open-world driving run on RX 9060 XT (16 GiB, RADV, HW RT on, FSR 4 Quality): 0 crashes, `1w` shrank from 2,096 MB to 532 MB, `5w` stayed 254/255 MB in VRAM.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 05:45:37 +00:00
Author
Owner

@⁠audunleganger on GitHub · 2026-12-02 08:39 UTC · original · edited 2026-12-02 12:42 UTC

Tested on an RX 9070 XT 16 GB (RDNA4), i7-13700KF, 32 GB, Arch (kernel 7.3.6), this repo's patched Mesa and vkd3d-proton. Series X profile, 1920x1080 output, 1280x720 render, ray tracing on (VICTORY_BVH_BUILDER=1), VICTORY_CARD_PULL=0. Build: d044248 + #163 + #164, with and without #165. Nothing else differs between the runs.

The scene is a scripted 5-minute camera orbit around Jason on the balcony of the first safehouse. Numbers are the mean of 5-s windows over the orbit.

fps 1% low GPU ms/frame title memory on the card pages down cold
without #165 (2 runs) 24.4 / 24.9 10.1 / 10.7 33.0 / 33.0 3,234 MB 165
with #165 17.5 5.9 45.8 979 MB 36,659
with #165, VICTORY_PAGES=wc 15.9 3.6 46.8 702 MB 34,675

For reference, dad990b without these PRs gave 23.9-26.5 fps in 6 runs of the same scene.

With ray tracing this card stays at about 88% of VRAM for the whole run, so the cold-page yield (on by default above 78%) runs all the time. It takes ~2.3 GB of title memory off the card and leaves ~2.2 GB of VRAM free. The pages it treats as cold are still read by the GPU every frame, so those reads go over the bus.

Suggestion: keep the early yield opt-in (like VICTORY_PAGES=wc), or count a page as cold only when the card hasn't read it either (the residency line already tracks "seen by the card").

Happy to share the logs (the residency line every few seconds) if useful.

AI assistance: Claude Code (Claude Opus 5.5) ran the builds and the measurements, read the logs and wrote this report, on the hardware above.

**@⁠audunleganger** on GitHub · 2026-12-02 08:39 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/165#issuecomment-7339751244) · edited 2026-12-02 12:42 UTC Tested on an RX 9070 XT 16 GB (RDNA4), i7-13700KF, 32 GB, Arch (kernel 7.3.6), this repo's patched Mesa and vkd3d-proton. Series X profile, 1920x1080 output, 1280x720 render, ray tracing on (`VICTORY_BVH_BUILDER=1`), `VICTORY_CARD_PULL=0`. Build: `d044248` + #163 + #164, with and without #165. Nothing else differs between the runs. The scene is a scripted 5-minute camera orbit around Jason on the balcony of the first safehouse. Numbers are the mean of 5-s windows over the orbit. | | fps | 1% low | GPU ms/frame | title memory on the card | pages down cold | |---|---|---|---|---|---| | without #165 (2 runs) | 24.4 / 24.9 | 10.1 / 10.7 | 33.0 / 33.0 | 3,234 MB | 165 | | with #165 | 17.5 | 5.9 | 45.8 | 979 MB | 36,659 | | with #165, `VICTORY_PAGES=wc` | 15.9 | 3.6 | 46.8 | 702 MB | 34,675 | For reference, `dad990b` without these PRs gave 23.9-26.5 fps in 6 runs of the same scene. With ray tracing this card stays at about 88% of VRAM for the whole run, so the cold-page yield (on by default above 78%) runs all the time. It takes ~2.3 GB of title memory off the card and leaves ~2.2 GB of VRAM free. The pages it treats as cold are still read by the GPU every frame, so those reads go over the bus. Suggestion: keep the early yield opt-in (like `VICTORY_PAGES=wc`), or count a page as cold only when the card hasn't read it either (the residency line already tracks "seen by the card"). Happy to share the logs (the residency line every few seconds) if useful. AI assistance: Claude Code (Claude Opus 5.5) ran the builds and the measurements, read the logs and wrote this report, on the hardware above.
Author
Owner

@⁠GreemSC on GitHub · 2026-12-02 11:21 UTC · original · edited 2026-12-02 11:52 UTC

Tested on an RX 7900 XT 20 GB (RDNA 3), i7-12700K, 24 GB RAM, CachyOS kernel 7.3.6, Proton-CachyOS Wine, this repo's patched Mesa 26.3.1 and vkd3d-proton 71cae09. Series X, 2560x1440 output, render scale 0.75, ray tracing on. Build: d044248 + #163 + #164 + #166 + #165 (+ #149, #155), run with VICTORY_PAGES=wc. One run, scripted drive from the same save as the run without #165 (results of that one in #163).

Result: device lost after ~124 s in the world, and the kernel says why. This complements @⁠audunleganger's fps result above: here the cold-page yield ends in a crash, not only a slowdown.

  • Until +110 s in the world, frame times match the run without #165 (32.1 / 31.1 / 21.8 fps in the same three slices vs 32.7 / 30.9 / 23.3).
  • Then 3.9 fps for 14 s (median frame 255 ms), and host GPU device removed ... 0x887A0005.
  • Kernel, at the same second: amdgpu 0000:03:00.0: [drm] *ERROR* Not enough memory for command submission! (three times).
  • GTT (amdgpu's default cap = half of RAM, 11,888 MB here) was at its ceiling, 11,887 MB. It also peaks at 11,685–11,887 MB without #165 on this machine, so there is no headroom on the RAM side.
  • VRAM peaked at 16,068 MB of 20,464 = 78.5 %, just over the new yield line. Last residency lines before the crash: title memory on the card 2,840 → 2,584 → 2,200 MB in 20 s, 11264 down cold, 4513 MB of the card free.

So the yield moves pages from VRAM (4.5 GB free) into GTT, which is already full, and the next submission cannot be allocated. On machines where GTT is the scarce side (24 GB of RAM or less; #119 and #147 show the same kernel message), the 78 % rule pushes in the wrong direction.

Suggestions, in line with the one above:

  • keep the early yield opt-in, or skip it when GTT is near its own limit (mem_info_gtt_used / mem_info_gtt_total in sysfs, or the system-side heap of VK_EXT_memory_budget);
  • VICTORY_UM_CARD_MB is useful on its own: on this 20 GB card the title gets 8,176 MB (CARD_KEPT_FOR_HOST = 12 GiB) while ~2.5 GB of VRAM stays free at peak and GTT is full. A split-out PR with only that switch would be easy to test.

Edit, measured since: with the same effect as VICTORY_UM_CARD_MB (title card room 8,176 → 10,224 MB, a local switch on CARD_KEPT_FOR_HOST), without VICTORY_PAGES=wc (so VICTORY_PAGES=0, "each pool stays where it starts"): no change — GTT peak 11,880 MB vs 11,884, VRAM peak 17,917 vs 17,918 MB, median frame 33.6 vs 33.9 ms (one run each). With pages not moving, the card room is not what fills GTT here; the pools that start in system memory are. So it only matters together with a mode that moves pages.

Logs (residency lines, kernel lines, summary) are available if useful.

AI assistance: Claude Code (Claude Opus 5.5) ran the build and the measurement, read the logs and wrote this report on the hardware above.

**@⁠GreemSC** on GitHub · 2026-12-02 11:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/165#issuecomment-7343816916) · edited 2026-12-02 11:52 UTC Tested on an RX 7900 XT 20 GB (RDNA 3), i7-12700K, 24 GB RAM, CachyOS kernel 7.3.6, Proton-CachyOS Wine, this repo's patched Mesa 26.3.1 and vkd3d-proton `71cae09`. Series X, 2560x1440 output, render scale 0.75, ray tracing on. Build: `d044248` + #163 + #164 + #166 + #165 (+ #149, #155), run with `VICTORY_PAGES=wc`. One run, scripted drive from the same save as the run without #165 (results of that one in #163). **Result: device lost after ~124 s in the world, and the kernel says why.** This complements @⁠audunleganger's fps result above: here the cold-page yield ends in a crash, not only a slowdown. - Until +110 s in the world, frame times match the run without #165 (32.1 / 31.1 / 21.8 fps in the same three slices vs 32.7 / 30.9 / 23.3). - Then 3.9 fps for 14 s (median frame 255 ms), and `host GPU device removed ... 0x887A0005`. - Kernel, at the same second: `amdgpu 0000:03:00.0: [drm] *ERROR* Not enough memory for command submission!` (three times). - GTT (amdgpu's default cap = half of RAM, 11,888 MB here) was **at its ceiling, 11,887 MB**. It also peaks at 11,685–11,887 MB without #165 on this machine, so there is no headroom on the RAM side. - VRAM peaked at 16,068 MB of 20,464 = **78.5 %**, just over the new yield line. Last residency lines before the crash: title memory on the card 2,840 → 2,584 → 2,200 MB in 20 s, `11264 down cold`, `4513 MB of the card free`. So the yield moves pages from VRAM (4.5 GB free) into GTT, which is already full, and the next submission cannot be allocated. On machines where GTT is the scarce side (24 GB of RAM or less; #119 and #147 show the same kernel message), the 78 % rule pushes in the wrong direction. Suggestions, in line with the one above: - keep the early yield opt-in, or skip it when GTT is near its own limit (`mem_info_gtt_used` / `mem_info_gtt_total` in sysfs, or the system-side heap of VK_EXT_memory_budget); - `VICTORY_UM_CARD_MB` is useful on its own: on this 20 GB card the title gets 8,176 MB (`CARD_KEPT_FOR_HOST` = 12 GiB) while ~2.5 GB of VRAM stays free at peak and GTT is full. A split-out PR with only that switch would be easy to test. **Edit, measured since:** with the same effect as `VICTORY_UM_CARD_MB` (title card room 8,176 → 10,224 MB, a local switch on `CARD_KEPT_FOR_HOST`), without `VICTORY_PAGES=wc` (so `VICTORY_PAGES=0`, "each pool stays where it starts"): **no change** — GTT peak 11,880 MB vs 11,884, VRAM peak 17,917 vs 17,918 MB, median frame 33.6 vs 33.9 ms (one run each). With pages not moving, the card room is not what fills GTT here; the pools that start in system memory are. So it only matters together with a mode that moves pages. Logs (residency lines, kernel lines, summary) are available if useful. AI assistance: Claude Code (Claude Opus 5.5) ran the build and the measurement, read the logs and wrote this report on the hardware above.
github-bot changed title from um: add VICTORY_PAGES=wc, VICTORY_UM_CARD_MB, and yield cold pages above 78% VRAM to um: add VICTORY_PAGES=wc, VICTORY_UM_CARD_MB, and opt-in VICTORY_PAGE_YIELD_PCT 2026-12-02 15:18:45 +00:00
Author
Owner

@⁠eirik200 on GitHub · 2026-12-02 15:16 UTC · original

Thanks @⁠audunleganger and @⁠GreemSC for the detailed tests and logs — both reports pinpointed real bugs in the default-on 78% yield:

  1. Default-on regression with RT (@⁠audunleganger): age == u8::MAX includes pages the GPU reads every frame that residency::heat skips (RT/BVH, descriptors, ranges >= 64 MiB), so firing early yield by default above 78% stripped active title pages over PCIe even with ~2.2 GB VRAM free.
  2. GTT OOM on 24 GB RAM (@⁠GreemSC): yielding VRAM → GTT without checking GTT headroom dumped pages into an already-full 11.9 GB GTT aperture while 4.5 GB of VRAM was still free.

Updated in the latest commit:

  • Opt-in only (off by default): early cold-page yield now requires VICTORY_PAGE_YIELD_PCT=<50..95> (unset or 0 = off, identical to main by default).
  • Skip GPU-seen pages: early yield checks lazy::seen_by_card (WANT / SEEN) and will not evict age == u8::MAX pages that the card has been pointed at by address.
  • GTT headroom guard: caps/skips early yield against DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL (shared_budget - reserve - (shared_used + freed)), and skips if GTT budget is unavailable, so it cannot push a tight GTT into command-submission OOM.

Verified with build.sh check and um::residency::tests (4/4 passed).

**@⁠eirik200** on GitHub · 2026-12-02 15:16 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/165#issuecomment-7350033623) Thanks @⁠audunleganger and @⁠GreemSC for the detailed tests and logs — both reports pinpointed real bugs in the default-on 78% yield: 1. **Default-on regression with RT (@⁠audunleganger):** `age == u8::MAX` includes pages the GPU reads every frame that `residency::heat` skips (RT/BVH, descriptors, ranges >= 64 MiB), so firing early yield by default above 78% stripped active title pages over PCIe even with ~2.2 GB VRAM free. 2. **GTT OOM on 24 GB RAM (@⁠GreemSC):** yielding VRAM → GTT without checking GTT headroom dumped pages into an already-full 11.9 GB GTT aperture while 4.5 GB of VRAM was still free. Updated in the latest commit: - **Opt-in only (off by default):** early cold-page yield now requires `VICTORY_PAGE_YIELD_PCT=<50..95>` (unset or `0` = off, identical to `main` by default). - **Skip GPU-seen pages:** early yield checks `lazy::seen_by_card` (`WANT` / `SEEN`) and will not evict `age == u8::MAX` pages that the card has been pointed at by address. - **GTT headroom guard:** caps/skips early yield against `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL` (`shared_budget - reserve - (shared_used + freed)`), and skips if GTT budget is unavailable, so it cannot push a tight GTT into command-submission OOM. Verified with `build.sh check` and `um::residency::tests` (4/4 passed).
github-bot closed this pull request 2026-12-03 19:11:33 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.