Repository navigation
Conversation
…without PAGES Fix three VRAM heap retirement and idle arena reclamation bugs in vram.rs: 1. Fail closed in RetireQueue::retire_with when CreateFence or Signal fails on any live queue: change RetiringBatch::marks to Option<Vec<(F, u64)>>, factor RetireQueue::capture_marks (returning None on any queue failure while keeping fence values monotonic for already-signaled queues), and return heaps immediately only when queues.is_empty() && unmap_mark.is_none(). Add RetireQueue::retry_unarmed_with (invoked in retire_heaps_and_sweep before retire_with/sweep_with) so transiently-unarmed batches capture one shared set of fresh marks and recover without head-of-line blocking armed ready batches. 2. Reject the D3D12 u64::MAX device-removed fence sentinel via fence_reached in RetireQueue::sweep_with so GetCompletedValue() == u64::MAX neither reaps pending batches nor prunes dead-queue fences. 3. Sweep idle arenas from before_execute even when PAGES has no active entry for the device (e.g. XCL_VRAM_ARENAS=1 or devices with only non-tiled D32S8/MSAA arenas): track per-device last_sweep in Arenas<H> with sweep_dropped_for_if_due (1 s interval, pruning last_sweep when empty) and synchronize ARENA_COUNT to arenas.list.len() on every ARENAS list mutation so the zero-arena fast path avoids locking. Add three pure-CPU unit tests in vram::tests covering fail-closed retirement and recovery, u64::MAX sentinel rejection, and throttled idle arena sweeping. Part of xcl-dev#1773 Part of xcl-dev#1585 Part of xcl-dev#1833 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
|
Tested: current PR head merged onto current
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. |
…upstream xcl-dev#2538) (cherry picked from commit b2502155fba95a85f6879303f998af07f2714e09)
|
I tested the no- The fixture places and releases a 64×64 RGBA8 render target in a 65,536-byte arena, verifies there is no active
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. |
|
Independent test report under Wine/Proton (not native Windows) for head Setup
Tests (debug,
Retail title, 300 s (release, from a copy of the same warm-cache snapshot;
Not tested
AI use
|
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 touchingArenas::take_for):CreateFence/Signalfailure inRetireQueue::retire_with: Previously, under VRAM/commit pressure, ifmake_fenceorsignalfailed on all live queues (withunmap_mark == None),retire_withsawmarks.is_empty()and returnedheapsimmediately to drop while live queues were still using them; if it failed on 1 of N live queues, that queue was omitted sosweep_withdropped the heaps as soon as the remaining queues finished.RetiringBatch::marksis nowOption<Vec<(F, u64)>>(None= unarmed),RetireQueue::capture_marksreturnsNoneif ANY queue failsmake_fenceorsignal(preserving monotonic*v += 1on any already-signaled queue), andretire_withreturnsheapsimmediately ONLY whenqueues.is_empty() && unmap_mark.is_none(). AddedRetireQueue::retry_unarmed_with(invoked inretire_heaps_and_sweepbeforeretire_with/sweep_with) so transiently-unarmed batches capture one shared set of fresh marks across all live queues and recover without head-of-line blocking armed ready batches.u64::MAXdevice-removed sentinel inRetireQueue::sweep_with: Added pure helperfence_reached(completed, target)(completed != u64::MAX && completed >= target) and applied it tounmap_mark,b.marks, and dead-queue fence pruning soID3D12Fence::GetCompletedValue() == u64::MAXon device removal never falsely reaps pending batches or prunes fences.before_executewhenPAGEShas no activeSome(Pages)entry for the device: Added per-devicelast_sweep: Vec<(usize, Instant)>,record_sweep, andsweep_dropped_for_if_due(1 s interval, pruninglast_sweepwhen no arenas remain fordev) toArenas<H>, plusstatic ARENA_COUNT: AtomicUsizesynchronized toarenas.list.len()on everyARENASlist mutation (place,before_execute). Whendo_reclaimis false andARENA_COUNT > 0(e.g.XCL_VRAM_ARENAS=1or devices with only non-tiled D32S8/MSAA arenas),before_executerunssweep_dropped_for_if_dueand retires reclaimed heaps throughretire_heaps_and_sweep, keeping a zero-lock fast path whenARENA_COUNT == 0.hle::d3d12x::vram::tests, pure CPU,0skips):retire_queue_fails_closed_on_fence_or_signal_failure_and_recoversretire_queue_rejects_device_removed_sentinelarenas_sweep_dropped_for_if_due_reclaims_without_pagesTested
origin/main(e1d84b7d9153f86a97d2ec5d209d196046fc0bea) with theRetireQueuetests:retire_queue_fails_closed_on_fence_or_signal_failure_and_recoverspanicked atvram.rs:1703:all-fail must hold heaps.retire_queue_rejects_device_removed_sentinelpanicked atvram.rs:1719:u64::MAX sentinel must neither reap nor prune.0compiler warnings invram.rs):cargo test --release -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1 --nocapture:22 passed; 0 failed; 1 ignored(churn_update_tile_mappings_timing),0skipped (all 3 new pure-CPU tests plusgpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,d32s8_targets_take_their_own_size_of_video_memory, andreservable_agrees_with_the_driverpassed).XCL_ADAPTER=warp):cargo test --release -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1 --nocapture:22 passed; 0 failed; 1 ignored,0skipped.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries:1426 passed; 0 failed; 46 ignored.29pre-existing runtimeSKIPPEDmessages (21no wave64on wave32-only RTX 4060,3per-lane form: refused,3no D3D12 debug layer/no d3d12SDKLayers.dll,1cannot disable the driver cache,1no heap windows).Regression run
Before (
origin/maine1d84b7d9153f86a97d2ec5d209d196046fc0bea):After (
fix-vram-retire-fail-closed-arenas73ff10e9ba8c4e7d45362bb8637536b52aba1686):Both 60 s runs reach steady
60 60 60presents per 2 s with0device removals,0crashes,1542vs1508frames shown (102.3%), and14007 MBvs14016 MBpeak commit.Not tested
CreateFenceOOM orDXGI_ERROR_DEVICE_REMOVEDinjection on hardware (both failure paths are exercised deterministically in the pure-CPURetireQueueunit tests).d3d12SDKLayers.dllis not installed on this machine) and native wave64 GPU tests (RTX 4060 is wave32-only).AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first reproductions, targeted RTX 4060 and WARP test runs, the full release workspace suite, and both paired 60 s GPU smoke runs were executed and checked locally.