D3D12.X: reclaim idle put-aside allocators and retire orphaned batches #2138
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!2138
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2138"
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?
@Simon-CR on GitHub · 2026-11-25 05:55 UTC · original
Simon-CR:pr/alloc-pool-reclaim-idle→main· +692 −79 · 5 files · 1 commits · openPut-aside PC command allocators previously stayed dirty in the swap pool until the title happened to reset that exact title allocator again, holding native D3D12 command-allocator allocations and any pending unified-memory blocks indefinitely. In addition, releasing a title allocator with GPU work in flight dropped busy owned spare allocators without waiting for completion and left stale title-allocator references in command-list binding state, while
forget_listran beforebind::forgetandmove_listcould race with background reclamation on reset.This change proactively resets idle put-aside PC allocators, trims excess idle spares per title allocator, keeps busy orphaned spares and title pending blocks tracked behind GPU fences until idle, and orders list release/reset retirement strictly before
alloc_poollist disassociation.What is in it
crates/xcl/src/hle/d3d12x/alloc_pool.rs: add dirty tracking,reset_list_with_retire,retire_orphan_uma,reclaim_idle(skipping off-thread Reset on title-owned allocators and capping excess clean owned spares at 2 per allocator, plus deferring title-allocator pending UMA flushes until all backings for that title allocator are idle),forgetfence-gated orphan capture, throttledmaybe_reclaim_idleon reset/release, and three unit tests covering idle reclaim/trim, fence-gated orphan retirement, and mid-reset reclamation orderingcrates/xcl/src/hle/d3d12x/console_list.rs: addtake_pending,free_uma_blocks, andpending_len_for_testhelperscrates/xcl/src/hle/d3d12x/bind.rs: addretire_uma_blocks(routingallocator == 0throughretire_orphan_uma) andon_title_allocator_release, droppingSTATESlock before retirement inforgetcrates/xcl/src/hle/d3d12x/real.rsandcrates/xcl/src/hle/d3d12x/list_x.rs: orderbind::forgetbeforelist_x::on_releaseandalloc_pool::forget_list(keepingdred::forget_list), clear dead title-allocator bindings on allocator release, and run reset state cleanup (andcl_resetDRED tracking) insidereset_list_with_retirebefore moving the list's backingTested
rustc 1.100.0 (0ef1bc386 2026-11-09)cargo test -p xcl --libtargeted suites (--test-threads=1):alloc_pool::tests7 passed / 0 failed,bind::tests7 passed / 0 failed,console_list::tests5 passed / 0 failed,list_x::tests34 passed / 0 failed,title_list::tests3 passed / 0 failedcargo test --workspace --no-fail-fast -- --test-threads=4: 1266 passed, 2 failed (only pre-existinggpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599 reproduced on unmodifiedorigin/main06c9f550, tracked in #2115 / #1679), 46 ignored across 23 test result summaries (debug build)SKIPPEDtests: gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D); test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))cargo build --release -p xcl) and 60 s retail title run (5ec87c56) completed cleanly with 0 device removals and 0 crashesRegression run
Not tested
mainalone (verified locally across a 240 s retail world-load soak alongside the stacked sparse-arena fallback PR, reducing held blocks from 5,006 across 212 allocators to 392 across 215), NVIDIA GPUs, Intel Arc GPUs, wave32-only GPUs, and Linux/WineAI use
main, adding the unit tests, running the test suite and smoke runs, and drafting this description. All builds, tests, and regression runs were executed locally on the hardware above.@thehollowedone on GitHub · 2026-11-25 06:01 UTC · original
Independent focused run of 998564a3 on Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug.
cargo test --offline --locked -p xcl --lib --no-run, then separate runs of the test binary with--nocapture --test-threads=1:alloc_pool::tests6 passed,bind::tests6,console_list::tests5,list_x::tests29, andtitle_list::tests1. Total 47 passed, 0 failed, 0 ignored, and no runtimeSKIPPEDnotices. This includes the three new allocator retirement tests.Focused synthetic coverage. Retail, memory savings and the workspace suite are outside this report. AI use: OpenAI Codex (GPT-6) ran the tests and drafted this report.
@JoaoPauluu on GitHub · 2026-11-25 06:25 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1363 here; 1353 and 1380 on the twomainruns). The 3 newalloc_pooltests pass under Wine. Nothing in the log shows idle allocators being reclaimed, so this is a regression run only.Tested
x86_64-pc-windows-gnu.998564aas it is (based on6020a33) andmain6e1e2be, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, #2138, #2142, main. New lib tests under Wine, one test per process.Regression run
main (first run):
this PR:
The second
mainrun: 1380 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 06:49 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@Simon-CR on GitHub · 2026-11-25 14:47 UTC · original
Rebased cleanly onto current
main(06c9f550->a6574154), preserving the new#2160/#2163resubmit tracking (last_submit/recordings),#1592DRED pipeline markers/reset hooks insidecl_reset&cl_release, and#929title_listreset behavior. Thanks @thehollowedone, @JoaoPauluu, and @DavidM1911 for the earlier verification passes!Re-tested on
a6574154(RX 9070 XT, Win10):--test-threads=1):alloc_pool7/0 (both#2160resubmit & all 3 reclaim tests pass),bind7/0,console_list5/0,list_x34/0,title_list3/0--no-fail-fast -- --test-threads=4): 1266 passed, 2 pre-existing#2115fuzz failures, 46 ignored06c9f550: 1582 frames vs 1373 onmain, 0 device removals, 0 crashes.@GustavoEllwanger on GitHub · 2026-11-25 18:53 UTC · original
Test report on head
a657415, as is and merged onto currentmain3ceb550(merge96a4009, no conflicts), on NVIDIA (32-lane waves) and AMD RDNA2 (native wave64).Tested
XCL_ADAPTER=5060XCL_ADAPTER=Radeoncargo test --workspace --no-fail-fast -- --test-threads=4:a657415main3ceb5503ceb550The failures are the same on
mainand on the merged tree, so none comes from this PR:gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(3 barriers, expected 1) fails onmainon both GPUs. #2379 and #2420 are about this test.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1on the iGPU (seed 540 ona657415, seed 783 onmain), #2115.SKIPPEDona657415: RTX 5060 28 lines (24 wave64-only or per-lanegpu::tests,heap_window_out_of_memory_falls_back_to_the_switch_form,shaders::tests::pso_measurement_compiles_an_exact_synthetic_record,test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state); iGPU 17 lines (12gpu::per-lane refusals, the same four, onehle::).The new
alloc_pooltests are flaky when they run in parallelXCL_ADAPTER=5060 cargo test -p xcl --lib hle::d3d12x::alloc_pool -- --test-threads=8, 30 runs each:main3ceb550a657415What the failing runs show:
released_lists_leave_only_live_recordings_and_gpu_work_holding_the_backingatalloc_pool.rs:673(no entry found for keyonbackings[&alloc]right afterfence.value.set(7)), orforget_retires_busy_owned_spares_and_title_alloc_pending_after_gpu_fenceatalloc_pool.rs:960(left: 1, right: 0).STATE, so the other tests then fail atSTATE.lock().unwrap()(alloc_pool.rs:180and:268).0xc0000409("thread caused non-unwinding panic"), which takes down every other lib test in the same process.My reading: all the tests share the global
STATE, andmaybe_reclaim_idle()(now called on every reset and release) reclaims what another test has just made idle. That is what reclaim is meant to do at runtime, so I don't see a runtime problem here, only test isolation. The whole suite passed on the RTX 5060 because fewer of these tests overlap there, but it can turn red on other machines.A fix in the style of
title_textures.rs/vram.rs(TEST_LOCK) that made the 30 runs pass here:with
let _serial = serial();as the first line of each of the 7 tests. Tests inlist_x,bindandconsole_listthat go throughalloc_poolwere not part of this stress run.Not tested
Tests run and this report drafted with Claude Code (Claude Opus 5.5); I checked the numbers against the logs.
@Kalmarv on GitHub · 2026-11-26 07:18 UTC · original
On
mainb49be18,alloc_pool::forget(alloc_pool.rs:283) runs at a title allocator's last Release. It takes that allocator's PC allocators out of the pool and releases only the free ones. A PC allocator that a list still records on, or whose submits the GPU is still running, is neither released nor tracked after that. So it stays for the rest of the run, along with what was recorded on it, and the next title allocator makes new ones. This PR'sorphaned_sparesinforget, reclaimed inreclaim_idleonce free, fixes that case.This may be part of the growth reported on #2404: recordings held and PC allocators made kept rising in @pvfreis's (7171860351), @Royalflamejlh's (7183911248) and @KDenKC's (7184267294) runs. We have not measured how much of it this explains. GitHub shows this PR as conflicting with
main; a rebase would let it be tried on top of #2404.AI use: Claude Code with Claude Opus 5.5 read
main'salloc_pool.rsand this PR's diff, and wrote this note.@bmjask on GitHub · 2026-11-25 21:46 UTC · original · reviewed
P2: orphaned UMA can stay unreclaimed indefinitely. retire_orphan_uma only appends; automatic reclaim runs only on title reset/allocator forget. A list outliving released allocator switches to allocator 0, then later release queues UMA; with no subsequent allocator lifecycle event, even completed/empty retirement persists for title lifetime. Schedule/trigger reclaim on orphan enqueue and add no-later-event regression. Also consider avoiding native allocator Reset/dispatch teardown while STATE lock held—select/pin under lock, reset outside, commit under lock—to avoid driver-call serialization risk.
@DavidM1911 on GitHub · 2026-11-26 07:28 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.