gpu: page mover off the title's path, honest VRAM budget, tighter texture pool #44

Closed
github-bot wants to merge 3 commits from github-bot/gh-44 into main AGit
Owner

@⁠k-qno1 on GitHub · 2026-11-30 20:51 UTC · original
k-qno1:memory-pressure → main · +214 −30 · 5 files · 3 commits · closed without merging

What

Memory-pressure work for unified memory on AMD, now that RADV's page pools (90338ca) run with a current driver. Three commits:

radv: page-pool pages count in the driver's own memory tally (patches/mesa.patch)

Pool pages are made with raw GEM calls that RADV's allocation tracker never saw, so VK_EXT_memory_budget treated the title's own pages as another process's memory: the budget shrank by every MB the page mover put on the card, and the reported use was low by the same amount. Pages now count as CPU-visible VRAM on the card and GTT off it, updated on create, place and free.

RX 9070 XT, ~2.9 GB of title pages on the card: the budget read 9,698 MB before; ~13.8 GB after (part of that from closing other GPU apps).

um: the page mover no longer holds the title back while pages move (um/residency.rs)

  • The lazy::moving() guard is released before the kick that makes the kernel migrate a pass's pages. Under it, every title thread first-touching any lazy page (lazy::materialize) waited out the whole migration, up to the kick's one-second wait, once per pass.
  • Passes run every 400 ms (was 1 s) and move up to 32 MiB (was 8 MiB): about 80 MiB/s against the 4 GB the title may hold on the card. VICTORY_PAGE_PASS_MS / VICTORY_PAGE_MOVE_MB; 1000 / 8 is the old pace.

pool: tightest free range, resting pieces not room; room lines as switches

  • Texture pieces take the tightest free range (an exact fit ends the search) instead of the lowest that fits, so large ranges stay whole and blocks can empty (from foxhound b90bb90).
  • Pieces still resting before reuse no longer count as room in texture_room().
  • VICTORY_TEXTURE_ROOM_CAP_PERCENT (92) and VICTORY_TEXTURE_ROOM_PERCENT (86) for resource::room's two lines; defaults unchanged.
  • VICTORY_VRAM_BUDGET_MB replaces the system's budget, above or below it. Above it only with the title's cgroup protected (dmem.low, e.g. dmemcg-booster with KDE's foreground booster), or the kernel may move the game's own buffers out.
  • The texture-blocks line now counts no-room textures placed in free space of existing blocks, and those that found none.

Testing

  • victory-gpu pool and resource tests pass under Wine (19, two new: tightest hole, resting bytes).
  • RX 9070 XT, Mesa 26.3.1 + this patch, GE-Proton 11-15, Series X, FSR4 4K Quality: plays; flicker and pop-in much reduced together with #41 and the rebuilt driver. In one run: 11,777 pages moved up (5.7 s spent moving in all); 1,229 no-room textures placed in existing block space, 0 that found none. No controlled A/B against main yet.

Needs ./setup.sh mesa for the RADV part.

🤖 Generated with Claude Code

**@⁠k-qno1** on GitHub · 2026-11-30 20:51 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/44) `k-qno1:memory-pressure` → `main` · +214 −30 · 5 files · 3 commits · closed without merging ## What Memory-pressure work for unified memory on AMD, now that RADV's page pools (90338ca) run with a current driver. Three commits: ### radv: page-pool pages count in the driver's own memory tally (`patches/mesa.patch`) Pool pages are made with raw GEM calls that RADV's allocation tracker never saw, so `VK_EXT_memory_budget` treated the title's own pages as another process's memory: the budget shrank by every MB the page mover put on the card, and the reported use was low by the same amount. Pages now count as CPU-visible VRAM on the card and GTT off it, updated on create, place and free. RX 9070 XT, ~2.9 GB of title pages on the card: the budget read 9,698 MB before; ~13.8 GB after (part of that from closing other GPU apps). ### um: the page mover no longer holds the title back while pages move (`um/residency.rs`) - The `lazy::moving()` guard is released before the kick that makes the kernel migrate a pass's pages. Under it, every title thread first-touching any lazy page (`lazy::materialize`) waited out the whole migration, up to the kick's one-second wait, once per pass. - Passes run every 400 ms (was 1 s) and move up to 32 MiB (was 8 MiB): about 80 MiB/s against the 4 GB the title may hold on the card. `VICTORY_PAGE_PASS_MS` / `VICTORY_PAGE_MOVE_MB`; `1000` / `8` is the old pace. ### pool: tightest free range, resting pieces not room; room lines as switches - Texture pieces take the tightest free range (an exact fit ends the search) instead of the lowest that fits, so large ranges stay whole and blocks can empty (from foxhound b90bb90). - Pieces still resting before reuse no longer count as room in `texture_room()`. - `VICTORY_TEXTURE_ROOM_CAP_PERCENT` (92) and `VICTORY_TEXTURE_ROOM_PERCENT` (86) for `resource::room`'s two lines; defaults unchanged. - `VICTORY_VRAM_BUDGET_MB` replaces the system's budget, above or below it. Above it only with the title's cgroup protected (`dmem.low`, e.g. dmemcg-booster with KDE's foreground booster), or the kernel may move the game's own buffers out. - The texture-blocks line now counts no-room textures placed in free space of existing blocks, and those that found none. ## Testing - `victory-gpu` pool and resource tests pass under Wine (19, two new: tightest hole, resting bytes). - RX 9070 XT, Mesa 26.3.1 + this patch, GE-Proton 11-15, Series X, FSR4 4K Quality: plays; flicker and pop-in much reduced together with #41 and the rebuilt driver. In one run: 11,777 pages moved up (5.7 s spent moving in all); 1,229 no-room textures placed in existing block space, 0 that found none. No controlled A/B against main yet. Needs `./setup.sh mesa` for the RADV part. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pool pages are made with raw GEM calls that RADV's allocation tracker never
saw, so VK_EXT_memory_budget treated the title's own pages as another
process's memory: the budget shrank by every MB the page mover put on the
card, and the reported use was low by as much. On an RX 9070 XT with 2.9 GB
of title pages on the card the budget read 9,698 MB instead of ~12.6 GB.

