D3D12.X: reclaim idle put-aside allocators and retire orphaned batches #2138

Open
github-bot wants to merge 1 commit from github-bot/gh-2138 into main AGit
Owner

@⁠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 · open

Put-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_list ran before bind::forget and move_list could 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_pool list 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), forget fence-gated orphan capture, throttled maybe_reclaim_idle on reset/release, and three unit tests covering idle reclaim/trim, fence-gated orphan retirement, and mid-reset reclamation ordering
  • crates/xcl/src/hle/d3d12x/console_list.rs: add take_pending, free_uma_blocks, and pending_len_for_test helpers
  • crates/xcl/src/hle/d3d12x/bind.rs: add retire_uma_blocks (routing allocator == 0 through retire_orphan_uma) and on_title_allocator_release, dropping STATES lock before retirement in forget
  • crates/xcl/src/hle/d3d12x/real.rs and crates/xcl/src/hle/d3d12x/list_x.rs: order bind::forget before list_x::on_release and alloc_pool::forget_list (keeping dred::forget_list), clear dead title-allocator bindings on allocator release, and run reset state cleanup (and cl_reset DRED tracking) inside reset_list_with_retire before moving the list's backing

Tested

  • Hardware & OS: AMD Radeon RX 9070 XT (driver 32.0.32015.7029), AMD Ryzen 7 5800X, Windows 10 Pro 26H2 (Build 26300.9974), rustc 1.100.0 (0ef1bc386 2026-11-09)
  • cargo test -p xcl --lib targeted suites (--test-threads=1): alloc_pool::tests 7 passed / 0 failed, bind::tests 7 passed / 0 failed, console_list::tests 5 passed / 0 failed, list_x::tests 34 passed / 0 failed, title_list::tests 3 passed / 0 failed
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1266 passed, 2 failed (only pre-existing gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599 reproduced on unmodified origin/main 06c9f550, tracked in #2115 / #1679), 46 ignored across 23 test result summaries (debug build)
  • SKIPPED tests: 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))
  • Release build (cargo build --release -p xcl) and 60 s retail title run (5ec87c56) completed cleanly with 0 device removals and 0 crashes

Regression run

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 9070 XT
title: 5ec87c56
seconds: 60
exit: 0x0
frames shown: 1373 (PresentX 1374)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19392 MB
xcl-smoke v1
commit: a6574154ea1175b2b2c5f57a355a7a9a01fef55d
gpu: AMD Radeon RX 9070 XT
title: 5ec87c56
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20545 MB

Not tested

  • Multi-minute world-load allocator-exhaustion soak on unmodified main alone (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/Wine

AI use

  • Antigravity (frontier model; exact model identifier not exposed to agent) assisted with designing the reclaim/orphan-retirement state machine, porting/rebasing against 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.
**@⁠Simon-CR** on GitHub · 2026-11-25 05:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138) `Simon-CR:pr/alloc-pool-reclaim-idle` → `main` · +692 −79 · 5 files · 1 commits · open Put-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_list` ran before `bind::forget` and `move_list` could 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_pool` list 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), `forget` fence-gated orphan capture, throttled `maybe_reclaim_idle` on reset/release, and three unit tests covering idle reclaim/trim, fence-gated orphan retirement, and mid-reset reclamation ordering - `crates/xcl/src/hle/d3d12x/console_list.rs`: add `take_pending`, `free_uma_blocks`, and `pending_len_for_test` helpers - `crates/xcl/src/hle/d3d12x/bind.rs`: add `retire_uma_blocks` (routing `allocator == 0` through `retire_orphan_uma`) and `on_title_allocator_release`, dropping `STATES` lock before retirement in `forget` - `crates/xcl/src/hle/d3d12x/real.rs` and `crates/xcl/src/hle/d3d12x/list_x.rs`: order `bind::forget` before `list_x::on_release` and `alloc_pool::forget_list` (keeping `dred::forget_list`), clear dead title-allocator bindings on allocator release, and run reset state cleanup (and `cl_reset` DRED tracking) inside `reset_list_with_retire` before moving the list's backing **Tested** - Hardware & OS: AMD Radeon RX 9070 XT (driver 32.0.32015.7029), AMD Ryzen 7 5800X, Windows 10 Pro 26H2 (Build 26300.9974), `rustc 1.100.0 (0ef1bc386 2026-11-09)` - `cargo test -p xcl --lib` targeted suites (`--test-threads=1`): `alloc_pool::tests` 7 passed / 0 failed, `bind::tests` 7 passed / 0 failed, `console_list::tests` 5 passed / 0 failed, `list_x::tests` 34 passed / 0 failed, `title_list::tests` 3 passed / 0 failed - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1266 passed, 2 failed (only pre-existing `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599 reproduced on unmodified `origin/main` `06c9f550`, tracked in #2115 / #1679), 46 ignored across 23 test result summaries (debug build) - `SKIPPED` tests: 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)) - Release build (`cargo build --release -p xcl`) and 60 s retail title run (`5ec87c56`) completed cleanly with 0 device removals and 0 crashes **Regression run** ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: AMD Radeon RX 9070 XT title: 5ec87c56 seconds: 60 exit: 0x0 frames shown: 1373 (PresentX 1374) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19392 MB ``` ``` xcl-smoke v1 commit: a6574154ea1175b2b2c5f57a355a7a9a01fef55d gpu: AMD Radeon RX 9070 XT title: 5ec87c56 seconds: 60 exit: 0x0 frames shown: 1582 (PresentX 1582) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20545 MB ``` **Not tested** - Multi-minute world-load allocator-exhaustion soak on unmodified `main` alone (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/Wine **AI use** - Antigravity (frontier model; exact model identifier not exposed to agent) assisted with designing the reclaim/orphan-retirement state machine, porting/rebasing against `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.
Reclaim idle put-aside PC command allocators proactively via reset_list_with_retire and reclaim_idle, cap excess clean spares at 2 per allocator, hold orphaned busy spares and pending UMA blocks behind GPU fences until idle, and order bind::forget and list_x cleanup strictly before alloc_pool::forget_list and release.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:20:15 +00:00
Author
Owner

