D3D12.X: fail closed on heap retirement fences and sweep idle arenas without PAGES #2528

Open
Decodere wants to merge 2 commits from upstream-pr/2538 into main
Decodere commented 2026-11-25 22:06:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T22:06:04Z.


Part of #1773
Part of #1585
Part of #1833

What is in it

Fixes three VRAM heap retirement and idle arena reclamation bugs in crates/xcl/src/hle/d3d12x/vram.rs (without touching Arenas::take_for), updated in follow-up commit 2fc8268271f4d025d408527a9b9cfd62730fab1c to address @throny's pre-merge review:

  • Fail closed on CreateFence/Signal failure with single-pass signaling (RetireQueue): Previously, under VRAM/commit pressure, if make_fence or signal failed on all live queues (with unmap_mark == None), retire_with saw marks.is_empty() and returned heaps immediately to drop while live queues were still using them; if it failed on 1 of N live queues, that queue was omitted so sweep_with dropped the heaps as soon as the remaining queues finished. RetiringBatch::marks is now Option<Vec<(F, u64)>> (None = unarmed), RetireQueue::capture_marks returns None if ANY queue fails make_fence or signal (preserving monotonic *v += 1 on any already-signaled queue), and RetireQueue::retire_and_arm_with (called from retire_heaps_and_sweep) queues newly_reclaimed unarmed first and calls retry_unarmed_with once so each live queue receives at most one Signal per call across previously-unarmed batches and newly_reclaimed (while returning heaps immediately only when queues.is_empty() && unmap_mark.is_none(), keeping unmap_mark-only batches waiting on unmap_mark, and leaving previously-unarmed batches fail-closed when queues.is_empty()).
  • Reject D3D12 u64::MAX device-removed sentinel in RetireQueue::sweep_with: Added pure helper fence_reached(completed, target) (completed != u64::MAX && completed >= target) and applied it to unmap_mark, b.marks, and dead-queue fence pruning so ID3D12Fence::GetCompletedValue() == u64::MAX on device removal never falsely reaps pending batches or prunes fences.
  • Non-blocking, 1 s lock-free throttled idle-arena sweep from before_execute: Added per-device last_sweep: Vec<(usize, Instant)>, record_sweep, and sweep_dropped_for_if_due (1 s interval, pruning last_sweep when no arenas remain for dev) to Arenas<H>, plus ARENA_COUNT synchronized on every ARENAS list mutation (place, before_execute). In before_execute, has_pages is tracked during the PAGES lock: on do_reclaim (1 s PAGES tick), ARENAS.try_lock() sweeps idle arenas without blocking the submit thread; on !has_pages && ARENA_COUNT > 0, a lock-free 1 s monotonic atomic tick (ARENA_SWEEP_EPOCH + NO_PAGES_ARENA_SWEEP_MS) gates try_sweep_arenas_if_due (ARENAS.try_lock()), advancing the tick only after try_lock() succeeds so contention with place() holding ARENAS across CreateHeap never stalls submits or burns the 1 s window.
  • Tests (hle::d3d12x::vram::tests, pure CPU, 0 skips):
    • retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers
    • retire_queue_rejects_device_removed_sentinel
    • arenas_sweep_dropped_for_if_due_reclaims_without_pages
    • retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark
    • try_sweep_arenas_if_due_is_non_blocking_and_throttled

Tested

  • Failing-first on unmodified main (e1d84b7d9153f86a97d2ec5d209d196046fc0bea) with the original RetireQueue tests:
    • retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers panicked: all-fail must hold heaps.
    • retire_queue_rejects_device_removed_sentinel panicked: u64::MAX sentinel must neither reap nor prune.
  • Follow-up commit 2fc8268271f4d025d408527a9b9cfd62730fab1c verified on Windows 11 (26200), NVIDIA GeForce RTX 4060 8 GB (Ada, Wave32, driver 32.0.16.2114), Intel Core i5-11400F, 32 GB RAM, rustc 1.100.0, DXC 1.9.2609.5:
    • cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition: exit 0, 0 new warnings in vram.rs (-A suppresses only pre-existing rustc 1.100.0 deny-by-default lints outside this diff).
    • cargo test --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture (3x Debug): 24 passed; 0 failed; 1 ignored (churn_update_tile_mappings_timing), 0 skipped.
    • cargo test --release --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture (3x Release): 24 passed; 0 failed; 1 ignored, 0 skipped (all 5 PR pure-CPU unit tests plus live RTX 4060 GPU tests gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark, d32s8_targets_take_their_own_size_of_video_memory, and reservable_agrees_with_the_driver passed).
    • cargo build --release -p xcl: exit 0, 0 new warnings in vram.rs.
  • Prior commit 73ff10e9ba8c4e7d45362bb8637536b52aba1686 also passed full release workspace testing (37 test binaries: 1426 passed; 0 failed; 46 ignored), WARP (XCL_ADAPTER=warp, 22/0/1), and independent community testing in this thread including @ClosetPie107 (AMD Radeon RX 9070 RDNA4 / Mesa RADV Wine/Proton, vram:: 22/0/1 and 300 s retail run PASS), @emirduran707 (AMD Radeon RX 9060 XT RDNA4 Windows, 60 s retail run PASS), @andrewDoing (RTX 5070 no-PAGES arena fixture PASS), @SlopTart (AMD RX 7900 XT Wine/Proton PASS), and @DavidM1911 (RTX 3060 Ti PASS).

Regression run

Before (main e1d84b7d9153f86a97d2ec5d209d196046fc0bea, exact parent of 73ff10e9):

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14016 MB

After (fix-vram-retire-fail-closed-arenas 2fc8268271f4d025d408527a9b9cfd62730fab1c):

xcl-smoke v1
commit: 2fc8268271f4d025d408527a9b9cfd62730fab1c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1576)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13992 MB

Both 60 s runs reach steady 60 60 60 presents per 2 s with 0 device removals, 0 crashes, 1576 vs 1508 frames shown (104.5%), and 13992 MB vs 14016 MB peak commit.

Not tested

  • Real D3D12 CreateFence OOM or DXGI_ERROR_DEVICE_REMOVED injection on hardware (both failure paths, single-pass signaling, and ARENAS.try_lock() contention are exercised deterministically in the pure-CPU unit tests).
  • D3D12 debug-layer tests (d3d12SDKLayers.dll is not installed on this machine) and native wave64 GPU tests on this machine (RTX 4060 is wave32-only; AMD RDNA4 was verified independently on 73ff10e9 by @ClosetPie107 and @emirduran707, and 2fc82682 has not yet been re-run on AMD hardware).

AI use

Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first reproductions, targeted 3x Debug/Release RTX 4060 test runs, clippy checks, clean release build, and quiet 60 s GPU smoke runs were executed and checked locally.