Pages now count as CPU-visible VRAM on the card and GTT off it, from their
creation, through each placement, to their release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lazy::moving() guard is released before the kick that makes the kernel
migrate a pass's pages. Under the guard every title thread that touched any
lazy page for the first time (lazy::materialize) waited out the whole
migration, up to the kick's one-second wait, once per pass.

Passes run every 400 ms (was 1 s) and move up to 32 MiB (was 8 MiB), about
80 MiB/s against the 4 GB the title may hold on the card:
VICTORY_PAGE_PASS_MS and VICTORY_PAGE_MOVE_MB (1000 and 8: the old pace).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Texture pieces take the tightest free range in a block (an exact fit ends
the look) instead of the lowest that fits, so big ranges stay whole for big
textures and blocks can empty (foxhound b90bb90). Pieces resting before
reuse are no longer counted as room by texture_room().

resource::room's two lines are switches, defaults unchanged:
VICTORY_TEXTURE_ROOM_CAP_PERCENT (92) and VICTORY_TEXTURE_ROOM_PERCENT (86).
VICTORY_VRAM_BUDGET_MB replaces the system's budget, above or below it;
above it only with the title's cgroup protected (dmem.low), or the kernel
may move the game's own buffers out.

The texture-blocks line counts textures the card had no room for that were
placed in free space of blocks already made, and those that found none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:42:07 +00:00
Author
Owner

@⁠BlueCatsz on GitHub · 2026-12-01 15:22 UTC · original

Tested #44 (992cc11 merged cleanly onto origin/main 37bb30f) on CachyOS + RX 9070 XT 16 GB.

Environment

  • CPU / RAM: Ryzen 7 5800X3D · 32 GB DDR4
  • GPU / Driver: AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.3.1 + #44's patches/mesa.patch)
  • OS / Runtime: CachyOS (kernel 7.3.6), proton-cachyos-slr + RB-tree wineserver, vkd3d-proton 71cae091
  • Profile: Series X (1706x960 -> 2560x1440, HW RT on, FG off)