@⁠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::tests 6 passed, bind::tests 6, console_list::tests 5, list_x::tests 29, and title_list::tests 1. Total 47 passed, 0 failed, 0 ignored, and no runtime SKIPPED notices. 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.

**@⁠thehollowedone** on GitHub · 2026-11-25 06:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7154364108) Independent focused run of [998564a3](https://github.com/xcl-dev/xcl/commit/998564a3b5f6bde7303f0eb5a1faca4ff1386fbd) 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::tests` 6 passed, `bind::tests` 6, `console_list::tests` 5, `list_x::tests` 29, and `title_list::tests` 1. Total 47 passed, 0 failed, 0 ignored, and no runtime `SKIPPED` notices. 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.
Author
Owner

@⁠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 two main runs). The 3 new alloc_pool tests pass under Wine. Nothing in the log shows idle allocators being reclaimed, so this is a regression run only.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 998564a as it is (based on 6020a33) and main 6e1e2be, 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):

xcl-smoke v1
commit: 6e1e2befc7430126b1e7b98b5c3fe93813c866b6
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1353 (PresentX 1353)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 998564a3b5f6bde7303f0eb5a1faca4ff1386fbd
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1363 (PresentX 1363)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1380 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the whole test suite on this head, a long run where allocators go idle, native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the tests and the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-25 06:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7154775303) 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 two `main` runs). The 3 new `alloc_pool` tests pass under Wine. Nothing in the log shows idle allocators being reclaimed, so this is a regression run only. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `998564a` as it is (based on `6020a33`) and `main` `6e1e2be`, 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): ``` xcl-smoke v1 commit: 6e1e2befc7430126b1e7b98b5c3fe93813c866b6 gpu: NVIDIA GeForce RTX 3060 title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1353 (PresentX 1353) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` this PR: ``` xcl-smoke v1 commit: 998564a3b5f6bde7303f0eb5a1faca4ff1386fbd gpu: NVIDIA GeForce RTX 3060 title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1363 (PresentX 1363) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` The second `main` run: 1380 frames, `exit: 0x0`, no device removal, no crash. Under Wine, `peak commit` reads 0 MB, so these blocks do not check memory. **Not tested** - the whole test suite on this head, a long run where allocators go idle, native Windows. **AI use** - Claude Code (Claude Opus 5.5) built both commits, ran the tests and the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
Author
Owner

@⁠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!

**@⁠DavidM1911** on GitHub · 2026-11-25 06:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7155193230) 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!
Author
Owner

@⁠Simon-CR on GitHub · 2026-11-25 14:47 UTC · original

Rebased cleanly onto current main (06c9f550 -> a6574154), preserving the new #2160/#2163 resubmit tracking (last_submit / recordings), #1592 DRED pipeline markers/reset hooks inside cl_reset & cl_release, and #929 title_list reset behavior. Thanks @⁠thehollowedone, @⁠JoaoPauluu, and @⁠DavidM1911 for the earlier verification passes!

