amd-dev: XMemVirtualAlloc GPU heaps go to the sparse windows since 108cbafa (+10 GB peak commit, every amd-dev PR fails pr_check's 1.25x commit rule) #3360
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?
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-29T10:20:52Z.
Setup
Windows 11, AMD RX 6650 XT (8 GB), 32 GB RAM. One retail title,
scripts/smoke.ps1 -Seconds 60,XCL_PREPARE=0, otherwise default environment, compute pipeline cache warmed withxcl pso-precompile <game> --used. Every build measured the same way, one run at a time.The gap
d8bd9a382c717a04f33df5a7scripts/pr_check.pyrequires a PR's peak commit to be at most 1.25x main's (19349 MB here), soevery PR against amd-dev fails that line on this machine whatever it changes.
Cause
Commit
108cbafa("kernelx: decode XMemVirtualAlloc XMemFlags and refine graphics protectionhandling") makes
xmem_virtual_alloc_flagsaddMEM_GRAPHICSwhenever XMemFlags bit 1 is set.The title's GPU heaps (four commits, about 4.5 GB in all, with GPU-accessible PAGE_GRAPHICS_*
protections) come through XMemVirtualAlloc with that bit set. With
MEM_GRAPHICSthey hitVirtualAlloc's
MEM_GRAPHICS->sparse::allocbranch before they reach the GPU-heap branch thatputs them in the coherent window. So:
reach 4.8 GB by 8 s, 4.4 GB of it never written by the CPU, and the process goes over its video
memory budget (24 warnings per run);
empty: the log shows
coherent 64/4095 MB, against3998/4095 MBon the merge-base.Checks that confirm it:
XCL_TRACE_MEMshows the four heaps as "graphics, sparse VRAM" with flags0x30003000 (MEM_GRAPHICS set).
XCL_COHERENT_MB=512on amd-dev alone gives 21220 MB, so the emptywindow accounts for about 4.2 GB of the gap.
Proposed fix
In
xmem_virtual_alloc_flags, a commit (MEM_COMMIT) with a GPU-accessible protection(
PAGE_GRAPHICS_GPU_ACCESS) and only the XMemFlags graphics bit gets noMEM_GRAPHICS, so ittakes the GPU-heap path again (coherent window, or the sparse windows with
XCL_COHERENT_HEAPS=sparse). Reservations, PAGE_GRAPHICS_NOACCESS-only commits and legacyXALLOC_ATTRIBUTES memory types keep
MEM_GRAPHICS. The fix is the draft PR #3369 (close it if108cbafa's routing was intended):
f33df5a7No device removal or crash.
cargo test -p xcl --lib hle::kernelx: 86 passed, 0 failed,1 ignored.
Open points:
108cbafamean to move the heaps to video memory (GPU speed, or in-world correctness)? Thecoherent window is system memory read over PCIe, which is slow for compute (see #2987's data), so
the sparse routing may be faster on a card with room. On an 8 GB card it is not: the sparse
pools put local video memory over the DXGI budget (about 6.3-6.6 GB here), and the same compute
dispatches then ran 4-45x slower once WDDM paged (one program 2.7-3.1 ms under budget, 133-365 ms
over it, in a GPU-timed run on this card) (earlier base, before
108cbafa). So the routing probably wants to depend on the card's video memory budget,not be fixed either way. Related: #3173, #2009.
The commit message does not say. If it did,
XCL_COHERENT_HEAPS=sparsestill gives that routing,but then the stored coherent size should follow so that the window is not committed empty.
plain memory, as on the merge-base. About 157 "retired unified-memory blocks ... given back"
warnings appear per run.
the Series S profile, NVIDIA.
Main is also about 4.8 GB below the merge-base on its own, from changes amd-dev does not have yet.
That part of the gap is not caused by amd-dev.
AI use: Claude Code (Claude Opus 5.5, medium effort, subagent) measured and wrote this; coordinated by Claude Code (Claude Sonnet 5.5); the account owner did not write it.
108cbafais onamd-devonly (a direct commit, no PR);mainandnvidia-devdo not have it, andmain's own run is the 15.5 GB above.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-29T12:27:32Z.
Not intended –
108cbafawas meant to decode the XMemFlags and strip NOCACHE/WRITECOMBINE; routing the committed GPU heaps throughMEM_GRAPHICS→sparse::allocahead of the coherent-window branch was a side effect (our own runs usedXCL_COHERENT_HEAPS=sparse:1024, which hid it). Your diagnosis matches the code. I've merged #3369 on top of amd-dev (10582c42) – thanks!Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-29T13:23:51Z.
Paired 90 s menu-only smoke of
amd-devbefore and after #3369, single run each, so treat the numbers as one sample.Setup: RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003, Windows 11 build 26200. Release builds,
scripts/smoke.ps1-style 90 s guest timer,XCL_PREPARE=0, isolated copy of the shader/driver cache per arm, same title and same settings in both arms. The only code difference between the two commits is #3369 (kernelx.rs, 22 added / 8 removed lines).f33df5a76b(before)10582c426(after #3369)So the symptom in this issue reproduces on this card (about 12 GiB more peak commit, and the coherent window almost empty while the sparse windows take the heaps), and #3369 removes it. I saw no over-budget warnings in either arm here: Windows' local budget was 12.4 GiB before the fix versus 15.4 GiB after, with peak usage under it in both. Only the menu was tested, not world load, and nothing on RDNA4 or NVIDIA.
Thanks to @iggyvilla for the diagnosis.
AI use: this run and comment were made with Claude Code, Claude Sonnet 5.5.