Memory: a sparse alloc/free loop makes a new 64 MiB pool each cycle; lib tests fill a 12 GB card (#348's test) #913
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#913
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?
@fromthemoonx on GitHub · 2026-11-24 08:09 UTC · original
On a 12 GB card,
cargo test -p xcl --libonmainnow fills video memory and fails withE_OUTOFMEMORY(0x8007000E). The cause is the test #348 added,hle::d3d12x::sparse::tests::a_freed_block_is_decommitted_before_its_address_is_reused. Behind it is a sparse pool pattern a title could hit too: freeing the last tile in use retires its 64 MiB pool, and the next allocation creates a new one.Seen (RTX 3060 12 GB, driver 32.0.16.1088, Ryzen 7 5700X, 16 GB RAM, Windows 11 26300, Rust 1.100.0 MSVC, debug,
maina1672ef)cargo test -p xcl --lib -- --test-threads=4: 3 of 3 runs failed.gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changespanics onE_OUTOFMEMORY, thenplaced_title_textures_share_vram_and_preserve_pixels,transitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryfail on the poisoned lock. With--test-threads=2and=1it fails as well; one later run passed.nvidia-smi, sampled through the run,--test-threads=1):maina1672efmainwith--skip a_freed_block_is_decommitted_before_its_address_is_reusedmain+ #532 (7f94c6fmerged locally)db1ddb2(before #348)db1ddb2good,d208e14bad): first bad commitebbf377(#348). Its parent peaks at ~1.6 GB.uma::get()has no sparse windows yet) and uses nothing. It only grows when earlier tests in the same process set up the sparse windows, which is why--exactruns don't show it.Why (counted with temporary counters in
take_tile/retire_free_pools, not committed)The test allocates and frees one 64 KiB tile 2,000 times on each of 4 threads. After a
free, that tile's pool is completely free, soretire_free_poolsmoves the 64 MiB heap toretired, where it stays for at least 2 s. The nextallocfinds an empty free list andtake_tilecreates a new 64 MiB heap. In one run of this test: 288 pools created, up to 284 retired heaps held at once, about 18 GB asked of a 12 GB card.The same applies outside the test: anything that frees the last tile of a pool and allocates again within 2 s gets a new 64 MiB heap each time.
Possibly relevant: #532 parks decommitted tiles in their pool instead of freeing them at once, so the pool is not all-free and not retired. With it merged, the peak is back to 1.65 GB (table above). Other ways out would be keeping one free pool instead of retiring it, or taking a tile from a pool in
retiredbefore creating a new one. Others have been skipping this test in their PR runs (e.g. #793, #794, #795, #797).Not tested: AMD; release build; a retail title (no title here), so the effect in a game is not measured.
AI use: Claude Code (Claude Opus 5.5) ran the tests, the bisect and the counters, and wrote this issue.
@fromthemoonx on GitHub · 2026-11-24 08:17 UTC · original
One more data point from the same machine.
real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_statefailed in 2 of 15cargo test -p xcl --lib -- --test-threads=4runs onmainf4ce27c, at theassert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0)afterOpenExistingHeapFromAddress.With
--skip a_freed_block_is_decommitted_before_its_address_is_reused, 16 of 16 runs onmain09940bbpassed completely: 674 passed, 0 failed. Neither that failure nor #718's showed up. So it looks like the same memory pressure, though I have not shown the cause directly.AI use: Claude Code (Claude Opus 5.5) did the runs and wrote this.
@DavidM1911 on GitHub · 2026-11-24 08:30 UTC · original
I'll take this one. The mechanism is clear from
take_tile/retire_free_pools: a fully-free pool is moved toretiredfor ≥2 s, buttake_tileonly ever popsself.freeor callsCreateHeap— it never looks atretired, so an alloc/free cycle inside the window mints a fresh 64 MiB heap every time.Plan: in
take_tile, beforeCreateHeap, reuse the oldest retired heap whose unmap fence value has already completed (GetCompletedValue() >= retired.value) — same placement intopools/freeas a fresh heap. Heaps still inside their fence window stay retired, so the #348 decommit-before-reuse ordering is preserved. Unit test around the pool reuse if the existing sparse tests give me a seam; otherwise the suite + smoke.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@juliptree on GitHub · 2026-11-24 09:02 UTC · original
I reproduced the pool churn in a standalone synthetic fixture on an RTX 5060 Ti, driver 616.92. The fixture creates its own D3D12 device and sparse windows, so it runs without whole-suite setup. After four allocation/free cycles, stock
a1672effailed the pool-reuse assertion in 3/3 runs. The same base with #532 at7f94c6fpassed 3/3. After each free, stock reported 0 MiB in active pools, while #532 retained one 64 MiB active pool with a parked tile.The fixture measured active pools only. I didn’t measure retired heaps, peak VRAM, or reproduce the suite-level out-of-memory failure. A separate WARP run confirmed the explicit skip when sparse windows are unavailable. I have a local test-only patch if it would help validate the fix. AI-assisted by Codex.
@SlopTart on GitHub · 2026-11-24 09:34 UTC · original
Same experiment on the AMD/Wine rig (RX 7900 XT, 20 GB), since the issue data is NVIDIA-native only.
Result: reproduces, but order-sensitive here too:
mem_info_vram_usedsampling caught the card at ~19.5 GB of 20 GB - the pool growth is real on RADV/Wine as well.a_freed_block_is_decommitted_before_its_address_is_reused ... ok, 8.16 s run).Matches the issue's own note that growth only happens when earlier tests in the same process have set up sparse windows: on Wine lanes that precondition comes and goes with test interleaving, which is why our 28 batch lanes mostly sailed through.
Counts only.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1,
XCL_NETWORK=0, release profile.AI use: Hermes agent (local Qwen-class) ran the sampling and drafted this; I checked it before posting.
@fromthemoonx on GitHub · 2026-11-24 09:42 UTC · original
A correction to my last comment.
coherent_buffer_sanitizes_console_flags_and_statealso fails without this issue's test. With--skip a_freed_block_is_decommitted_before_its_address_is_reused, it failed in 1 of 3 full runs ofmain6bac4b4+ #953 here, at the sameassert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0). The other two runs passed.So the 16 clean runs I reported were luck. This
VirtualFreefailure is probably a separate flake, not this issue's memory pressure. I have not found its cause.AI use: Claude Code (Claude Opus 5.5).