Stop reading title memory on the card with the CPU (hitches), stop VRAM creep #93
No reviewers
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!93
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-93"
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?
@prinzjo on GitHub · 2026-12-01 18:41 UTC · original
prinzjo:perf/card-reads→main· +603 −19 · 8 files · 4 commits · merged 2026-12-01 20:55 UTCThe CPU reads VRAM through the BAR at ~100 MB/s (RX 7900 XTX + i7-13700K); texture/buffer refreshes doing that caused 100-3400 ms frames.
Measured: world frames 11 -> 36 fps, copy_ms 122 -> 11 ms (960p). Details in each commit.
Generated with assistance of Claude Code (Opus 5.5 xhigh)
@Daniel-Engelmann on GitHub · 2026-12-01 20:31 UTC · original
Tested this on an 9060 xt 16gb, 14600kf and it works great.
copy_ms 107ms -> 0.72-2.59ms.
worst frame 341 -> 32ms.
in world ~15 fps with constant hitches -> 27-42.
Thanks for the fix!
@EdouardSence on GitHub · 2026-12-01 21:22 UTC · original
Tested on RDNA 4 with Resizable BAR, A/B against main. Short version: on this machine main has no slow-readback problem to fix, and this branch adds dips.
Setup: Ryzen 7 7800X3D, 32 GB, RX 9070 XT 16 GB (Resizable BAR on, 16 GB BAR), CachyOS, Proton-CachyOS, the repo's Mesa 26.3.1 build.
./run.sh playdefaults: 1706x960 -> 2560x1440, RT on. Both builds are release and use the same warm caches. Each one ran 10 minutes, loading the same checkpoint and idling there.37bb30fstats: frame, fps < 95)copy_msOn main,
copy_msstays around 0.3-1 ms with Resizable BAR, so the CPU-reads-VRAM cost this PR targets (122 ms on 7900 XTX + i7-13700K) does not show up here. With the branch,copy_msgoes up to 5-14 ms with an 85 ms spike, and that is where the fps dips fall.My guess, untested: on a large-BAR system, the GPU-copy path for reads of 32 KiB or more (
pull) costs more than the direct read it replaces. If so, the switch could depend on the readback speedsafecopymeasures at startup, rather than applying everywhere.Caveat: one run per build, with idle sampling at the same checkpoint (no scripted movement, so the scene is not frame-identical).
AI-assisted (Claude Code); measured on the hardware above.
@marduuhin on GitHub · 2026-12-01 21:46 UTC · original
Cut CPU reads of VRAM a lot (1.7 GB/min -> 0.35 GB/min) and reduced page shuffling (2.7s/min->1.7s/min).
VICTORY_CARD_PULL=0 is about 5 ms/frame faster on a 5800X3D + 7800 XT, because the CPU reads VRAM faster than the copies do on a busy card (240 vs ~92 MB/s).
@EdouardSence on GitHub · 2026-12-01 22:22 UTC · original
Follow-up with
VICTORY_CARD_PULL=0, which @marduuhin pointed at. Same RX 9070 XT + 7800X3D with Resizable BAR (16 GB BAR). This time I used diag builds with scripted input (VICTORY_KEYS), so all three runs load the same save the same way. 7 minutes each:37bb30fVICTORY_CARD_PULL=0copy_mscopy_ms(after load)What is consistent across both rounds:
copy_msworse: 1.2 → 10.2 ms here, and 1.1 → 6.8 ms in the first round.VICTORY_CARD_PULL=0brings it back to about main's level. This matches the 7800 XT report above.Together with the 9060 XT result (107 → ~1 ms), it looks like the pull only pays off where CPU reads through the BAR are slow. Could the default come from the
safecopytiming the branch already takes at startup? Enable the pull when the measured read speed is low, keep the direct read otherwise. That would keep the 9060 XT / 7900 XTX wins without the extra ~9 ms per frame on large-BAR systems.@Widget9337 on GitHub · 2026-12-02 01:45 UTC · original
A data point from a card where this change costs more than it saves: RX 9070 XT 16 GB (Resizable BAR, 16 GB BAR), Ryzen 9 7950X3D, 64 GB DDR5, CachyOS. Series X profile, 1080p output, PC FSR 4, ray tracing on, 30 fps cap. I tried it twice: on its own, and as part of
mainatf7f0360.On this machine the CPU's reads of VRAM aren't slow. The startup calibration picks streaming loads here:
So with
movntdqathe CPU reads the card at about 1.4 GB/s, not the ~100 MB/s measured on the 7900 XTX. Taking pages down after our reads then costs more than it saves.1. #93 alone, on top of #67/#47/#45, against the same branch without it (about 2–3 min each, similar area):
copy_ms(median / peak)preparing_ms(median)2. On
main(f7f0360, so with #83) plus #126, in about 4 min sessions:VICTORY_PAGES_SEEN=1was needed to get the card to fill again.VICTORY_PAGES_CPU_QUIET=75(#126), copy time was fine (1.5 ms), but "down when the processor touched them" still reached 10,327 in about 2 min.3.
mainwith this PR reverted (everything else the same, paging at 1000 ms / 8 MiB): copy time back to 1.1–1.2 ms, take-downs back to the pre-#93 level, and no pages bouncing between RAM and the card.The new
read_throughbehaviour (every card page our CPU reads goes down at the next wave and is struck for a while) seems to be the costly part.pulltakes reads of 32 KiB and up off the CPU, but the smaller reads and thesafecopypath still take pages down. On a card where streaming reads of the BAR are fast, those pages are better left on the card. Two suggestions:streaming_mb_sis well above the ~100 MB/s case), or put it behind a switch likeVICTORY_CARD_PULL.I only have this one machine and played by hand, so take the numbers as directional. I'm happy to run a build with a switch for the take-down and post A/B numbers.