GPU heaps in host memory: residency, CPU readback and wait-release data from a PS5 relinker #1640
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1640
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?
@Astronaut10 on GitHub · 2026-11-24 18:31 UTC · original
Data from AnyPS5 (PS5 titles on Linux/Vulkan; part of XCL's recompiler was ported from it), which uses the same memory model: the GPU reads title memory in place from host memory. Measured on Astro Bot, RX 9070 XT at PCIe 3.0 x16; PCIe 4/5 hosts pay less per byte.
1. Write-combined graphics memory is not only upload data.
kernelx.rsputs the title'sPAGE_GRAPHICS_*heaps in the coherent window, as upload heaps. On the console that memory also holds geometry the GPU reads every frame. In ours:Palmwave measured the same on the retail title (one pass 431 ms in host memory, 0.45 ms in VRAM). With 15–21 GB already in use on 16 GB cards, moving whole heaps to VRAM may not fit; a budgeted copy of the ranges the GPU reads often and the CPU rarely writes got most of the gain for us.
2. CPU reads of GPU writes in the sparse windows. The CPU's view is not updated there. A first-touch census (protect the pages the GPU wrote, count the CPU's first touch) found ~96 % of the GPU's stores into title memory overwritten before any CPU read. The same mechanism becomes copy-back on first touch: exact at little cost, and it shows which memory needs the coherent window.
3. Waits whose producer is not submitted yet (#1452). Our frame replay tool hit the same class. Every one turned out to be signalled by GPU work submitted later. Releasing them on a timer let them go 0–2 frames before their producer, and only 73–76 % of output pixels matched; releasing only when nothing else could run needed no releases at all and raised that to 92 %. A timer release can also explain wrong images.
AI-assisted (Claude Code); numbers from our own runs, no XCL or the retail title data.
@CharlyRien on GitHub · 2026-11-24 22:36 UTC · original · edited 2026-11-24 22:37 UTC
A data point on what makes the host-memory heap expensive for compute, from offline benchmarks and a retail title on an RTX 3090 (driver 616.56, Windows 11): for loads, the multiplier is the
globallycoherentqualifier on a view of the imported heap, much more than host memory by itself.Micro-benchmark (one buffer, 1 024 dependent loads per thread, GPU timestamps; ns per load per wave)
globallycoherentOpenExistingHeapFromAddressgloballycoherent, same addressOne captured world-load dispatch of the title, replayed offline with its real inputs (32x32x2 groups of 4x4x4, loops reading a constant buffer in the committed window): 7 369 ms as the runtime does it, 9.95 ms with the same views not
globallycoherent(byte-identical output), 12.7 ms with the windows in video memory.So for data the dispatch only reads, dropping the qualifier (#1850) gets what a copy in video memory gets, without the copy. A copy still pays where the qualifier has to stay: with #1850's rule the programs that use an atomic keep it and carry about 5 s of GPU time per world frame here; with the committed window copied to video memory (#1329 forced on Windows) the same frame is about 0.35 s. Details in #1850.
About point 1 above: the 431 ms against 0.45 ms pass has the same shape as ours. It may be worth checking whether its views were
globallycoherent(before #1850 every compute memory window is), because then most of that cost is the qualifier and not the bus.About point 3 (timer releases): on the copy path we see about twenty
GPU queue.Wait … did not complete within 5000 msreleases per world frame, every queue waiting on the others, and the 3D scene comes out flat grey. Whether the two are linked is not established yet; that is what I am looking at now.Setup (edited in)
main9e3831emerged locally with #1288, #1448, #684, #889, #1323, #929 and #640, plus local diagnostics (GPU timestamp queries around each operation, a device-removal watcher); the 5 s figure adds the HLSL-path part of #1850, the 0.35 s figure adds #1326, #1327 and #1329 withXCL_UMA_SHADOW=1.VirtualAlloc,OpenExistingHeapFromAddress, placed buffers, views taken from the descriptor heap withXCL_HEAP_WINDOWS=1) and times dispatches with timestamp queries, median of 3.XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1, warm DXIL and driver caches, scripted A presses, 230 – 300 s per run, noXCL_PSO_WAIT_MSunless a row says so.XCL_PSO_WAIT_MS); the title's own stall watchdog is neutralised so that long stalls can be observed.TdrDelayandTdrDdiDelayset to 30 s. With the default 2 s the driver resets the device during the multi-second dispatches (System event 4101) and nothing can be timed.Not tested: AMD or Intel GPUs, other drivers, stores and atomics through each kind of view (being measured).
AI use: Claude Code (Claude Fable 5.2) wrote the harness, ran the measurements and drafted this.