VRAM accounting: ~3.4 GB of free texture-pool blocks and ~1.1 GB of free staging while 17,217 texture slots wait #21
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/lobomfz--VIctory-xmem#21
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?
@216598762 on GitHub · 2026-11-30 07:54 UTC · original
Environment
./setup.sh; GE-Proton11-14.cd811c1b5ce8ddc9854230e293e9d9d2df73b44c, Series X profile (CONSOLEunset), 4K output.Z:\home\null\Documents\GTAin both logs), from first frame to the window closing: 131 s and 121 s.VICTORY_FSR_4K=quality,VICTORY_OUTPUT=2560x1440(render 2560×1440 → 3840×2160).VICTORY_FSR_4K=performance,VICTORY_OUTPUT=1920x1080(render 1920×1080 → 3840×2160).Summary
Unified memory is doing what it is for: the title's memory is resident in GTT, mapped through the RADV alias patch, and the VRAM figures below are accounted for entirely by the layer's own caches. The card, however, ends both runs at 94–99 % of the DXGI budget, and the composition at the ceiling looks wrong: 3.4 GB is free space inside 64 MiB texture blocks and 1.1 GB is free staging, while the texture queue reports 17,217 slots, 16,740 of them waiting for memory, and the layer falls back to re-uploading textures in place 154,000 times. No block is ever returned:
0 given back to the card since the start.The two runs (last stats block before the window closed)
The "309 records" are the log lines:
draw.rsprints the refresh message for the first one and every 500th after it (n == 1 || n.is_multiple_of(500)), so 309 records is 154,000 refreshes.Where the 13.7 GB goes (run A, last stats block)
58,984 host copies of the levels viewed alone (4,106 MB on the card, 25,081 MB of title memory whole))targets_room_kept()reserves up to 3,072 MB)That accounts for the 13.7 GB without any title resource in it.
It is not the title's memory
XMemAllocatePhysicalPages: 710 + 185 + 6,236 = 7,131 MB physical for the title.131,437 pages in place in 149 stretches of title memory itselfat 64 KiB per page ≈ 8.0 GiB, all in GTT (theshared 11,112 MBfigure).the card reads and writes title memory where the title has it base=0x400000 mb=3840.card_mb_for_title=4016, andwrite-combined title memory left in RAMnever fired — the 4 GiB title reserve was not even filled.The budget rules involved
um.rs:const CARD_KEPT_FOR_HOST: u64 = 12 << 30;— on this 16,304 MB heap the title gets16,304 − 12,288 = 4,016 MBof write-combined VRAM.resource.rs::room(): host copies are made unconditionally up tobudget / 4(2 GiB), then whileused − texture_room + targets_room_kept < budget × ROOM_PERCENT / 100andused < budget × 92 / 100;ROOM_PERCENT = 86,targets_room_kept()up to 3,072 MB.pool.rs: 64 MiB blocks,SPARE = 2above 80 % (SPARE_WITH_ROOM = 6below),room()runs once a second fromhost::sweep()and reclaims only blocks with nothing left in them; retired blocks rest 5 s before reuse (REST).pool::texture_room()=blocks × 64 MiB − live bytes.Why the free space cannot be used (inferred from the counters)
reclaimonly drops a block whose free ranges cover all 64 MiB (free.whole(BLOCK)), so a block that still holds any piece stays; world-load fragmentation leaves all of them partly used.SPAREis 2 at this pressure (used ≥ 80 % of budget), so even two empty blocks would stay — but with no empty block at all, nothing is returned (0 given back to the card since the start).nothing showed at the last look under pressure, and the texture queue only has 91 slots due out of 17,217.Impact
texture_late kind="after_memory": n = 75,092, mean 6,964 ms, p50 < 4 s, p90 < 32 s, p99 > 32 s (written_to_shownmean is 59 ms, so the wait is memory, not the copy).busy_percent99–100 andgpu_wait_ms15.9 (A) / 29.8 (B).Questions
CARD_KEPT_FOR_HOSTreserve meant to cover this much fragmentation slack, or should the pool be sized against live bytes (or trimmed whenused ≥ 92 %of budget)?pool::room()be allowed to retire a partly used block under pressure, moving its live pieces to other blocks, instead of only completely empty ones? With 2.6 GB live in 93 blocks this would recover most of the 3.4 GB.STAGEDrather than by block count? It ends at 1,095 MB free (run A) and 817 MB free (run B) while the pool is at its ceiling.resource::room()'s 92 % stop leave more room for the queue?Reproduction
./run.sh playwithVICTORY_FSR_4K=qualityandVICTORY_OUTPUT=2560x1440(orperformance/1920x1080), Series X profile.texture blocks free (pool …, staging …, vram used/budget, shared …),texture blocks: … alive … given back to the card …,textures picked by index, the queue: … waiting for their memory …, and theno room for new ones so_far=lines used above.The two play logs are available if they would help.
@LOCKhart07 on GitHub · 2026-11-30 13:53 UTC · original
Same picture here on a 9070 XT (16 GB),
cd811c1, 2560x1440, ray tracing on. While driving: VRAM 13.6 / 15.3 GB, 173 texture slots due, ~19 MB/frame uploaded, GPU 47 ms. Textures flicker and pop in, and there are no dropped draws or missing pipelines.I looked for prior work on this across the VIctory forks: the 30 forks of this repo, plus 97 copies of
crates/victory-gpu/src/pool.rsfound through GitHub code search. None of this repo's forks change the reclaim rule. Two other VIctory forks implement actual compaction:VICTORY_POOL_DRAINandVICTORY_POOL_COMPACT=1, both off by default.compact_choice), as many as the other blocks can absorb while keeping a headroom free (VICTORY_POOL_HEADROOM_MB, default 256).resource::drain_moves), at a rate bounded per second that rises with how far the card is over budget.resource::compact_pool) plusVICTORY_POOL_FIT=bestplacement.Partial measures seen elsewhere: best-fit placement only (a few forks), and 32 MiB or 16 MiB blocks (three forks).
This repo already has half of it:
pool::drain(only)marks blocks so they take no new pieces. Those are the "8 emptying" blocks in the counters above. Nothing moves the live textures out, though, so an emptying block only frees once the title releases every texture in it, which during streaming it doesn't. The piece that's missing compared with tapin is the mover, plus the choice of which blocks to empty.I'm planning to port that piece to xmem: read their design and reimplement it here, behind a switch. I'll report back with before/after numbers from a driving run. Their README also lists texture flicker that remains with compaction on and has no known cause, so compaction likely fixes the wasted VRAM and memory waits, but not necessarily all the flicker.
@grykom on GitHub · 2026-12-01 14:02 UTC · original
@LOCKhart07 before you start the port: we have a give-back branch that already does the missing piece (the mover plus
the choice of blocks), measured today. Sharing so we don't both write it.
What it does, behind
VICTORY_VRAM_GIVE_BACK=1(off = unchanged code):blocks instead of 2-6;
host::sweep()when nothing is in flight: picks up to 16 of the sparsest blocks whosetextures can all move (largest texture fits a free range elsewhere, at least 128 MiB of headroom kept), copies them
GPU->GPU (one list, grouped barriers, own fence), swaps the
HostTextureand the descriptors, keeps the old copy for~1 s + 4 frames before retiring it. Skips textures touched in the last 500 ms, host-written, staged, aliased or held by
a list. 32 MiB/s, 64 MiB/s above 85 % VRAM; holds off for 5 s after the pool grew;
let_go_idle()also lets idle, unpinned textures go fromWaitedOutblocks;Numbers (RX 9070 16 GB, prison cell, 2560x1440, diag build on
cd811c1, A B B A with a second variant in between, 4 minruns; VRAM reading includes ~1.2 GB for a remote-desktop screen, the same in every arm):
(The "off" log doesn't print the free space inside blocks; a third variant in the same series, with the same 64 MiB
blocks and no compaction, logged 3.2-3.4 GB free inside 97-99 blocks.)
budget. With give-back it kept 2.1-2.3 GB of title pages on the card instead of 0.8-0.9 GB, and the peak was still
1.2 GB lower. So about 2.6 GB of VRAM came back in total.
queue and waits for its fence, so it may be the cost, but that is not confirmed. One run also had a 2.2 s stall at
world load, before compaction had started; the second run didn't.
Not yet measured: open world / driving, upstream
main.The branch is on
cd811c1with our older experiment under it, so it is not a PR as is. If it's useful I can push itto my fork for you to read, or port it to current
mainmyself; your call, so we don't both do it.@Aruku448 on GitHub · 2026-12-01 14:17 UTC · original
Same shape on RDNA3 (RX 7800 XT,
37bb30f, wine-staging 11.22, Series X profile at 1080p, RT off), one ~20 minute session:Two things there that are new to me, and both look like the visible defect:
written_uploaded_again(36.14 MB/frame) is essentially equal towritten_under(36.22 MB/frame) whilelooks_sameis 126 MB/frame: almost all of the upload traffic is textures written and then uploaded again inside the same frame, and the comparison layer already proved the bytes match. That is most of the 4.4 ms/framecopy_mshere, before any pumping.24,315 waiting at the end of the session, VRAM at 15,469 of 16,368 MB (94 %), GPU 89 %.
@grykom on GitHub · 2026-12-01 19:47 UTC · original
VRAM give-back on current
main: measurements and a branch to tryFollow-up to my earlier note here. The give-back branch is now ported onto
main(37bb30f) and measured there,on a physical monitor this time. Branch: https://github.com/grykom/VIctory-xmem/tree/give-back-main (commits on top of
37bb30f, all behind switches; unset =main).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 my previous comment.
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.
@TheRifai on GitHub · 2026-12-02 11:26 UTC · original
A comparison point from vkback's arena on the same GPU class (RX 9070 XT, main
d59b4f8, GE-Proton11-16, Series X, 3840x2160, house savert3, 80 s warm-store run,UMEM_MEMREPORT=1):So our free-inside-block fraction is much smaller than the ~50% you saw on VIctory-NVIDIA, but it is fragmented (256 MB largest range, 27 blocks), so compaction alone would not free a whole 64 MB-equivalent block easily. Your point that slack only becomes fps when a consumer uses the freed room still holds; on our side the consumer would be in-place render targets, not page residency. Evidence:
/home/shlong/Documents/VKtory-capture/arena-slack/20261202-122424/. No code change from me.@grykom on GitHub · 2026-12-02 16:18 UTC · original
A data point for current main on RX 9070 16 GB, open world (Mandy save, walking then driving, played by hand on the
same route, ~5 min each, 1440p output, release build, RT off, physical monitor). One run per build, so take it as a
hint, not a verdict.
37bb30f(give-back-main4c6d3c6, switches off =37bb30f+ a page-return counter):the old page pace, 1 s passes of 8 MiB, "seen" source on.
d044248, defaults ("seen" source off sincef68c5c9).d044248withVICTORY_PAGES_SEEN=1.level with A. B leaves ~0.8-1 GB more VRAM free (1.7-1.9 GB vs 0.9 GB), which this card doesn't turn into frames.
logged 8.6k of them "within two seconds of promotion".
37bb30f(reads through a card copy instead of BAR, the Mesa budget patch, ...),so this does not isolate the page pace. It's only where the counters point.
If someone wants to check this on their card: the
page residency:line in the log gives "pages moved up" and"down when the processor touched them";
VICTORY_PAGE_PASS_MS=1000 VICTORY_PAGE_MOVE_MB=8puts back the old pacefrom
518bc1b(the guard release stays). Comparing that against defaults on the same route would show whether thefaster pace is what costs frames in the open world. We may run that ourselves later; numbers from other cards would
help more.
github-bot referenced this issue2026-12-02 19:27:50 +00:00