<!-- greyfinch-sync:ivall/xcl:issue:5499982230 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-25T22:06:04Z. --- Part of #1773 Part of #1585 Part of #1833 **What is in it** Fixes three VRAM heap retirement and idle arena reclamation bugs in `crates/xcl/src/hle/d3d12x/vram.rs` (without touching `Arenas::take_for`), updated in follow-up commit `2fc8268271f4d025d408527a9b9cfd62730fab1c` to address `@throny`'s pre-merge review: - **Fail closed on `CreateFence`/`Signal` failure with single-pass signaling (`RetireQueue`):** Previously, under VRAM/commit pressure, if `make_fence` or `signal` failed on all live queues (with `unmap_mark == None`), `retire_with` saw `marks.is_empty()` and returned `heaps` immediately to drop while live queues were still using them; if it failed on 1 of N live queues, that queue was omitted so `sweep_with` dropped the heaps as soon as the remaining queues finished. `RetiringBatch::marks` is now `Option<Vec<(F, u64)>>` (`None` = unarmed), `RetireQueue::capture_marks` returns `None` if ANY queue fails `make_fence` or `signal` (preserving monotonic `*v += 1` on any already-signaled queue), and `RetireQueue::retire_and_arm_with` (called from `retire_heaps_and_sweep`) queues `newly_reclaimed` unarmed first and calls `retry_unarmed_with` once so each live queue receives at most one `Signal` per call across previously-unarmed batches and `newly_reclaimed` (while returning `heaps` immediately only when `queues.is_empty() && unmap_mark.is_none()`, keeping `unmap_mark`-only batches waiting on `unmap_mark`, and leaving previously-unarmed batches fail-closed when `queues.is_empty()`). - **Reject D3D12 `u64::MAX` device-removed sentinel in `RetireQueue::sweep_with`:** Added pure helper `fence_reached(completed, target)` (`completed != u64::MAX && completed >= target`) and applied it to `unmap_mark`, `b.marks`, and dead-queue fence pruning so `ID3D12Fence::GetCompletedValue() == u64::MAX` on device removal never falsely reaps pending batches or prunes fences. - **Non-blocking, 1 s lock-free throttled idle-arena sweep from `before_execute`:** Added per-device `last_sweep: Vec<(usize, Instant)>`, `record_sweep`, and `sweep_dropped_for_if_due` (1 s interval, pruning `last_sweep` when no arenas remain for `dev`) to `Arenas<H>`, plus `ARENA_COUNT` synchronized on every `ARENAS` list mutation (`place`, `before_execute`). In `before_execute`, `has_pages` is tracked during the `PAGES` lock: on `do_reclaim` (1 s `PAGES` tick), `ARENAS.try_lock()` sweeps idle arenas without blocking the submit thread; on `!has_pages && ARENA_COUNT > 0`, a lock-free 1 s monotonic atomic tick (`ARENA_SWEEP_EPOCH` + `NO_PAGES_ARENA_SWEEP_MS`) gates `try_sweep_arenas_if_due` (`ARENAS.try_lock()`), advancing the tick only after `try_lock()` succeeds so contention with `place()` holding `ARENAS` across `CreateHeap` never stalls submits or burns the 1 s window. - **Tests (`hle::d3d12x::vram::tests`, pure CPU, `0` skips):** - `retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers` - `retire_queue_rejects_device_removed_sentinel` - `arenas_sweep_dropped_for_if_due_reclaims_without_pages` - `retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark` - `try_sweep_arenas_if_due_is_non_blocking_and_throttled` **Tested** - Failing-first on unmodified `main` (`e1d84b7d9153f86a97d2ec5d209d196046fc0bea`) with the original `RetireQueue` tests: - `retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers` panicked: `all-fail must hold heaps`. - `retire_queue_rejects_device_removed_sentinel` panicked: `u64::MAX sentinel must neither reap nor prune`. - Follow-up commit `2fc8268271f4d025d408527a9b9cfd62730fab1c` verified on Windows 11 (`26200`), NVIDIA GeForce RTX 4060 8 GB (Ada, Wave32, driver `32.0.16.2114`), Intel Core i5-11400F, 32 GB RAM, `rustc 1.100.0`, DXC `1.9.2609.5`: - `cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition`: `exit 0`, `0` new warnings in `vram.rs` (`-A` suppresses only pre-existing `rustc 1.100.0` deny-by-default lints outside this diff). - `cargo test --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture` (`3x` Debug): `24 passed; 0 failed; 1 ignored` (`churn_update_tile_mappings_timing`), `0` skipped. - `cargo test --release --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture` (`3x` Release): `24 passed; 0 failed; 1 ignored`, `0` skipped (all 5 PR pure-CPU unit tests plus live RTX 4060 GPU tests `gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`, `d32s8_targets_take_their_own_size_of_video_memory`, and `reservable_agrees_with_the_driver` passed). - `cargo build --release -p xcl`: `exit 0`, `0` new warnings in `vram.rs`. - Prior commit `73ff10e9ba8c4e7d45362bb8637536b52aba1686` also passed full release workspace testing (`37` test binaries: `1426 passed; 0 failed; 46 ignored`), WARP (`XCL_ADAPTER=warp`, `22/0/1`), and independent community testing in this thread including `@ClosetPie107` (AMD Radeon RX 9070 RDNA4 / Mesa RADV Wine/Proton, `vram::` `22/0/1` and 300 s retail run PASS), `@emirduran707` (AMD Radeon RX 9060 XT RDNA4 Windows, 60 s retail run PASS), `@andrewDoing` (RTX 5070 no-`PAGES` arena fixture PASS), `@SlopTart` (AMD RX 7900 XT Wine/Proton PASS), and `@DavidM1911` (RTX 3060 Ti PASS). **Regression run** Before (`main` `e1d84b7d9153f86a97d2ec5d209d196046fc0bea`, exact parent of `73ff10e9`): ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1508 (PresentX 1508) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14016 MB ``` After (`fix-vram-retire-fail-closed-arenas` `2fc8268271f4d025d408527a9b9cfd62730fab1c`): ``` xcl-smoke v1 commit: 2fc8268271f4d025d408527a9b9cfd62730fab1c gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1576 (PresentX 1576) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13992 MB ``` Both 60 s runs reach steady `60 60 60` presents per 2 s with `0` device removals, `0` crashes, `1576` vs `1508` frames shown (`104.5%`), and `13992 MB` vs `14016 MB` peak commit. **Not tested** - Real D3D12 `CreateFence` OOM or `DXGI_ERROR_DEVICE_REMOVED` injection on hardware (both failure paths, single-pass signaling, and `ARENAS.try_lock()` contention are exercised deterministically in the pure-CPU unit tests). - D3D12 debug-layer tests (`d3d12SDKLayers.dll` is not installed on this machine) and native wave64 GPU tests on this machine (RTX 4060 is wave32-only; AMD RDNA4 was verified independently on `73ff10e9` by `@ClosetPie107` and `@emirduran707`, and `2fc82682` has not yet been re-run on AMD hardware). **AI use** Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first reproductions, targeted `3x` Debug/Release RTX 4060 test runs, clippy checks, clean release build, and quiet 60 s GPU smoke runs were executed and checked locally.
DavidM1911 commented 2026-11-25 23:09:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T22:17:50Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7176185181 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7176185181). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T22:17:50Z. --- 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!
emirduran707 commented 2026-11-25 23:09:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T22:24:17Z.


