Measured on RX 9070: GPU-only VRAM copies of never-CPU-touched physical pages (placement step 4) #17
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory#17
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@grykom on GitHub · 2026-11-30 18:58 UTC · original
Follow-up to #9, same machine and method (RX 9070 16 GB, 7800X3D, 32 GB, Linux 7.3, RADV 26.3.1; VIctory-xmem, not
VKtory; ABBA in one session, prison cell after control is handed over, scripted, diag build).
We implemented a variant of your placement step 4. Physical-pool pages that no alias was ever materialized for the CPU,
and that the card has already asked for, get a copy in 64 MiB VRAM blocks; only the card's view of every alias is
re-pointed at the copy, while the CPU keeps the RAM page, which stays the source of truth. The card's view goes back to
RAM — no copy-back needed — on the first CPU access, when an alias already mapped for the CPU is bound, and before our
own pool-window writes (DirectStorage, copies); on known card writes the slot is copied back first. Pages move
continuously (128 MB per 5 s) as long as 1.3 GB of VRAM stays free; freed slots are reused after 3 s.
in line with your
prison30.md.fit and the gain drops to ~5–9 %, with heavy churn: tens of thousands of pages a minute go back because DirectStorage
rewrites them. Next for us: giving back texture-block slack (cf. xmem issue lobomfz/VIctory-xmem#21) and moving only pages that stay quiet
longer.
them in runs ≥1 MB), so it has to work per 64 KiB page, not as a static split of the pool.
had already changed right before our own write (never the copy) — cause still open. No visual artefacts seen.
Happy to share the code or run something specific on the 9070.
@vktory6 on GitHub · 2026-11-30 23:19 UTC · original · edited 2026-11-30 23:22 UTC
Thanks, this is exactly the measurement our planned GTT-master + VRAM-replica placement needed. I created a task update based on your report:
github.com/vktory6/VKtory@73cfff406aThree things we would like to understand:
Re your next step: we see the same slack on our side (our image arena keeps 1.7-2.2 GB free inside its blocks), so for us the replica and the arena share one VRAM budget, and giving that slack back is part of the same task.
No need to share the code for now: we re-implement in our own design, but your description of the revert triggers is very useful.
@CuteBooty on GitHub · 2026-12-01 01:08 UTC · original
A data point on the slack you both mention, from the Windows / D3D12 side (VIctory-NVIDIA, a different code base; RTX 3070 8 GB, Series S, normal play):
There, too, that free space counts as room, and none of it goes back to the card.
Two things from that tracker that may save you a step when you give the slack back:
On 8 GB the slack is the room a VRAM replica like this one would need, so the two tasks meet here as well.
@grykom on GitHub · 2026-12-01 06:38 UTC · original
Thanks! Answers as far as we have data:
1. The ~4 %
ram_changedreturns. Most likely not a write-combined alias but a race in our own code, found by lobomfz in review (lobomfz/VIctory-xmem#40): our write hooks did not lock the page, so a write that started while the mover was copying the page wrote RAM concurrently; the slot then held torn bytes, and the check saw "RAM changed, slot not". That fits with it always happening right before our own write. We did not re-measure with a fix, because we dropped the copy path and moved the idea into xmem's residency instead. So: probable, not verified.2. Returns in the open world. What we have (open world, 1440p, walking, release build, 3.5 min): ~1.4 GB copied to VRAM and ~49.6k returns caused by DirectStorage writes into those pages, so heavy churn. We did not record how soon after the move a page came back; I'll measure that (time from move to return) and post it in a follow-up.
3. Is ~3 ms/GB the same for hot and rarely read pages? We don't know; we only measured totals. The candidates were all pages the card had asked for at least once, without a per-page read rate. The points we have (prison cell, 1080p): 1 GB → −2.7 ms, 1.7 GB → −5.5 ms, so the second batch was worth no less than the first; and the 710 MB WC pool alone gave −4.0 ms at 1440p. A real split by read frequency would need a per-page heat measure, which we don't have yet.
On the shared budget: agreed. On our side too, VRAM capacity is now the limit (15.4 GB peak at 1080p with 1.7 GB moved); giving back texture slack is the next thing we test.
@vktory6 on GitHub · 2026-12-01 07:35 UTC · original
Thanks to both of you. I added the follow-up to the VRAM replica task in
github.com/vktory6/VKtory@5169307: the likely cause of the ~4 % returns (not verified), and the point that only whole emptied blocks give card memory back, so returning the arena's slack needs compaction.@grykom on GitHub · 2026-12-01 19:45 UTC · original · edited 2026-12-01 19:52 UTC
@vktory6
Follow-up with the return times I promised (question 2).
Setup: VIctory-xmem
37bb30f(upstream page residency with the "seen" source from #40) plus a counter that recordshow long each page stayed on the card before it went down (commit
9054887, now in https://github.com/grykom/VIctory-xmem/tree/give-back-main).RX 9070 16 GB, 1440p, diag build, RT off, physical monitor. "Room" for the title is 4 GB (xmem's VRAM - 12 GiB) and
it was full in both scenes.
Pages that went down, by time on the card (<=1 s / <=5 s / <=30 s / <=120 s / longer):
moving would catch only a small share. In the open world more than half of the moved pages came back during the
run, so for streaming-heavy scenes it's mostly churn.
"Never touched" so far doesn't mean "won't be touched".
Effect on frames, same build, PAGES=1 vs PAGES=0 (details in lobomfz/VIctory-xmem#14):
cell +10 % fps in steady state; open world about equal on average with worse 1 % lows.
On question 3 (hot vs rarely read pages) we still have no per-page read rate, so nothing new there.
@grykom on GitHub · 2026-12-01 19:48 UTC · original · edited 2026-12-01 19:52 UTC
On the shared VRAM budget we talked about: here is the texture-slack side of it (CuteBooty saw ~50 % slack on
VIctory-NVIDIA, we saw 3.3 GB here). Same text as in lobomfz/VIctory-xmem#21:
What it does (behind
VICTORY_VRAM_GIVE_BACK=1): 16 MiB texture/staging blocks instead of 64 MiB, best-fit into thefullest blocks, compaction of the sparsest texture blocks once a second (GPU->GPU copy, descriptor swap, old copy kept
~1 s + 4 frames), idle staging returned after 5-15 s. Details in lobomfz/VIctory-xmem#21. Branch: https://github.com/grykom/VIctory-xmem/tree/give-back-main (on top of
37bb30f, all behind switches; unset = xmemmain).Setup: RX 9070 16 GB, prison cell, 2560x1440, diag build, RT off, 7 min runs, order A B C C B A, physical monitor
(desktop uses ~0.4 GB). Run-to-run spread in this series ~0.4 fps.
main(residency room 4 GB)VICTORY_CARD_KEPT_MB=9216)doesn't use the space. Texture pool slack goes from ~3.3 GB (measured earlier with 64 MiB blocks) to ~100 MB;
~7-8k textures (0.8-0.9 GB) compacted per run.
still 0.4 GB below
main. The room was not full (5.4 of 7.1 GB) and 2.3-2.5 GB stayed free: 43k pages in 7 min isexactly the 128 pages/s pace, so pace is the next limit.
over 80 ms when compaction starts during the cutscene (9-19 vs 7-12). Copy waits on its fence and the texture scan
takes up to ~13 ms; both are known and not fixed yet.
Open world (Mandy save, walk then drive, ~6 min, one run per arm, played by hand on a similar route) is a different
story:
main, PAGES=0main, PAGES=1went back down because the CPU touched them, most after 30 s to a few minutes (return times in vktory6/VKtory#17).
A bigger room in a streaming scene mostly means more churn, not more pages staying on the card.
them (32-64 MiB/s).
churn, and more room doesn't help until pages that will be touched again are told apart from those that won't.
How to measure it on your card (no extra tooling, all in the normal log):
VICTORY_VRAM_GIVE_BACK=1, and optionallyVICTORY_CARD_KEPT_MB=<VRAM - room you want, in MB>tolet residency use what comes back (we used 9216 on 16 GB; on 8-12 GB cards try a smaller room first).
vram give-back ...line:pool_reserved_mbvspool_live_mb(slack),returned_blocks,compacted_mb.page residency: ...line: MB on the card, room, MB of the card free.page returns (...)line (from the counter commit): how long pages stayed on the card before the CPU pulled them back.compaction pass timing(diag, passes over 5 ms): where the compaction time goes.residency filling up.
Most useful to us: small cards (8-12 GB) and open world, which we can't test.
Not for merging as is: the pace/room switches are local experiments, and the give-back stutter at compaction start is
open. If you'd rather take only parts of it (block size + best-fit, staging return, compaction), say which.
@vktory6 on GitHub · 2026-12-01 19:57 UTC · original
Thanks for both. That answers question 2 clearly.
Both are recorded as hints in docs/learnings/memory-placement.md ("Fork hints from issue #17"). Nothing to merge from it as is. On our side the next VRAM step is different: binding render targets over their own game memory, where the census shows up to ~4 GB.
@TheRifai on GitHub · 2026-12-02 15:55 UTC · original
Prior-art check on the XCL UMA fix (Discord post + PRs
xcl-dev/xcl#3695,#3696, upstream#2844/#2977). No code was copied; this is a portability assessment with a local data point.XCL's problem is Windows/D3D12-specific: with
XCL_COHERENT_MB=512the title's 1,277/1,162/258 MB GPU heaps end up in plain, write-watched memory the GPU cannot see, so shaders read zeros and ~2.7 GB is copied/watched per submit. Their fix gives those heaps committed windows of their own in a 16-slot aperture, as NVIDIA driver CUSTOM write-back heaps (#3696), and stops counting freed heaps in the stored coherent-window size (#3695).Our Vulkan path already solves the same visibility problem differently:
umemowns sparse title windows at the title's own addresses (greenfield/umem/src/lib.rswindow/WIN_SHIFT), and GPU-only pools are mapped withpool_view_gpu_only+victory_gpu::title_gpu_only_mapped(no CPU mapping), so the GPU reads/writes heap bytes where the title has them. There is no fixed 16-window aperture and no copy-back for those views. Local check on main3aea0e4, RX 9070 XT / GE-Proton11-16, housert3, 80 s warm-store run withUMEM_MEMREPORT=1(/home/shlong/Documents/VKtory-capture/uma-check/20261202-165333/):views shown 180,600 hidden 13,397,window pages 701,small reads from umem's backing (GPU-only views) 0, pool errors 0. So#3696's symptom does not reproduce here.The one transferable idea is
#3695's accounting: count the heaps alive at once (and holes below the highest used block), not every heap ever asked for. Our VRAM budget is queried live fromVK_EXT_memory_budgetrather than stored across runs, so that leak does not exist here either. The analogous local issue is vkback's arena free space inside blocks (issue #241: 1.5 GB free in 33 blocks, largest range 256 MB), which is a fragmentation problem, not a stored-size problem.@vktory6 on GitHub · 2026-12-02 18:38 UTC · original
Thanks for the portability check and the local UMA run.
Agreed on both points. Our windows already map the GPU-only pools at the title's own addresses, and
small reads from umem's backing (GPU-only views) 0confirms #3696's symptom doesn't exist here. The VRAM budget is read live fromVK_EXT_memory_budget, so #3695's stored-size leak doesn't exist here either. The arena fragmentation you point to is already tracked: compaction in "Memory placement: VRAM vs GTT", and the #241 growth in "Long sessions and VRAM headroom". Nothing new for TASKS from this one.This issue's own findings (placement step 4, return times, pool slack) are in "Memory placement: VRAM vs GTT" and in docs/learnings/memory-placement.md, so I'm closing it. Thanks to everyone who measured here.