Unit Tests (under Wine)

  • pool::: 6/6 passed (including both new tests: a_small_piece_takes_the_tightest_hole and resting_pieces_are_counted_until_they_have_rested)
  • resource::: 13/13 passed with --test-threads=1 (buffer_data_reaches_the_host_texture raced when run in parallel against tests sharing host() upload lists)

Live Observations (main 37bb30f vs. 37bb30f + #44)

(Caveat: the main run was a cold first run with 1,499 first-use pipeline misses, whereas both #44 runs were warm with 0 misses, so this is not a strict cold-vs-cold A/B.)

Metric main (37bb30f, cold) 37bb30f + #44 (run 1) 37bb30f + #44 (run 2, VICTORY_AMBIENT_RT=0)
Reported VRAM budget (F3) 9.97–10.56 GB 13.38–13.43 GB 13.31–13.37 GB
Identical indoor window scene 15.0 fps (Submit 37.6 ms, Copy prep 18.7 ms) 28.5 fps (Submit 17.0 ms, Copy prep 4.2 ms) —
texture_late (after_memory) mean 19.35 s (n=182,469) 7.95 s (n=131,412) 12.18 s (n=252,449)
texture_late (part_to_whole) mean 4.60 s (n=75,261) 3.40 s (n=35,433) —
No-room textures placed in free block space — 60,078 (0 failed) —
Crashes / device loss / dropped draws 0 / 0 / 0 0 / 0 / 0 0 / 0 / 0

Remaining Notes

  • VRAM budget & page-mover fix clearly worked: VK_EXT_memory_budget jumped by ~3.4 GB once RADV tracked pool pages, and 0 pages waited for room (15,869–21,347 pages moved up seen by the card, 0 refused).
  • Heavy scene transitions still hit pool pressure: On transitions VRAM hit 87–93% (11.7–12.4 / 13.4 GB), textures picked by index: the card has no room for more still fired (444 times in run 1), and at the end of run 2 texture blocks: 80 alive, 8 being emptied, 0 given back to the card, 2 taken into use again for want of room elsewhere — looks complementary to #31 (VICTORY_POOL_MOVE=1).
**@⁠BlueCatsz** on GitHub · 2026-12-01 15:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/44#issuecomment-7315812207) Tested #44 (`992cc11` merged cleanly onto `origin/main` `37bb30f`) on CachyOS + RX 9070 XT 16 GB. ### Environment - **CPU / RAM:** Ryzen 7 5800X3D · 32 GB DDR4 - **GPU / Driver:** AMD Radeon RX 9070 XT (RADV GFX1201, Mesa `26.3.1` + #44's `patches/mesa.patch`) - **OS / Runtime:** CachyOS (kernel `7.3.6`), `proton-cachyos-slr` + RB-tree `wineserver`, `vkd3d-proton 71cae091` - **Profile:** Series X (`1706x960 -> 2560x1440`, HW RT on, FG off) ### Unit Tests (under Wine) - `pool::`: **6/6 passed** (including both new tests: `a_small_piece_takes_the_tightest_hole` and `resting_pieces_are_counted_until_they_have_rested`) - `resource::`: **13/13 passed** with `--test-threads=1` (`buffer_data_reaches_the_host_texture` raced when run in parallel against tests sharing `host()` upload lists) ### Live Observations (`main` `37bb30f` vs. `37bb30f + #44`) *(Caveat: the `main` run was a cold first run with `1,499` first-use pipeline misses, whereas both `#44` runs were warm with `0` misses, so this is not a strict cold-vs-cold A/B.)* | Metric | `main` (`37bb30f`, cold) | `37bb30f + #44` (run 1) | `37bb30f + #44` (run 2, `VICTORY_AMBIENT_RT=0`) | | --- | --- | --- | --- | | Reported VRAM budget (`F3`) | `9.97–10.56 GB` | **`13.38–13.43 GB`** | **`13.31–13.37 GB`** | | Identical indoor window scene | `15.0 fps` (`Submit 37.6 ms`, `Copy prep 18.7 ms`) | **`28.5 fps`** (`Submit 17.0 ms`, `Copy prep 4.2 ms`) | — | | `texture_late (after_memory)` mean | `19.35 s` (`n=182,469`) | **`7.95 s`** (`n=131,412`) | **`12.18 s`** (`n=252,449`) | | `texture_late (part_to_whole)` mean | `4.60 s` (`n=75,261`) | **`3.40 s`** (`n=35,433`) | — | | No-room textures placed in free block space | — | `60,078` (`0` failed) | — | | Crashes / device loss / dropped draws | `0` / `0` / `0` | `0` / `0` / `0` | `0` / `0` / `0` | ### Remaining Notes - **VRAM budget & page-mover fix clearly worked:** `VK_EXT_memory_budget` jumped by ~3.4 GB once RADV tracked pool pages, and `0` pages waited for room (`15,869`–`21,347` pages moved up seen by the card, `0` refused). - **Heavy scene transitions still hit pool pressure:** On transitions VRAM hit `87–93%` (`11.7–12.4 / 13.4 GB`), `textures picked by index: the card has no room for more` still fired (`444` times in run 1), and at the end of run 2 `texture blocks: 80 alive, 8 being emptied, 0 given back to the card, 2 taken into use again for want of room elsewhere` — looks complementary to #31 (`VICTORY_POOL_MOVE=1`).
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:00 UTC · original · edited 2026-12-05 11:24 UTC

As I read it, this is already in main: all three commits are in main.

  • The tightest-fit texture pool is ce61ce3 ("pool: tightest free range, resting pieces not room; room lines as switches") — crates/victory-gpu/src/pool.rs:141-172 (take), :236 resting_bytes, :506 in_holes, with VICTORY_TEXTURE_ROOM_PERCENT/..._CAP_PERCENT at crates/victory-gpu/src/resource.rs:1870-1873.
  • VICTORY_VRAM_BUDGET_MB is at crates/victory-gpu/src/host.rs:9334-9345.
  • The page-mover ordering fix went further than this PR: crates/victory-gpu/src/um/residency.rs:759 let moving = lazy::moving(); … :798 drop(moving); before the kick, and the flat wave has since been replaced by DOWN_MOST = 512-bounded work, so the constants here are older than what runs.

One thing from this work is still true on main and worth a separate docs PR: VICTORY_VRAM_BUDGET_MB, VICTORY_PAGE_PASS_MS, VICTORY_PAGE_MOVE_MB, VICTORY_TEXTURE_ROOM_PERCENT and VICTORY_TEXTURE_ROOM_CAP_PERCENT are in neither docs/SETTINGS.md nor run.conf.default, so five shipped switches are invisible in the F1 menu. One line each in run.conf.default would fix that.

Whether it still has work of its own is the maintainer's call, not mine.

**@⁠Luxuride** on GitHub · 2026-12-04 12:00 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/44#issuecomment-7410837618) · edited 2026-12-05 11:24 UTC As I read it, this is already in `main`: all three commits are in `main`. - The tightest-fit texture pool is `ce61ce3` ("pool: tightest free range, resting pieces not room; room lines as switches") — `crates/victory-gpu/src/pool.rs:141-172` (`take`), `:236` `resting_bytes`, `:506` `in_holes`, with `VICTORY_TEXTURE_ROOM_PERCENT`/`..._CAP_PERCENT` at `crates/victory-gpu/src/resource.rs:1870-1873`. - `VICTORY_VRAM_BUDGET_MB` is at `crates/victory-gpu/src/host.rs:9334-9345`. - The page-mover ordering fix went further than this PR: `crates/victory-gpu/src/um/residency.rs:759` `let moving = lazy::moving();` … `:798` `drop(moving);` before the kick, and the flat wave has since been replaced by `DOWN_MOST = 512`-bounded work, so the constants here are older than what runs. One thing from this work is still true on `main` and worth a separate docs PR: `VICTORY_VRAM_BUDGET_MB`, `VICTORY_PAGE_PASS_MS`, `VICTORY_PAGE_MOVE_MB`, `VICTORY_TEXTURE_ROOM_PERCENT` and `VICTORY_TEXTURE_ROOM_CAP_PERCENT` are in neither `docs/SETTINGS.md` nor `run.conf.default`, so five shipped switches are invisible in the F1 menu. One line each in `run.conf.default` would fix that. Whether it still has work of its own is the maintainer's call, not mine.
github-bot closed this pull request 2026-12-05 17:31:43 +00:00

Pull request closed

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