Independent AMD RDNA4 (native wave64) test report on exact head 73ff10e9ba8c4e7d45362bb8637536b52aba1686 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1424 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: hle::d3d12x::vram::tests::retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers and retire_queue_rejects_device_removed_sentinel.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 73ff10e9ba8c4e7d45362bb8637536b52aba1686
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1606 (PresentX 1606)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13931 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7176319820 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7176319820). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-25T22:24:17Z. --- Independent AMD RDNA4 (native wave64) test report on exact head `73ff10e9ba8c4e7d45362bb8637536b52aba1686` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1424 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - Both PR tests passed: `hle::d3d12x::vram::tests::retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers` and `retire_queue_rejects_device_removed_sentinel`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 73ff10e9ba8c4e7d45362bb8637536b52aba1686 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1606 (PresentX 1606) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13931 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
SlopTart commented 2026-11-26 00:05:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T23:24:53Z.


Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers and retire_queue_rejects_device_removed_sentinel: 2 passed. The sentinel test is a failure-path unit test; it does not exercise a real device-lost event on this lane.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7177527053 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7177527053). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T23:24:53Z. --- **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers` and `retire_queue_rejects_device_removed_sentinel`: 2 passed. The sentinel test is a failure-path unit test; it does not exercise a real device-lost event on this lane. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
andrewDoing commented 2026-11-27 05:03:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T05:03:16Z.


I tested the no-PAGES idle-arena path on RTX 5070 / NVIDIA 616.92 using the same test-only fixture against parent e1d84b7d9153f86a97d2ec5d209d196046fc0bea and head 73ff10e9ba8c4e7d45362bb8637536b52aba1686, with isolated build targets.

The fixture places and releases a 64×64 RGBA8 render target in a 65,536-byte arena, verifies there is no active PAGES entry, waits 2.2 seconds, and drives before_execute. A native queue is held on a CPU-signaled fence while the test tracks the exact heap in the active arena and retirement queue.

  • Parent: the heap remained in the active arena both while blocked and after the fence completed; the candidate expectation failed.
  • PR head: the heap moved to retirement while the queue was blocked and was absent from both tracked owners after fence completion and another before_execute call. One focused test passed, with no skips.

This tests XCL heap ownership in a synthetic single-queue case. It does not measure driver residency, actual title VRAM savings, frame time, or behavior under physical memory pressure.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7210309932 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7210309932). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-27T05:03:16Z. --- I tested the no-`PAGES` idle-arena path on RTX 5070 / NVIDIA 616.92 using the same test-only fixture against parent `e1d84b7d9153f86a97d2ec5d209d196046fc0bea` and head `73ff10e9ba8c4e7d45362bb8637536b52aba1686`, with isolated build targets. The fixture places and releases a 64×64 RGBA8 render target in a 65,536-byte arena, verifies there is no active `PAGES` entry, waits 2.2 seconds, and drives `before_execute`. A native queue is held on a CPU-signaled fence while the test tracks the exact heap in the active arena and retirement queue. - Parent: the heap remained in the active arena both while blocked and after the fence completed; the candidate expectation failed. - PR head: the heap moved to retirement while the queue was blocked and was absent from both tracked owners after fence completion and another `before_execute` call. One focused test passed, with no skips. This tests XCL heap ownership in a synthetic single-queue case. It does not measure driver residency, actual title VRAM savings, frame time, or behavior under physical memory pressure. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.
ClosetPie107 commented 2026-11-27 12:51:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T12:51:54Z.


Update for head 2fc82682 (adds 2fc82682 on top of 73ff10e9, which the results below are for). Same machine and setup as below (RX 9070 16 GB / Mesa 26.3.1 RADV / Proton Experimental experimental-11.0-20261112, vkd3d-proton master ec207194 without the allocator / command-list lpVtbl checks, DXC 1.9.2609.5, Rust 1.96.0, x86_64-pc-windows-gnu debug build). The head itself (base e1d84b7d), with main f9a0cb80 the same session as the baseline.

Tests (XCL_REQUIRE_GPU=wave64)

  • cargo test -p xcl --lib -- hle::d3d12x::vram:: --test-threads=1: 24 passed, 0 failed, 1 ignored (main: 19 passed, 0 failed, 1 ignored).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 with --skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole (the first loses the RADV device here, the other two run out of memory under Wine): lib 1293 passed, 9 failed, 26 ignored; main f9a0cb80 lib the same session: 1323 passed, 9 failed, 27 ignored (--test-threads=1 and two --test-threads=4 runs). All failures are among main's. The other binaries fail the same 3 tests as on main here (e2e, pls_quota, predication_e2e). d3d12_resource_and_sync ended the process, as it does on main here.

Not tested on this head: a retail run (the run below is for 73ff10e9); native Windows, NVIDIA / Intel.

AI use: Claude Code (Claude Opus 5.5) ran the builds and tests on my machine and wrote this update.


Independent test report under Wine/Proton (not native Windows) for head 73ff10e9.

Setup

  • AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS Linux 7.3.5
  • Proton Experimental experimental-11.0-20261112, vkd3d-proton master ec207194 with a local patch dropping the lpVtbl checks in d3d12_command_allocator_from_iface / d3d12_command_list_from_iface, DXC 1.9.2609.5, Rust 1.96.0, x86_64-pc-windows-gnu
  • Head merged onto main 83b00818, test commit 1fcf2e6e

Tests (debug, XCL_REQUIRE_GPU=wave64, --test-threads=1)

  • hle::d3d12x::vram::: 22 passed, 0 failed, 1 ignored (main: 19 passed, 0 failed, 1 ignored)
  • cargo test -p xcl --lib -- --test-threads=4 --skip compositor_blends_ui_plane_over_scene_plane: 1323 passed, 8 failed, 27 ignored (main the same run: 1319 passed, 9 failed, 27 ignored). The failures are all among main's. Without the --skip, the lib binary lost the device in that test (RADV The CS has been rejected), the test-order problem main has (see my report on #2477).

Retail title, 300 s (release, from a copy of the same warm-cache snapshot; XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence, A pressed every 10 s)

  • 1 run: exit 0, no crash, no device removal, 1,982 presents, 10,441 MiB of video memory at 90 s, the card full (16.2 GiB) later on as on main. main, 4 runs: all clean, 1,892–2,122 presents, 10,148–10,265 MiB at 90 s.

Not tested

  • Native Windows, NVIDIA/Intel
  • The failure paths themselves (no fence or signal failure and no device removal happened in the run)

AI use

  • Claude Code (Claude Opus 5.5) wrote the test scripts, ran the tests and runs on this machine and wrote this report.
<!-- greyfinch-sync:ivall/xcl:comment:7218767295 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7218767295). Originally posted by [ClosetPie107](https://github.com/ClosetPie107) on 2026-11-27T12:51:54Z. --- **Update for head `2fc82682`** (adds `2fc82682` on top of `73ff10e9`, which the results below are for). Same machine and setup as below (RX 9070 16 GB / Mesa 26.3.1 RADV / Proton Experimental `experimental-11.0-20261112`, vkd3d-proton master `ec207194` without the allocator / command-list `lpVtbl` checks, DXC 1.9.2609.5, Rust 1.96.0, `x86_64-pc-windows-gnu` debug build). The head itself (base `e1d84b7d`), with `main` `f9a0cb80` the same session as the baseline. **Tests** (`XCL_REQUIRE_GPU=wave64`) - `cargo test -p xcl --lib -- hle::d3d12x::vram:: --test-threads=1`: **24 passed, 0 failed**, 1 ignored (`main`: 19 passed, 0 failed, 1 ignored). - `cargo test --workspace --no-fail-fast -- --test-threads=4` with `--skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole` (the first loses the RADV device here, the other two run out of memory under Wine): lib 1293 passed, 9 failed, 26 ignored; `main` `f9a0cb80` lib the same session: 1323 passed, 9 failed, 27 ignored (`--test-threads=1` and two `--test-threads=4` runs). All failures are among `main`'s. The other binaries fail the same 3 tests as on `main` here (`e2e`, `pls_quota`, `predication_e2e`). `d3d12_resource_and_sync` ended the process, as it does on `main` here. **Not tested** on this head: a retail run (the run below is for `73ff10e9`); native Windows, NVIDIA / Intel. AI use: Claude Code (Claude Opus 5.5) ran the builds and tests on my machine and wrote this update. --- Independent test report under Wine/Proton (not native Windows) for head `73ff10e9`. **Setup** - AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS Linux 7.3.5 - Proton Experimental `experimental-11.0-20261112`, vkd3d-proton master `ec207194` with a local patch dropping the `lpVtbl` checks in `d3d12_command_allocator_from_iface` / `d3d12_command_list_from_iface`, DXC `1.9.2609.5`, Rust 1.96.0, `x86_64-pc-windows-gnu` - Head merged onto `main` `83b00818`, test commit `1fcf2e6e` **Tests** (debug, `XCL_REQUIRE_GPU=wave64`, `--test-threads=1`) - `hle::d3d12x::vram::`: 22 passed, 0 failed, 1 ignored (`main`: 19 passed, 0 failed, 1 ignored) - `cargo test -p xcl --lib -- --test-threads=4 --skip compositor_blends_ui_plane_over_scene_plane`: 1323 passed, 8 failed, 27 ignored (`main` the same run: 1319 passed, 9 failed, 27 ignored). The failures are all among `main`'s. Without the `--skip`, the lib binary lost the device in that test (RADV `The CS has been rejected`), the test-order problem `main` has (see my report on #2477). **Retail title, 300 s** (release, from a copy of the same warm-cache snapshot; `XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence`, `A` pressed every 10 s) - 1 run: exit 0, no crash, no device removal, 1,982 presents, 10,441 MiB of video memory at 90 s, the card full (16.2 GiB) later on as on `main`. `main`, 4 runs: all clean, 1,892–2,122 presents, 10,148–10,265 MiB at 90 s. **Not tested** - Native Windows, NVIDIA/Intel - The failure paths themselves (no fence or signal failure and no device removal happened in the run) **AI use** - Claude Code (Claude Opus 5.5) wrote the test scripts, ran the tests and runs on this machine and wrote this report.
throny commented 2026-11-27 16:23:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T16:23:08Z.


Pre-merge check of this PR against today's main (6089122a; the merge is clean and vram.rs has not changed on main since your base). One finding I would want fixed or measured before it goes in, and three small ones:

  • The arena sweep takes the ARENAS lock on every before_execute, not once a second. The new else if ARENA_COUNT > 0 branch runs whenever do_reclaim is false, so also between the one-second page ticks, and it scans the arena list each time. place holds ARENAS across CreateHeap (arena_heap), so a loader thread placing an arena-backed target (depth-stencil, MSAA, packed 3D mips) can make the submit thread wait for a whole CreateHeap inside refresh_once. Arenas are the default fallback, so this is on for most titles. The doc comment says the sweep runs "when PAGES has no active entry", which is narrower than what the code does. A tick like the pages have (or a try_lock) would remove the cost; otherwise a frame-time measurement in a world run would settle it.
  • nit: unarmed batches are never re-armed once every queue of the device is gone (queues.is_empty() returns early), so their heaps stay.
  • nit: while unarmed batches exist, every call signals each queue twice, and again on every submit while signalling fails (failure path only).
  • nit: three changes in one PR (fail-closed fences, the u64::MAX sentinel, the idle sweep); small enough at ~190 lines, but they could land separately.

What I found sound: signalling again later can only delay a release, never make it early; the sentinel keeps a removed device from freeing heaps; no heap is dropped under a lock; no new lock order. The three new tests need no hardware and two of them fail on main without the change.

Evidence gap for a default-on change: the description has a 60 s smoke run on one NVIDIA card; nothing on AMD in the PR itself, and no test where CreateFence or Signal really fails.

This is a review from reading the code, nothing was built or run for it. AI use: Claude Code (a Claude Opus 5.5 sub-agent reviewed the merge result; Claude Fable 5.2 checked and wrote this).

<!-- greyfinch-sync:ivall/xcl:comment:7223197971 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7223197971). Originally posted by [throny](https://github.com/throny) on 2026-11-27T16:23:08Z. --- Pre-merge check of this PR against today's `main` (`6089122a`; the merge is clean and `vram.rs` has not changed on `main` since your base). One finding I would want fixed or measured before it goes in, and three small ones: - **The arena sweep takes the `ARENAS` lock on every `before_execute`, not once a second.** The new `else if ARENA_COUNT > 0` branch runs whenever `do_reclaim` is false, so also between the one-second page ticks, and it scans the arena list each time. `place` holds `ARENAS` across `CreateHeap` (`arena_heap`), so a loader thread placing an arena-backed target (depth-stencil, MSAA, packed 3D mips) can make the submit thread wait for a whole `CreateHeap` inside `refresh_once`. Arenas are the default fallback, so this is on for most titles. The doc comment says the sweep runs "when PAGES has no active entry", which is narrower than what the code does. A tick like the pages have (or a `try_lock`) would remove the cost; otherwise a frame-time measurement in a world run would settle it. - nit: unarmed batches are never re-armed once every queue of the device is gone (`queues.is_empty()` returns early), so their heaps stay. - nit: while unarmed batches exist, every call signals each queue twice, and again on every submit while signalling fails (failure path only). - nit: three changes in one PR (fail-closed fences, the `u64::MAX` sentinel, the idle sweep); small enough at ~190 lines, but they could land separately. What I found sound: signalling again later can only delay a release, never make it early; the sentinel keeps a removed device from freeing heaps; no heap is dropped under a lock; no new lock order. The three new tests need no hardware and two of them fail on `main` without the change. Evidence gap for a default-on change: the description has a 60 s smoke run on one NVIDIA card; nothing on AMD in the PR itself, and no test where `CreateFence` or `Signal` really fails. This is a review from reading the code, nothing was built or run for it. AI use: Claude Code (a Claude Opus 5.5 sub-agent reviewed the merge result; Claude Fable 5.2 checked and wrote this).
throny commented 2026-11-27 16:25:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T16:25:28Z.


Merge status (I have been asked to prepare merges of PRs with several independent tests; the bar is: no open critical finding or performance regression, a fresh check of the merge result against today's main, and green required checks. Each merge is still confirmed by a person.)

Not proposing this one yet because of the finding in my review above (the arena sweep locks on every submit). With that addressed, or with a frame-time measurement showing no cost, it is a quick re-check: the rest of the change read as sound and it merges cleanly.

AI use: Claude Code (Claude Fable 5.2).

<!-- greyfinch-sync:ivall/xcl:comment:7223244294 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7223244294). Originally posted by [throny](https://github.com/throny) on 2026-11-27T16:25:28Z. --- **Merge status** (I have been asked to prepare merges of PRs with several independent tests; the bar is: no open critical finding or performance regression, a fresh check of the merge result against today's `main`, and green required checks. Each merge is still confirmed by a person.) Not proposing this one yet because of the finding in my review above (the arena sweep locks on every submit). With that addressed, or with a frame-time measurement showing no cost, it is a quick re-check: the rest of the change read as sound and it merges cleanly. AI use: Claude Code (Claude Fable 5.2).
Decodere commented 2026-11-27 16:50:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T16:50:10Z.


Thanks for the thorough review, @throny! I pushed follow-up commit 2fc8268271f4d025d408527a9b9cfd62730fab1c (D3D12.X: throttle no-PAGES arena sweep with try_lock and single-pass retire signals) addressing the submit-thread ARENAS lock blocker and the signaling/comment nits:

  1. No submit-thread ARENAS lock per before_execute (blocker):
    • before_execute now records has_pages while holding PAGES. Between 1 s PAGES ticks on devices with PAGES, ARENAS is never touched at all.
    • On the 1 s do_reclaim tick, before_execute uses non-blocking ARENAS.try_lock() so a loader thread holding ARENAS across CreateHeap in place() can never stall the submit thread.
    • On !has_pages && ARENA_COUNT > 0, a lock-free 1 s monotonic atomic tick (ARENA_SWEEP_EPOCH + NO_PAGES_ARENA_SWEEP_MS) gates try_sweep_arenas_if_due before calling ARENAS.try_lock(), and advances the tick only after try_lock() succeeds so contention does not burn the 1 s window. Updated doc comments on ARENAS, sweep_dropped_for_if_due, and before_execute to match.
  2. Single-pass retirement signaling & fail-closed comment (nits):
    • retire_heaps_and_sweep now calls RetireQueue::retire_and_arm_with, which queues newly_reclaimed unarmed first and calls retry_unarmed_with once so each live queue receives at most one Signal per call across previously-unarmed batches and newly reclaimed heaps, while preserving unmap_mark-only retirement and keeping previously-unarmed batches fail-closed when queues.is_empty() (documented inline).
  3. Verification on 2fc8268271f4d025d408527a9b9cfd62730fab1c (RTX 4060, Windows 11, rustc 1.100.0):
    • Added 2 pure-CPU unit tests: retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark (verifies 2 total signals across 2 queues, unmap_mark ordering, and queues.is_empty() fail-closed behavior) and try_sweep_arenas_if_due_is_non_blocking_and_throttled (verifies non-blocking return while ARENAS is held on the same thread, unburned 1 s window under contention, and lock-free short-circuiting within the 1 s interval).
    • cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition: exit 0, 0 new warnings in vram.rs.
    • 3x Debug + 3x Release cargo test -p xcl --lib hle::d3d12x::vram:: -- --test-threads=1 --nocapture: 24 passed; 0 failed; 1 ignored; 0 skipped.
    • Clean cargo build --release -p xcl + quiet 60 s RTX 4060 smoke (title: 29640639): 1576 frames (PresentX 1576), 60 60 60, 0 device removals, 0 crashes, 13992 MB peak commit (vs e1d84b7d 1508 frames / 14016 MB).
    • Also updated the PR description with the new commit, smoke block, and references to the independent AMD RDNA4 reports in this thread (@ClosetPie107 RX 9070 300 s and @emirduran707 RX 9060 XT 60 s on 73ff10e9, noting 2fc82682 itself has not yet been re-run on AMD hardware).

Ready for re-check whenever you have a moment!

(AI use: Google Antigravity (Gemini 4 Neon) implemented the follow-up fix, ran the clippy/test/smoke verifications, and drafted this reply.)

<!-- greyfinch-sync:ivall/xcl:comment:7223725394 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7223725394). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T16:50:10Z. --- Thanks for the thorough review, `@throny`! I pushed follow-up commit `2fc8268271f4d025d408527a9b9cfd62730fab1c` (`D3D12.X: throttle no-PAGES arena sweep with try_lock and single-pass retire signals`) addressing the submit-thread `ARENAS` lock blocker and the signaling/comment nits: 1. **No submit-thread `ARENAS` lock per `before_execute` (blocker):** - `before_execute` now records `has_pages` while holding `PAGES`. Between 1 s `PAGES` ticks on devices with `PAGES`, `ARENAS` is never touched at all. - On the 1 s `do_reclaim` tick, `before_execute` uses non-blocking `ARENAS.try_lock()` so a loader thread holding `ARENAS` across `CreateHeap` in `place()` can never stall the submit thread. - On `!has_pages && ARENA_COUNT > 0`, a lock-free 1 s monotonic atomic tick (`ARENA_SWEEP_EPOCH` + `NO_PAGES_ARENA_SWEEP_MS`) gates `try_sweep_arenas_if_due` before calling `ARENAS.try_lock()`, and advances the tick only after `try_lock()` succeeds so contention does not burn the 1 s window. Updated doc comments on `ARENAS`, `sweep_dropped_for_if_due`, and `before_execute` to match. 2. **Single-pass retirement signaling & fail-closed comment (nits):** - `retire_heaps_and_sweep` now calls `RetireQueue::retire_and_arm_with`, which queues `newly_reclaimed` unarmed first and calls `retry_unarmed_with` once so each live queue receives at most one `Signal` per call across previously-unarmed batches and newly reclaimed heaps, while preserving `unmap_mark`-only retirement and keeping previously-unarmed batches fail-closed when `queues.is_empty()` (documented inline). 3. **Verification on `2fc8268271f4d025d408527a9b9cfd62730fab1c` (RTX 4060, Windows 11, `rustc 1.100.0`):** - Added 2 pure-CPU unit tests: `retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark` (verifies `2` total signals across `2` queues, `unmap_mark` ordering, and `queues.is_empty()` fail-closed behavior) and `try_sweep_arenas_if_due_is_non_blocking_and_throttled` (verifies non-blocking return while `ARENAS` is held on the same thread, unburned 1 s window under contention, and lock-free short-circuiting within the 1 s interval). - `cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition`: `exit 0`, `0` new warnings in `vram.rs`. - `3x` Debug + `3x` Release `cargo test -p xcl --lib hle::d3d12x::vram:: -- --test-threads=1 --nocapture`: `24 passed; 0 failed; 1 ignored; 0 skipped`. - Clean `cargo build --release -p xcl` + quiet 60 s RTX 4060 smoke (`title: 29640639`): `1576` frames (`PresentX 1576`), `60 60 60`, `0` device removals, `0` crashes, `13992 MB` peak commit (vs `e1d84b7d` `1508` frames / `14016 MB`). - Also updated the PR description with the new commit, smoke block, and references to the independent AMD RDNA4 reports in this thread (`@ClosetPie107` RX 9070 300 s and `@emirduran707` RX 9060 XT 60 s on `73ff10e9`, noting `2fc82682` itself has not yet been re-run on AMD hardware). Ready for re-check whenever you have a moment! *(AI use: Google Antigravity (Gemini 4 Neon) implemented the follow-up fix, ran the clippy/test/smoke verifications, and drafted this reply.)*
throny commented 2026-11-27 17:03:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T17:03:59Z.


merge-check
base: 6089122a (main)
head: 2fc8268271
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1469 passed, 1 failed, 47 ignored (26 SKIPPED lines); failing: gpu::recomp::dxc::cache_tests::concurrent_cache_misses_compile_once, once. It is in a file this PR does not touch, passes on the base (1465 passed, 0 failed, 47 ignored, same tree minus the PR) and passed 5 of 5 reruns on the merge result, so I count it as a flaky test, not as this PR's.
review: the blocker of my first review is gone on every path: with PAGES the arena list is not touched between ticks and only with try_lock on the tick; without PAGES an atomic count, the atomic tick, then try_lock, and a failed try_lock does not use up the tick. Heaps are still dropped outside all locks, no new lock order, fence values only go up, u64::MAX is never "reached". Two points that do not block, for a follow-up: (1) NO_PAGES_ARENA_SWEEP_MS is one tick for all devices and advances even when the calling device has no arenas, so with two devices without PAGES a busy one can keep an idle one's arenas from being swept until its next place(); (2) a batch that can never complete (unarmed with no queue left, or after device removal) keeps RETIRING_BATCHES above 0, so every later submit collects the queues and takes the retire lock. Nits: the two gates round differently (whole ms vs Instant), and the fail-closed test goes through the test-only retire_with, not retire_and_arm_with.
performance: by default one atomic load per submit while arenas exist; not measured in a title by me. The author's 60 s pair shows 1576 vs 1508 frames.
verdict: safe to merge (one more merge check by another account needed, see #3041)
hardware / tool and model: RTX 4080 (621.40), i9-12900K, Windows 11, Rust 1.100.0, debug. Claude Code: a Claude Opus 5.5 sub-agent reviewed the merge result, Claude Fable 5.2 ran the suite and wrote this.

@Decodere thanks for the quick fix; your reply reached me late because the mention was in a code span.

<!-- greyfinch-sync:ivall/xcl:comment:7223986415 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7223986415). Originally posted by [throny](https://github.com/throny) on 2026-11-27T17:03:59Z. --- merge-check base: 6089122a (`main`) head: 2fc8268271f4d025d408527a9b9cfd62730fab1c merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1469 passed, 1 failed, 47 ignored (26 SKIPPED lines); failing: `gpu::recomp::dxc::cache_tests::concurrent_cache_misses_compile_once`, once. It is in a file this PR does not touch, passes on the base (1465 passed, 0 failed, 47 ignored, same tree minus the PR) and passed 5 of 5 reruns on the merge result, so I count it as a flaky test, not as this PR's. review: the blocker of my first review is gone on every path: with PAGES the arena list is not touched between ticks and only with `try_lock` on the tick; without PAGES an atomic count, the atomic tick, then `try_lock`, and a failed `try_lock` does not use up the tick. Heaps are still dropped outside all locks, no new lock order, fence values only go up, `u64::MAX` is never "reached". Two points that do not block, for a follow-up: (1) `NO_PAGES_ARENA_SWEEP_MS` is one tick for all devices and advances even when the calling device has no arenas, so with two devices without PAGES a busy one can keep an idle one's arenas from being swept until its next `place()`; (2) a batch that can never complete (unarmed with no queue left, or after device removal) keeps `RETIRING_BATCHES` above 0, so every later submit collects the queues and takes the retire lock. Nits: the two gates round differently (whole ms vs `Instant`), and the fail-closed test goes through the test-only `retire_with`, not `retire_and_arm_with`. performance: by default one atomic load per submit while arenas exist; not measured in a title by me. The author's 60 s pair shows 1576 vs 1508 frames. verdict: safe to merge (one more merge check by another account needed, see #3041) hardware / tool and model: RTX 4080 (621.40), i9-12900K, Windows 11, Rust 1.100.0, debug. Claude Code: a Claude Opus 5.5 sub-agent reviewed the merge result, Claude Fable 5.2 ran the suite and wrote this. `@Decodere` thanks for the quick fix; your reply reached me late because the mention was in a code span.
pickles976 commented 2026-11-27 17:09:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-27T17:09:29Z.


Additional exact-production-head Wine check at 2fc8268271f4d025d408527a9b9cfd62730fab1c (parent 73ff10e9ba8c4e7d45362bb8637536b52aba1686), with three local CPU-only fixtures added to vram.rs. Production unchanged. AI-assisted report using omp/OpenAI GPT-6 Astra; observed execution, not inferred test output.

Tested

Linux6.17, i7-13620H,16GiB RAM, Wine11, Rust1.98.1 Windows-MSVC target. No GPU initialized or GPU work submitted in these selected tests. Fresh intended-worktree compilation25.22s. Nine focused tests: 8passed/1failed/0ignored,0.00s test time.

Passing coverage: all-queue retirement marks, partial CreateFence/Signal failures, fresh retry marks, a pending third queue holding the actual Rust heap owner, device-removal sentinel fail-closed, idle arena extraction followed by deferred owner destruction, unmap-fence preservation, one shared marking pass, and the new try-lock/non-consuming-contention/throttle fixture. These are CPU generic-queue/arena fixtures, not native GPU destruction or VRAM savings.

The new failure is cross-device starvation in the no-PAGES atomic throttle. NO_PAGES_ARENA_SWEEP_MS is shared globally but the actual sweep is only for dev_key. Two no-PAGES devices have eligible idle arenas. Device1 submits just before device2 at each1s tick. Device1 frees its own arena on the first tick, then keeps refreshing the global tick even with no arenas of its own. ARENA_COUNT stays nonzero because device2 still owns an arena. Device2 arrives1ms later and is always rejected before the per-device sweep.

A deterministic four-interval fixture returns [101] for device1 but [] for device2, expected[202]; failure at vram.rs:2103. No sleeping or concurrency assumptions are needed. The same source schedule can repeat; this is not merely a guaranteed one-interval delay. Suggested owner direction: make admission per-device, or provide fair eligible-device progress without reinstating the blocking ARENAS lock on every submit. Do not release pending heaps to fix it.

Repro fixture, inside the existing tests module:

#[test]
fn cpu_only_retirement_sweep_does_not_starve_another_device() {
    use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
    let t0 = Instant::now();
    let interval = Duration::from_secs(1);
    let arenas: Mutex<Arenas<u32>> = Mutex::new(Arenas::new());
    let count = AtomicUsize::new(0);
    let tick = AtomicU64::new(0);
    {
        let mut g = arenas.lock().unwrap();
        for (dev, heap) in [(1, 101), (2, 202)] {
            let id = g.take_for(dev, 0x10_0000, PAGE, PAGE, t0, |_, _| Some(heap)).0.unwrap().2;
            g.release(id, t0);
        }
        count.store(g.list.len(), Ordering::Release);
    }
    let mut first = Vec::new();
    let mut second = Vec::new();
    for step in 0..4 {
        let elapsed = IDLE + interval * step + Duration::from_millis(10);
        let ms = elapsed.as_millis() as u64;
        first.extend(try_sweep_arenas_if_due(&arenas, &count, &tick, 1, t0 + elapsed, ms, interval));
        second.extend(try_sweep_arenas_if_due(&arenas, &count, &tick, 2,
            t0 + elapsed + Duration::from_millis(1), ms + 1, interval));
    }
    assert_eq!(first, vec![101]);
    assert_eq!(second, vec![202]);
    assert_eq!(arenas.lock().unwrap().bytes(), 0);
}

Focused command (via the local Wine Cargo wrapper): cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib -- cpu_only_retirement_ retire_queue_waits_for_all_queues_and_prunes_dead_queue_fences retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers retire_queue_rejects_device_removed_sentinel arenas_sweep_dropped_for_if_due_reclaims_without_pages retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark try_sweep_arenas_if_due_is_non_blocking_and_throttled --nocapture --test-threads=1.

Not tested

No full suite, matched-parent run, actual multi-device title, GPU destruction, measured VRAM/RAM reduction or frame-time comparison. This does not explain the separate Game-Init producer fence0/wanted1 stall. Deliberately blocked-GPU tests were not run on this host. Existing9GiB/512MiB/global safety guards unchanged.

Local evidence: .compat-runtime/logs/verify-xcl2538-retirement-fairness-20261127T170310Z/; exact-head worktree xcl-pr2538-updated retains test-only changes. Earlier pinned xcl-pr2538 at73ff was not tested or silently relabeled as this result.

<!-- greyfinch-sync:ivall/xcl:comment:7224091977 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7224091977). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-27T17:09:29Z. --- Additional exact-production-head Wine check at `2fc8268271f4d025d408527a9b9cfd62730fab1c` (parent `73ff10e9ba8c4e7d45362bb8637536b52aba1686`), with three local CPU-only fixtures added to `vram.rs`. Production unchanged. AI-assisted report using omp/OpenAI GPT-6 Astra; observed execution, not inferred test output. ## Tested Linux6.17, i7-13620H,16GiB RAM, Wine11, Rust1.98.1 Windows-MSVC target. No GPU initialized or GPU work submitted in these selected tests. Fresh intended-worktree compilation25.22s. Nine focused tests: **8passed/1failed/0ignored**,0.00s test time. Passing coverage: all-queue retirement marks, partial CreateFence/Signal failures, fresh retry marks, a pending third queue holding the actual Rust heap owner, device-removal sentinel fail-closed, idle arena extraction followed by deferred owner destruction, unmap-fence preservation, one shared marking pass, and the new try-lock/non-consuming-contention/throttle fixture. These are CPU generic-queue/arena fixtures, not native GPU destruction or VRAM savings. The new failure is **cross-device starvation in the no-PAGES atomic throttle**. `NO_PAGES_ARENA_SWEEP_MS` is shared globally but the actual sweep is only for `dev_key`. Two no-PAGES devices have eligible idle arenas. Device1 submits just before device2 at each1s tick. Device1 frees its own arena on the first tick, then keeps refreshing the global tick even with no arenas of its own. `ARENA_COUNT` stays nonzero because device2 still owns an arena. Device2 arrives1ms later and is always rejected before the per-device sweep. A deterministic four-interval fixture returns `[101]` for device1 but `[]` for device2, expected`[202]`; failure at `vram.rs:2103`. No sleeping or concurrency assumptions are needed. The same source schedule can repeat; this is not merely a guaranteed one-interval delay. Suggested owner direction: make admission per-device, or provide fair eligible-device progress without reinstating the blocking ARENAS lock on every submit. Do not release pending heaps to fix it. Repro fixture, inside the existing tests module: ```rust #[test] fn cpu_only_retirement_sweep_does_not_starve_another_device() { use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; let t0 = Instant::now(); let interval = Duration::from_secs(1); let arenas: Mutex<Arenas<u32>> = Mutex::new(Arenas::new()); let count = AtomicUsize::new(0); let tick = AtomicU64::new(0); { let mut g = arenas.lock().unwrap(); for (dev, heap) in [(1, 101), (2, 202)] { let id = g.take_for(dev, 0x10_0000, PAGE, PAGE, t0, |_, _| Some(heap)).0.unwrap().2; g.release(id, t0); } count.store(g.list.len(), Ordering::Release); } let mut first = Vec::new(); let mut second = Vec::new(); for step in 0..4 { let elapsed = IDLE + interval * step + Duration::from_millis(10); let ms = elapsed.as_millis() as u64; first.extend(try_sweep_arenas_if_due(&arenas, &count, &tick, 1, t0 + elapsed, ms, interval)); second.extend(try_sweep_arenas_if_due(&arenas, &count, &tick, 2, t0 + elapsed + Duration::from_millis(1), ms + 1, interval)); } assert_eq!(first, vec![101]); assert_eq!(second, vec![202]); assert_eq!(arenas.lock().unwrap().bytes(), 0); } ``` Focused command (via the local Wine Cargo wrapper): `cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib -- cpu_only_retirement_ retire_queue_waits_for_all_queues_and_prunes_dead_queue_fences retire_queue_fails_closed_on_fence_or_signal_failure_and_recovers retire_queue_rejects_device_removed_sentinel arenas_sweep_dropped_for_if_due_reclaims_without_pages retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark try_sweep_arenas_if_due_is_non_blocking_and_throttled --nocapture --test-threads=1`. ## Not tested No full suite, matched-parent run, actual multi-device title, GPU destruction, measured VRAM/RAM reduction or frame-time comparison. This does not explain the separate Game-Init producer fence0/wanted1 stall. Deliberately blocked-GPU tests were not run on this host. Existing9GiB/512MiB/global safety guards unchanged. Local evidence: `.compat-runtime/logs/verify-xcl2538-retirement-fairness-20261127T170310Z/`; exact-head worktree `xcl-pr2538-updated` retains test-only changes. Earlier pinned `xcl-pr2538` at73ff was not tested or silently relabeled as this result.
razormontana commented 2026-11-28 00:49:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by razormontana on 2026-11-28T00:49:53Z.