Re-tested on a6574154 (RX 9070 XT, Win10):

  • Targeted (--test-threads=1): alloc_pool 7/0 (both #2160 resubmit & all 3 reclaim tests pass), bind 7/0, console_list 5/0, list_x 34/0, title_list 3/0
  • Full workspace (--no-fail-fast -- --test-threads=4): 1266 passed, 2 pre-existing #2115 fuzz failures, 46 ignored
  • Paired 60 s smoke against 06c9f550: 1582 frames vs 1373 on main, 0 device removals, 0 crashes.
**@⁠Simon-CR** on GitHub · 2026-11-25 14:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7165813220) Rebased cleanly onto current `main` (`06c9f550` -> `a6574154`), preserving the new `#2160`/`#2163` resubmit tracking (`last_submit` / `recordings`), `#1592` DRED pipeline markers/reset hooks inside `cl_reset` & `cl_release`, and `#929` `title_list` reset behavior. Thanks @⁠thehollowedone, @⁠JoaoPauluu, and @⁠DavidM1911 for the earlier verification passes! **Re-tested on `a6574154` (RX 9070 XT, Win10):** - Targeted (`--test-threads=1`): `alloc_pool` 7/0 (both `#2160` resubmit & all 3 reclaim tests pass), `bind` 7/0, `console_list` 5/0, `list_x` 34/0, `title_list` 3/0 - Full workspace (`--no-fail-fast -- --test-threads=4`): 1266 passed, 2 pre-existing `#2115` fuzz failures, 46 ignored - Paired 60 s smoke against `06c9f550`: 1582 frames vs 1373 on `main`, 0 device removals, 0 crashes.
Author
Owner

@⁠GustavoEllwanger on GitHub · 2026-11-25 18:53 UTC · original

Test report on head a657415, as is and merged onto current main 3ceb550 (merge 96a4009, no conflicts), on NVIDIA (32-lane waves) and AMD RDNA2 (native wave64).

Tested

  • AMD Ryzen 7 7700, Windows 11 build 26200.9974, Rust 1.95.0 MSVC, debug.
    • NVIDIA GeForce RTX 5060 (driver 32.0.16.1088), XCL_ADAPTER=5060
    • AMD Radeon RDNA2 iGPU (driver 32.0.21042.62), XCL_ADAPTER=Radeon
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
tree RTX 5060 RDNA2 iGPU
this PR, a657415 1268 passed, 0 failed, 46 ignored 1267 passed, 1 failed, 46 ignored
main 3ceb550 1346 passed, 1 failed, 46 ignored 1345 passed, 2 failed, 46 ignored
this PR merged onto 3ceb550 1349 passed, 1 failed, 46 ignored 1348 passed, 2 failed, 46 ignored

