D3D12.X: detach retired segments and reclaim idle aside allocators #2707
No reviewers
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!2707
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2707"
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?
@Saksukella on GitHub · 2026-11-26 07:51 UTC · original
Saksukella:fix/alloc-pool-retire-reclaim→main· +644 −42 · 5 files · 4 commits · openWhat is in it
crates/xcl/src/hle/d3d12x/alloc_pool.rs:retire_recording(list)to detach a retired split segment or superseded primary list from its oldBacking.userswhile preservingBacking.marksandlast_submit(so GPU completion fences andin_flight(list)remain fully enforced).Backing.already_resetand reclaim idlefree()put-aside backings ontitle_resetso their held UMA arena blocks and scratch buffers return promptly instead of remaining pinned until a future busy swap on that exact title allocator.STATEbefore callingreset_pc_allocator/CreateCommandAllocatorso COM callbacks during allocator reset or resource teardown (such as dropping a pooled preludeID3D12CommandAllocator->real::alloc_release->alloc_pool::forget) cannot self-deadlock onSTATE, and release pending UMA blocks per free backing onforget.title_reset/reset_listraces whileSTATEis unlocked: trackBacking.resetting(Backing::free()requires!self.resetting) with aCondvar(RESET_DONE), reserve the backing inreset_listbefore invoking nativeReset(rolling back onhr < 0), and wait cleanly if a backing is mid-reset.retired_segment_releases_backing_after_gpu_completes_while_preserving_in_flight,clean_title_reset_reclaims_idle_aside_backings_once,stalled_primary_stand_in_reset_keeps_uma_blocks_until_native_backing_resets,reset_list_blocks_concurrent_title_reset_and_rolls_back_on_failure, andreset_list_waits_while_backing_is_resetting.crates/xcl/src/hle/d3d12x/bind.rs&crates/xcl/src/hle/d3d12x/real.rs:bind::State.allocator(and thereforeconsole_list::PENDINGUMA blocks) by the native PC allocator backing (alloc_pool::recording_backing/alloc_pool::current) rather than the logical title allocator, and moveconsole_list::allocator_reset(raw)intoreal::reset_pc_allocator(raw)so swapping away from an in-flight primary backing never frees its UMA blocks while the GPU can still read them.crates/xcl/src/hle/d3d12x/title_list.rs&crates/xcl/src/hle/d3d12x/list_x.rs:alloc_pool::retire_recordingwhentitle_list::resetmoves old split/stand-in segments intospares(and forprimarywhen replaced by astand_in, retiring its UMA blocks viabind::reset(primary, 0, 0)), input_spare, and forKickoffX-reclaimed segments inlist_x.rsafteralloc_pool::executedmarks them.Tested
32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows;rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).cargo test -p xcl --lib hle::d3d12x::alloc_pool::tests -- --test-threads=1: 9 passed, 0 failed (0.11s, includingstalled_primary_stand_in_reset_keeps_uma_blocks_until_native_backing_resets,reset_list_blocks_concurrent_title_reset_and_rolls_back_on_failure, andreset_list_waits_while_backing_is_resetting).cargo test -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=1: 8 passed, 0 failed (0.38s).cargo test -p xcl --lib hle::d3d12x::title_list::tests -- --test-threads=1: 3 passed, 0 failed (0.01s).amd-dev(b5c0275f): previouslycoherentUMA exhausted4095/4095 MB(547 blocks held for 236 allocatorsat63.7k draws / 34.6k dispatches), triggeringunified memory is fulland0x887a0006; with this fix held blocks dropped by >72% (152 blocks / 75 allocators,4046/4095 MBat65.5k draws / 47.0k dispatches) with0unified memory is fullwarnings.Regression run
Not tested
cargo test --workspacewas run on the same baseb49be183in #2703 (1434passed; pre-existing RDNA 4fuzz_validate_and_gpu_1/3failures).AI use
resetting/Condvarconcurrency guard, writing unit tests, and running local tests and smoke verification. All diffs and measurements were reviewed and verified locally on hardware.@fromthemoonx on GitHub · 2026-11-26 08:14 UTC · original
NVIDIA run (listed under Not tested): passes. Both new tests are stable,
list_xfails no differently than onmainin parallel, and the e2e title's D3D12 debug-layer messages are the same asmain's.Tested:
7879954merged ontomainb49be18(clean). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlinesretired_segment_releases_backing_after_gpu_completes_while_preserving_in_flight,clean_title_reset_reclaims_idle_aside_backings_once, alone, 40 runs eachhle::d3d12x::alloc_pool::+title_list::+real::dispatch_chain::(11 tests),--test-threads=8, 30 runshle::d3d12x::list_x::tests::,--test-threads=4, 100 runsa_dispatch_with_a_pipeline_still_building_waits_at_the_submit(7×) androtating_queue_self_deadlock_…(3×), the two that flake onmainthe same way (#2118, #2547)e2etest_title_draws_with_a_root_signature_under_the_debug_layer, merged vsmainNot tested: a title run, Intel, a release build.
AI use: Claude Code (Claude Opus 5.5) ran the suite, the repeats and the debug-layer comparison, and wrote this report.
@luckyteagirl on GitHub · 2026-11-26 08:18 UTC · original · reviewed
At head
7879954925faaa048293f28857febf9eb8aa503b, the newbind::reset(primary, 0, 0)runs precisely whentitle_list::resetselects a stand-in because the primary PC list is still in flight (title_list.rs:157-201).bind::resetmoves that primary recording's UMA blocks toconsole_list::PENDINGunder its old logical title allocator (bind.rs:75-87). A subsequent successful title-allocatorResetcan swap to a different native backing while the old primary is still in flight, butreal::alloc_resetunconditionally callsconsole_list::allocator_reset(this)on success (real.rs:7047-7057), which frees all pending blocks under that logical allocator. The GPU can therefore still read blocks freed by the new stand-in path. Before this PR, the stand-in branch did not transfer the primary's bind blocks at that point. Could those blocks stay owned by the old primary/native backing until its fence completes, with the pending-key/reset path tracking that backing rather than the logical allocator? A regression with a GPU-stalled primary, stand-in list reset, and title-allocator reset would distinguish the two lifetimes.This is an exact-head source review; I did not run a GPU-stalled title reproduction. AI use: OpenAI Codex (GPT-6.2 Sol) traced the interleaving; I checked the bind, pool, and allocator-reset paths before posting.
@sage-sage on GitHub · 2026-11-26 08:48 UTC · original
Test report: passes on NVIDIA. Exact head
78799549(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4: 1437 passed, 0 failed, 47 ignored; the 2 new tests passmainon this machine (wave64, debug layer, Developer Mode, heap windows)Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@Saksukella on GitHub · 2026-11-26 08:55 UTC · original
Good catch @luckyteagirl — fixed in
f796b9e6.bind::State.allocator(and thusconsole_list::PENDING) is now keyed by the native PC allocator backing (alloc_pool::recording_backing/alloc_pool::current) rather than the logical title allocator, andconsole_list::allocator_resetnow runs insidereal::reset_pc_allocator(and for free backings inalloc_pool::forget) rather than unconditionally onalloc_reset(this). Added the regression teststalled_primary_stand_in_reset_keeps_uma_blocks_until_native_backing_resetscovering a GPU-stalled primary, stand-in reset, title-allocator swap reset, and post-fence reclaim. Re-ranalloc_pool(7/7),bind(8/8),title_list(3/3), and a 60s RX 9070 XT smoke run (1669 frames, 0 removals, 0 crashes).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.