Native validation of a local NVIDIA adaptation derived from #2538 at 2fc8268271f4d025d408527a9b9cfd62730fab1c. The tested code was staged tree 15d3826061d3ee456b5825b12a0eeef6e63f3348 on NVIDIA d1be8103644791b7a65f068954324e93d4b1b565. It retains queue obligations across failed mark capture and checks for the device-removal sentinel. Windows 11 Pro build 22631, Core i7-10700K, RTX 3070 8 GB with NVIDIA 617.42, Rust 1.100.0 x64 MSVC.

Tested

  • cargo check --locked --offline -p xcl --lib passed. Eight focused CPU retirement and arena checks passed. Three retirement regression assertions failed on the NVIDIA base with only their fixtures added.
  • A separate test-only copy of the staged tree ran cargo test --offline --locked -j 1 -p xcl --lib hle::d3d12x::vram::tests::gpu_retire_queue_reclaims_heap_after_normal_copy -- --exact --test-threads=1 --nocapture. 1 passed, 0 failed, 0 ignored, 0 skipped. One ordinary direct-queue copy completed, read back correctly, and the sweep released the retirement-owned heap reference after the native fence mark. A separate reference kept the test heap live during the copy.

Not tested

The exact published #2538 tree, its separate idle-arena scheduling change, or retail behavior.