The failures are the same on main and 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 on main on both GPUs. #2379 and #2420 are about this test.
  • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 on the iGPU (seed 540 on a657415, seed 783 on main), #2115.
  • SKIPPED on a657415: RTX 5060 28 lines (24 wave64-only or per-lane gpu:: 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 (12 gpu:: per-lane refusals, the same four, one hle::).

The new alloc_pool tests are flaky when they run in parallel

XCL_ADAPTER=5060 cargo test -p xcl --lib hle::d3d12x::alloc_pool -- --test-threads=8, 30 runs each:

tree tests result
main 3ceb550 4 30 passed, 0 failed
this PR, a657415 7 7 passed, 23 failed (two more sets of 30: 7 / 23 and 10 / 20)
this PR, tests serialized with a lock (local change, below) 7 30 passed, 0 failed

What the failing runs show:

  • The first panic is one test seeing another test's state, for example released_lists_leave_only_live_recordings_and_gpu_work_holding_the_backing at alloc_pool.rs:673 (no entry found for key on backings[&alloc] right after fence.value.set(7)), or forget_retires_busy_owned_spares_and_title_alloc_pending_after_gpu_fence at alloc_pool.rs:960 (left: 1, right: 0).
  • It poisons STATE, so the other tests then fail at STATE.lock().unwrap() (alloc_pool.rs:180 and :268).
  • In 22 of the 23 failing runs the binary then aborts with 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, and maybe_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:

#[cfg(test)]
mod tests {
    use super::*;

    static TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
    fn serial() -> std::sync::MutexGuard<'static, ()> {
        TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner())
    }

    #[test]
    fn a_spare_whose_reset_fails_stays_available_for_retry() {
        let _serial = serial();
        // ...

with let _serial = serial(); as the first line of each of the 7 tests. Tests in list_x, bind and console_list that go through alloc_pool were not part of this stress run.

Not tested

  • A retail title or a smoke run.
  • A release build.

Tests run and this report drafted with Claude Code (Claude Opus 5.5); I checked the numbers against the logs.

**@⁠GustavoEllwanger** on GitHub · 2026-11-25 18:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7171539062) Test report on head `a657415`, as is and merged onto current `main` `3ceb550` (merge `96a4009`, no conflicts), on NVIDIA (32-lane waves) and AMD RDNA2 (native wave64). **Tested** - AMD Ryzen 7 7700, Windows 11 build 26200.9974, Rust 1.95.0 MSVC, debug. - NVIDIA GeForce RTX 5060 (driver 32.0.16.1088), `XCL_ADAPTER=5060` - AMD Radeon RDNA2 iGPU (driver 32.0.21042.62), `XCL_ADAPTER=Radeon` - `cargo test --workspace --no-fail-fast -- --test-threads=4`: | tree | RTX 5060 | RDNA2 iGPU | |---|---|---| | this PR, `a657415` | 1268 passed, 0 failed, 46 ignored | 1267 passed, 1 failed, 46 ignored | | `main` `3ceb550` | 1346 passed, 1 failed, 46 ignored | 1345 passed, 2 failed, 46 ignored | | this PR merged onto `3ceb550` | 1349 passed, 1 failed, 46 ignored | 1348 passed, 2 failed, 46 ignored | The failures are the same on `main` and 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 on `main` on both GPUs. #2379 and #2420 are about this test. - `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` on the iGPU (seed 540 on `a657415`, seed 783 on `main`), #2115. - `SKIPPED` on `a657415`: RTX 5060 28 lines (24 wave64-only or per-lane `gpu::` 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 (12 `gpu::` per-lane refusals, the same four, one `hle::`). **The new `alloc_pool` tests are flaky when they run in parallel** `XCL_ADAPTER=5060 cargo test -p xcl --lib hle::d3d12x::alloc_pool -- --test-threads=8`, 30 runs each: | tree | tests | result | |---|---|---| | `main` `3ceb550` | 4 | 30 passed, 0 failed | | this PR, `a657415` | 7 | 7 passed, 23 failed (two more sets of 30: 7 / 23 and 10 / 20) | | this PR, tests serialized with a lock (local change, below) | 7 | 30 passed, 0 failed | What the failing runs show: - The first panic is one test seeing another test's state, for example `released_lists_leave_only_live_recordings_and_gpu_work_holding_the_backing` at `alloc_pool.rs:673` (`no entry found for key` on `backings[&alloc]` right after `fence.value.set(7)`), or `forget_retires_busy_owned_spares_and_title_alloc_pending_after_gpu_fence` at `alloc_pool.rs:960` (`left: 1, right: 0`). - It poisons `STATE`, so the other tests then fail at `STATE.lock().unwrap()` (`alloc_pool.rs:180` and `:268`). - In 22 of the 23 failing runs the binary then aborts with `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`, and `maybe_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: ```rust #[cfg(test)] mod tests { use super::*; static TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); fn serial() -> std::sync::MutexGuard<'static, ()> { TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()) } #[test] fn a_spare_whose_reset_fails_stays_available_for_retry() { let _serial = serial(); // ... ``` with `let _serial = serial();` as the first line of each of the 7 tests. Tests in `list_x`, `bind` and `console_list` that go through `alloc_pool` were not part of this stress run. **Not tested** - A retail title or a smoke run. - A release build. Tests run and this report drafted with Claude Code (Claude Opus 5.5); I checked the numbers against the logs.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-26 07:18 UTC · original

On main b49be18, 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's orphaned_spares in forget, reclaimed in reclaim_idle once 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's alloc_pool.rs and this PR's diff, and wrote this note.

**@⁠Kalmarv** on GitHub · 2026-11-26 07:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7185321742) On `main` `b49be18`, `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's `orphaned_spares` in `forget`, reclaimed in `reclaim_idle` once 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`'s `alloc_pool.rs` and this PR's diff, and wrote this note.
Author
Owner

@⁠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.

**@⁠bmjask** on GitHub · 2026-11-25 21:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#pullrequestreview-6065416686) · **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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 07:28 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 07:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2138#issuecomment-7185504710) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/list_x.rs
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.
git fetch -u origin '+refs/pull/2138/head:github-bot/gh-2138'
git switch 'github-bot/gh-2138'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2138'
git switch 'github-bot/gh-2138'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2138'
git switch 'github-bot/gh-2138'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2138'
git switch 'main'
git merge --squash 'github-bot/gh-2138'
git switch 'main'
git merge --ff-only 'github-bot/gh-2138'
git switch 'main'
git merge 'github-bot/gh-2138'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.