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. |
|
Update for head Tests (
Not tested on this head: a retail run (the run below is for 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 Setup
Tests (debug,
Retail title, 300 s (release, from a copy of the same warm-cache snapshot;
Not tested
AI use
|
|
Pre-merge check of this PR against today's
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 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 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). |
|
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 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). |
…retire signals Address @throny's pre-merge review on xcl-dev#2538: - Gate the no-PAGES idle-arena sweep in `before_execute` on `!has_pages` plus a lock-free 1 s monotonic atomic tick (`ARENA_SWEEP_EPOCH` + `NO_PAGES_ARENA_SWEEP_MS`), and use non-blocking `ARENAS.try_lock()` on both the `do_reclaim` and `!has_pages` paths so submit threads never stall behind `place()` holding `ARENAS` across `CreateHeap`. Advance the throttle timestamp only after `try_lock()` succeeds so contention never burns the 1 s window, and align doc comments with the actual scope. - Combine `newly_reclaimed` queueing and unarmed-batch retry in `RetireQueue::retire_and_arm_with` (called from `retire_heaps_and_sweep`) so each live queue receives at most one `Signal` per call across existing unarmed batches and newly reclaimed heaps, while preserving `unmap_mark` handling and immediate return / fail-closed semantics when `queues.is_empty()`. - Add unit tests `retire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_mark` and `try_sweep_arenas_if_due_is_non_blocking_and_throttled`. Part of xcl-dev#1773 Part of xcl-dev#1585 Part of xcl-dev#1833 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Thanks for the thorough review,
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.) |
|
merge-check
|
|
Additional exact-production-head Wine check at TestedLinux6.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. A deterministic four-interval fixture returns 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): Not testedNo 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: |
|
Native validation of a local NVIDIA adaptation derived from #2538 at Tested
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. |
|
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 Codex (GPT-6) prepared this scoped adaptation and report. Optional temporary contributor/testing coordination: https://discord.gg/gK3y7WRRY |
Reject device-removal sentinel completions, mark sparse unmaps with a checked queue signal, and retain tiles when any queue mark is unavailable. Add a pure retirement fixture (not executed). Related to xcl-dev#2538 (2fc8268), whose fail-closed target-page retirement principle does not cover sparse buffer pools. Source-reviewed independently; no native tests or runtime claims. Prepared with Codex (GPT-6).
|
No open or merged PR makes the same change: main's AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
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), updated in follow-up commit2fc8268271f4d025d408527a9b9cfd62730fab1cto address@throny's pre-merge review:CreateFence/Signalfailure with single-pass signaling (RetireQueue): 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), andRetireQueue::retire_and_arm_with(called fromretire_heaps_and_sweep) queuesnewly_reclaimedunarmed first and callsretry_unarmed_withonce so each live queue receives at most oneSignalper call across previously-unarmed batches andnewly_reclaimed(while returningheapsimmediately only whenqueues.is_empty() && unmap_mark.is_none(), keepingunmap_mark-only batches waiting onunmap_mark, and leaving previously-unarmed batches fail-closed whenqueues.is_empty()).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_execute: 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>, plusARENA_COUNTsynchronized on everyARENASlist mutation (place,before_execute). Inbefore_execute,has_pagesis tracked during thePAGESlock: ondo_reclaim(1 sPAGEStick),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) gatestry_sweep_arenas_if_due(ARENAS.try_lock()), advancing the tick only aftertry_lock()succeeds so contention withplace()holdingARENASacrossCreateHeapnever stalls submits or burns the 1 s window.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_pagesretire_and_arm_single_pass_signals_once_per_queue_and_preserves_unmap_marktry_sweep_arenas_if_due_is_non_blocking_and_throttledTested
main(e1d84b7d9153f86a97d2ec5d209d196046fc0bea) with the originalRetireQueuetests:retire_queue_fails_closed_on_fence_or_signal_failure_and_recoverspanicked:all-fail must hold heaps.retire_queue_rejects_device_removed_sentinelpanicked:u64::MAX sentinel must neither reap nor prune.2fc8268271f4d025d408527a9b9cfd62730fab1cverified on Windows 11 (26200), NVIDIA GeForce RTX 4060 8 GB (Ada, Wave32, driver32.0.16.2114), Intel Core i5-11400F, 32 GB RAM,rustc 1.100.0, DXC1.9.2609.5:cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition:exit 0,0new warnings invram.rs(-Asuppresses only pre-existingrustc 1.100.0deny-by-default lints outside this diff).cargo test --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture(3xDebug):24 passed; 0 failed; 1 ignored(churn_update_tile_mappings_timing),0skipped.cargo test --release --lib -p xcl hle::d3d12x::vram:: -- --test-threads=1 --nocapture(3xRelease):24 passed; 0 failed; 1 ignored,0skipped (all 5 PR pure-CPU unit tests plus live RTX 4060 GPU testsgpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,d32s8_targets_take_their_own_size_of_video_memory, andreservable_agrees_with_the_driverpassed).cargo build --release -p xcl:exit 0,0new warnings invram.rs.73ff10e9ba8c4e7d45362bb8637536b52aba1686also passed full release workspace testing (37test 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/1and 300 s retail run PASS),@emirduran707(AMD Radeon RX 9060 XT RDNA4 Windows, 60 s retail run PASS),@andrewDoing(RTX 5070 no-PAGESarena fixture PASS),@SlopTart(AMD RX 7900 XT Wine/Proton PASS), and@DavidM1911(RTX 3060 Ti PASS).Regression run
Before (
maine1d84b7d9153f86a97d2ec5d209d196046fc0bea, exact parent of73ff10e9):After (
fix-vram-retire-fail-closed-arenas2fc8268271f4d025d408527a9b9cfd62730fab1c):Both 60 s runs reach steady
60 60 60presents per 2 s with0device removals,0crashes,1576vs1508frames shown (104.5%), and13992 MBvs14016 MBpeak commit.Not tested
CreateFenceOOM orDXGI_ERROR_DEVICE_REMOVEDinjection on hardware (both failure paths, single-pass signaling, andARENAS.try_lock()contention are exercised deterministically in the pure-CPU unit tests).d3d12SDKLayers.dllis not installed on this machine) and native wave64 GPU tests on this machine (RTX 4060 is wave32-only; AMD RDNA4 was verified independently on73ff10e9by@ClosetPie107and@emirduran707, and2fc82682has 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
3xDebug/Release RTX 4060 test runs, clippy checks, clean release build, and quiet 60 s GPU smoke runs were executed and checked locally.