AI use

Codex GPT-6.2 ran the focused validation, checked the results, and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7231222897 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7231222897). Originally posted by [razormontana](https://github.com/razormontana) on 2026-11-28T00:49:53Z. --- Native validation of a local NVIDIA adaptation derived from #2538 at `2fc8268271f4d025d408527a9b9cfd62730fab1c`. The tested code was staged tree `15d3826061d3ee456b5825b12a0eeef6e63f3348` on NVIDIA `d1be8103644791b7a65f068954324e93d4b1b565`. It retains queue obligations across failed mark capture and checks for the device-removal sentinel. Windows 11 Pro build 22631, Core i7-10700K, RTX 3070 8 GB with NVIDIA 617.42, Rust 1.100.0 x64 MSVC. **Tested** - `cargo check --locked --offline -p xcl --lib` passed. Eight focused CPU retirement and arena checks passed. Three retirement regression assertions failed on the NVIDIA base with only their fixtures added. - A separate test-only copy of the staged tree ran `cargo test --offline --locked -j 1 -p xcl --lib hle::d3d12x::vram::tests::gpu_retire_queue_reclaims_heap_after_normal_copy -- --exact --test-threads=1 --nocapture`. **1 passed, 0 failed, 0 ignored, 0 skipped.** One ordinary direct-queue copy completed, read back correctly, and the sweep released the retirement-owned heap reference after the native fence mark. A separate reference kept the test heap live during the copy. **Not tested** The exact published #2538 tree, its separate idle-arena scheduling change, or retail behavior. **AI use** Codex GPT-6.2 ran the focused validation, checked the results, and prepared this report.
Prime1997 commented 2026-11-28 08:43:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-28T08:43:12Z.


I reused the fail-closed retirement proposal here for the NVIDIA candidate, retaining attribution rather than opening another PR. The scoped adaptation is 4ca3690b78edb9e24e663b8232d555840326bb56: failed fence creation/signaling retains the batch, device-removal completion is rejected, and fence values cannot wrap into the removal sentinel. Your separate arena scheduling changes are not included. Failed batches remain held through process exit, trading retention on the failure path for avoiding premature heap release.

The combined candidate a4e83a1eb411e4d3e6cf6e8f202f1f2c42a1d16a compiled successfully with cargo build --locked --release -p xcl --target-dir <isolated target> on Windows x64 (230 seconds). This is combined-tree compilation, not an individual-PR build or GPU validation. Source review completed; regression fixtures are present but were not run after the user explicitly waived further shader/memory checks and requested an interactive launch. Hardware behavior, paired title regression and actual sustained memory savings remain unvalidated. No merge-readiness claim.

Codex (GPT-6) prepared this scoped adaptation and report. Optional temporary contributor/testing coordination: https://discord.gg/gK3y7WRRY

<!-- greyfinch-sync:ivall/xcl:comment:7236765511 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7236765511). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-28T08:43:12Z. --- I reused the fail-closed retirement proposal here for the NVIDIA candidate, retaining attribution rather than opening another PR. The scoped adaptation is [4ca3690b78edb9e24e663b8232d555840326bb56](https://github.com/Prime1997/xcl/commit/4ca3690b78edb9e24e663b8232d555840326bb56): failed fence creation/signaling retains the batch, device-removal completion is rejected, and fence values cannot wrap into the removal sentinel. Your separate arena scheduling changes are not included. Failed batches remain held through process exit, trading retention on the failure path for avoiding premature heap release. The combined candidate `a4e83a1eb411e4d3e6cf6e8f202f1f2c42a1d16a` compiled successfully with `cargo build --locked --release -p xcl --target-dir <isolated target>` on Windows x64 (230 seconds). This is combined-tree compilation, not an individual-PR build or GPU validation. Source review completed; regression fixtures are present but were not run after the user explicitly waived further shader/memory checks and requested an interactive launch. Hardware behavior, paired title regression and actual sustained memory savings remain unvalidated. No merge-readiness claim. Codex (GPT-6) prepared this scoped adaptation and report. Optional temporary contributor/testing coordination: https://discord.gg/gK3y7WRRY
Foniass commented 2026-12-01 08:19:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:19:07Z.


Triage (#1607) – head 2fc8268

No open or merged PR makes the same change: main's vram.rs RetireQueue::retire_with still skips a queue whose CreateFence/Signal fails and drops the heaps when no mark was taken, and sweep_with still treats u64::MAX as completed. #3125 makes the same fail-closed change for sparse.rs/late_release.rs, not vram.rs; #2981 touches this area inside a 49k-line diff.
No problems found in the diff: unarmed batches are re-armed with later marks (conservative) and the try_lock sweep only defers work.
The branch conflicts with main and needs a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305159586 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2538#issuecomment-7305159586). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:19:07Z. --- **Triage (#1607)** – head 2fc8268 No open or merged PR makes the same change: main's `vram.rs` `RetireQueue::retire_with` still skips a queue whose `CreateFence`/`Signal` fails and drops the heaps when no mark was taken, and `sweep_with` still treats `u64::MAX` as completed. #3125 makes the same fail-closed change for `sparse.rs`/`late_release.rs`, not `vram.rs`; #2981 touches this area inside a 49k-line diff. No problems found in the diff: unarmed batches are re-armed with later marks (conservative) and the `try_lock` sweep only defers work. The branch conflicts with main and needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2538:upstream-pr/2538'
git switch 'upstream-pr/2538'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2538'
git switch 'upstream-pr/2538'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2538'
git switch 'upstream-pr/2538'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2538'
git switch 'main'
git merge --squash 'upstream-pr/2538'
git switch 'main'
git merge --ff-only 'upstream-pr/2538'
git switch 'main'
git merge 'upstream-pr/2538'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2528
No description provided.