Repository navigation
Conversation
…L_UPLOAD_BACKOFF=1) Port the C5 OOM back-off and commit-headroom upload admission gate from Vice-Tay (`57deba5c4c752b97a8286bdbd80b96517f0988fc`, `crates/victory-gpu/src/residency.rs`, GPL-3.0) behind opt-in `XCL_UPLOAD_BACKOFF=1` (default OFF). - Add `hle::d3d12x::residency` with 500 ms E_OUTOFMEMORY upload cooldown, 32 ms cached `GlobalMemoryStatusEx` commit-headroom sampling, 512 MiB upload reserve floor (keeps pooled staging reuse open), 1024 MiB staging growth reserve floor, thread-local deferral signaling, and an opt-in aggregate exit summary logged in `report::write_final`. - Wire `residency::allocation_error` into `sparse.rs` and `vram.rs` heap creation OOM paths, `texture_upload.rs` staging pool reuse / growth / trim-on-pressure / `SubmitError`, and `title_textures.rs` deferred retry handling so deferred textures are forgotten cleanly and re-queued without dropping dirty or pending state. - Add `Vice-Tay` provenance entry to `THIRD_PARTY.md`. - Add 5 unit tests in `residency.rs`, a deferral/retry unit test in `title_textures.rs`, and a live D3D12 GPU test in `texture_upload.rs`. Part of xcl-dev#2688 Refs xcl-dev#3011
|
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 This is against AI use: Claude Code (Claude Fable 5.2). |
|
Independent Windows/RTX 3080 Ti (621.35) check of head One pressure-path issue needs attention before the opt-in path is relied on: completed staging jobs remain in Three additional source-only cases need targeted regressions; I did not measure them on a live low-memory system:
Nonblocking reap candidate and fence-test diffdiff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index b9141599..c54d92d5 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -2105,6 +2105,14 @@ unsafe fn reclaim(q: &mut QueueUploads, cap: u64, wait_ms: u64) {
}
}
+/// Return completed upload jobs before deciding that commit pressure requires another allocation.
+/// Never wait for a still-running title queue here.
+unsafe fn reclaim_completed_uploads() {
+ for q in ON_QUEUE.lock().unwrap().values_mut() {
+ reclaim(q, u64::MAX, 0);
+ }
+}
+
/// The queue a submit's uploads go to, by device, and the one it waits for first.
struct Target {
/// the title's queue, when they go to it
@@ -2288,6 +2296,9 @@ unsafe fn upload_all(todo: Vec<Due>, dirty: &[usize], page: usize, title: Option
Some((d, changed, bytes))
}).peekable();
let backoff_on = super::residency::enabled();
+ if backoff_on && todo.peek().is_some() {
+ reclaim_completed_uploads();
+ }
while todo.peek().is_some() {
if backoff_on && !super::residency::admit_upload() {
super::residency::note_upload_deferred();
@@ -2420,6 +2431,12 @@ fn defer_remaining(
/// Those whose time has come are to be uploaded as a whole, like new ones.
fn retry_failed() {
+ if RETRY.lock().unwrap().is_empty() {
+ return;
+ }
+ if super::residency::enabled() {
+ unsafe { reclaim_completed_uploads(); }
+ }
if super::residency::enabled() && !super::residency::admit_upload() {
return;
}
@@ -3074,10 +3091,16 @@ pub(super) mod tests {
assert!(q.bytes > 0);
}
gate.Signal(1).unwrap();
+ let (fence, value) = {
+ let g = ON_QUEUE.lock().unwrap();
+ let q = g.get(&key).unwrap();
+ (q.fence.clone(), q.value)
+ };
+ crate::gpu::fence::wait(&fence, value, dev, None, 5_000).unwrap();
+ reclaim_completed_uploads();
{
- let mut g = ON_QUEUE.lock().unwrap();
- let q = g.get_mut(&key).unwrap();
- reclaim(q, 0, 10_000);
+ let g = ON_QUEUE.lock().unwrap();
+ let q = g.get(&key).unwrap();
assert!(q.in_flight.is_empty() && q.bytes == 0);
}
assert_eq!(read_r8(dev, &queue, &texture), vec![0x77; 64 * 64]); |
|
RTX 3060 12 GB (NVIDIA), Release build, On this card the title goes past the VRAM budget without ever getting an out-of-memory error. So, as far as this run shows, the OOM back-off has nothing to react to. The commit-headroom check never fired either, at 41 GB of process commit on a 64 GB machine. Whether the gate should also look at DXGI's local budget, not only at failures and commit, is for you to judge. No base comparison: on base RTX 3060 12 GB (driver 581.80), i9-14900KF, 64 GB RAM, Windows 11 26200. AI use: Claude Code (Claude Opus 5.5) built the PR, ran the title and wrote this report. |
… on registration id Fixes the four opt-in upload-backoff pressure-path review findings on xcl-dev#3037: - Reap completed in-flight upload jobs without waiting before upload admission and before checking a non-empty retry queue (preserving ON_QUEUE -> FREE lock order), returning completed staging buffers to FREE (or dropping them under pressure) without requiring a later successful submit. - Preserve windows::core::Error HRESULTs through title_textures::upload_queue and map them via SubmitError::from_win so E_OUTOFMEMORY on first copy/compute-queue upload arms the 500 ms cooldown and queues all remaining batches after a single attempt. - Serialize and debit the 32 ms cached available-commit sample on staging growth grants under a leaf Mutex<CommitSample> and hold an in-flight GrowthReservation until allocation completes so concurrent refreshes cannot double-spend headroom below the 1024 MiB growth floor. - Key RETRY entries on (res, Entry::seq) and prune retired or mismatched entries even while upload admission is closed, preventing retry-queue growth under churn and spurious rescheduling on address reuse. Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Thanks @thehollowedone for the thorough pressure-path review and RTX 3080 Ti verification, and thanks @Anon64 for the 300 s RTX 3060 12 GB + 64 GB RAM no-harm run ( Pushed fast-forward commit
On DXGI local-VRAM budget (@Anon64): Keeping DXGI local-VRAM budget deferral out of scope for #3037 intentionally — as your 300 s RTX 3060 12 GB + 64 GB RAM run showed, WDDM spills cleanly past local VRAM budget without hitting OOM when system commit is plentiful, so gating texture uploads on local VRAM budget without active VRAM eviction would risk texture starvation on healthy high-RAM hosts. Local-VRAM budget management belongs in dedicated residency/eviction PRs, while #3037 focuses strictly on OS commit headroom and Verification on
@throny — branch is updated fast-forward to AI use: Google Antigravity (Gemini 4 Neon) implemented the fixes, added the regressions, and ran all local tests and 60 s smokes on this RTX 4060. |
|
Verified current production head 10 passed /0 failed /0 ignored,1.46s tests after fresh33.30s intended-worktree compilation:
Command: Evidence: Limits: diagnostic-relaxed-vtable vkd3d-proton3.2.0 Useful next gate: matched measured loading on a separately runtime-cleared stack with real admitted/deferred/reclaimed bytes, preserving producer-fence completion and distinguishing idle-pool capacity from resident RAM. This passes the changed bookkeeping/data-recovery mechanisms, not that runtime gate. |
|
merge-check Local candidate and GPU regression diffdiff --git a/crates/xcl/src/hle/d3d12x/texture_upload.rs b/crates/xcl/src/hle/d3d12x/texture_upload.rs
index 49faf1a4..fd61e249 100644
--- a/crates/xcl/src/hle/d3d12x/texture_upload.rs
+++ b/crates/xcl/src/hle/d3d12x/texture_upload.rs
@@ -885,7 +885,6 @@ unsafe fn take_in(
match res.reserve_staging_growth_with(cap, now, true, query_commit) {
Some(guard) => Some(guard),
None => {
- trim_free_in(pool, res);
res.note_deferred();
return Err(SubmitError::Deferred("texture upload: staging growth deferred under low commit headroom"));
}
@@ -1518,16 +1517,40 @@ mod tests {
pool.lock().unwrap().push(reused);
// Requesting the 2 MiB texture under mid_commit cannot reuse the 1 MiB buffer:
- // must defer fresh CreateCommittedResource growth AND trim the idle 1 MiB pooled buffer.
+ // must defer fresh CreateCommittedResource growth while retaining the idle 1 MiB
+ // pooled buffer for smaller uploads that are still admitted at this headroom.
let (deferred_res, observed) = residency::upload_deferred_during(|| {
submit_with(&pool, &dev, &queue, &[make_item(&big, &big_mem)], &res, true, 300, || Some(mid_commit))
});
assert!(matches!(deferred_res, Err(SubmitError::Deferred(_))), "expected growth deferral under mid_commit");
assert!(observed, "upload_deferred_during must observe the deferral");
- assert!(pool.lock().unwrap().is_empty(), "idle too-small pooled upload buffer must be trimmed on growth deferral");
+ assert_eq!(pool.lock().unwrap().len(), 1, "retain a reusable smaller staging buffer");
assert_eq!(res.stats().growth_denials, 1);
+ assert_eq!(res.stats().free_trims, 0);
+
+ // A larger deferred upload must not strand later small uploads that could reuse
+ // an already committed staging buffer at the same available-commit level.
+ let (failed, continued, _) = submit_with(&pool, &dev, &queue, &[make_item(&small, &small_mem_a)], &res, true, 301, || Some(mid_commit))
+ .expect("a smaller upload should still reuse its pooled staging buffer");
+ assert!(failed.is_empty());
+ let continued = continued.expect("small upload job");
+ assert_eq!(continued.buf.as_raw() as usize, pooled_raw);
+ value += 1;
+ queue.Signal(&fence, value).unwrap();
+ crate::gpu::fence::wait(&fence, value, &dev, None, 20_000).unwrap();
+ let want_continued = super::super::title_textures::subresources(small_mem_a.as_ptr() as usize, &small.tex);
+ assert_eq!(read_back(&dev, &queue, &small.res, want_continued.len()), want_continued.iter().map(|w| w.data.clone()).collect::<Vec<_>>());
+ pool.lock().unwrap().push(continued);
+
+ // Below the upload reserve, even pooled reuse is closed, so returning idle
+ // commit to the OS still takes priority.
+ let low_commit = UPLOAD_RESERVE_BYTES / 2;
+ assert!(matches!(
+ submit_with(&pool, &dev, &queue, &[make_item(&small, &small_mem_b)], &res, true, 350, || Some(low_commit)),
+ Err(SubmitError::Deferred(_))
+ ));
+ assert!(pool.lock().unwrap().is_empty());
assert_eq!(res.stats().free_trims, 1);
- assert_eq!(res.stats().free_trim_bytes, BUFFER_MIN);
// Arm a 500 ms E_OUTOFMEMORY cooldown at t=400: uploads defer until t=900.
assert!(res.record_allocation_error(crate::util::E_OUTOFMEMORY, 400, true)); |
|
Independent native validation of Tested
Not tested Sustained OS commit pressure, actual allocation failure, the full suite, or retail behavior. AI use Codex GPT-6.2 ran the focused validation, checked the results, and prepared this report. |
|
I checked one Windows accounting boundary for the headroom predicate at head
This shows that system-wide available commit does not capture a tighter job/process commit limit. The probe did not allocate a D3D12 heap or test XCL's failure cooldown, so it does not establish a GPU failure or retail impact. A follow-up could check the relevant job limits if supporting constrained processes is in scope. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the probe; Codex reviewed and prepared this report. |
|
Test report for #3037 on NVIDIA: the whole workspace suite on this PR merged onto today's Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the tests above on the hardware named and wrote this report. |
|
Ran the upload-backoff tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. The two failures are Not tested: sustained OS commit exhaustion, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, a retail title, game data. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
Tested Exact The failed refresh at tick 132 retained 1,040 MiB of cached availability and scheduled the next sample at tick 164. The 32 MiB request was denied. Releasing the 16 MiB reservation left 32 MiB pending without restoring its cached debit. A successful sample at tick 164 followed by a new 32 MiB grant reached the exact 1,024 MiB floor. One additional byte was denied. Later refreshes and releases restored the full sample and admitted 64 MiB again. The fixture recorded five queries and two denials. 2 passed, 0 failed, 0 ignored, 0 runtime skips. Both processes exited 0 with one test filtered out each. Not tested OS memory telemetry, real memory pressure, staging or D3D12 allocations, runtime scheduling, GPU or WARP, retail, CI, and the workspace suite. AI use T3 Code through the Codex harness ( |
|
No open or merged PR makes the same change (an opt-in commit-headroom and E_OUTOFMEMORY gate on texture upload staging). No correctness problem found in what I read (residency.rs, the texture_upload.rs and title_textures.rs changes); the off path keeps the old retry behaviour. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Review (head 58ff61c, diff read, not a merge-check; conflicts with main):
Fine: off is really off (every call checks AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
What is in it
Ports the
C5OOM back-off and commit-headroom upload admission gate from Vice-Tay commit57deba5c4c752b97a8286bdbd80b96517f0988fc(crates/victory-gpu/src/residency.rs, GPL-3.0; credit toTaynanGT,codec_d(codec-d),avatarmanz/VIctory-7900XTX, andVIctorycontributors) ontonvidia-devbehind an opt-in environment variableXCL_UPLOAD_BACKOFF=1(default OFF).crates/xcl/src/hle/d3d12x/residency.rs(with GPL-3.0 §5a modification notice and matchingVice-Tayprovenance row inTHIRD_PARTY.md):XCL_UPLOAD_BACKOFF=1(default OFF; disabled path is a complete no-op with zero extra syscalls or log output).500 msE_OUTOFMEMORYupload cooldown (UPLOAD_RETRY_MS = 500), armed byresidency::allocation_error(hr).32 mscachedGlobalMemoryStatusExavailable-commit sampling (COMMIT_SAMPLE_MS = 32) serialized under a leafMutex<CommitSample>: fresh staging growth grants debit the cached available-commit headroom immediately and hold an in-flightGrowthReservationuntil allocation completes so concurrent calls or sample refreshes cannot double-spend headroom below the1024 MiBgrowth floor.512 MiBupload reserve (UPLOAD_RESERVE_BYTES) keeping pooled staging buffer reuse open under moderate pressure, and1024 MiBstaging growth reserve (GROWTH_RESERVE_BYTES) gating freshCreateCommittedResourceupload allocations.upload_deferred_during/note_upload_deferred) and aggregate-only exit counters (deferrals,oom_cooldowns,growth_denials,free_trims/ MiB), logged once inreport::write_finalonly whenXCL_UPLOAD_BACKOFF=1.crates/xcl/src/hle/d3d12x/texture_upload.rs: preservesE_OUTOFMEMORYviaSubmitError { Deferred, Oom, Failed }(from_win/from_win_in); reuses pooledFREEstaging jobs down to the512 MiBfloor; reserves fresh upload heap growth withreserve_staging_growth_withagainst the1024 MiBreserve; drops idleFREEstaging buffers (trim_free) and declines re-pooling ingive_backwhen pressure denies admission orE_OUTOFMEMORYoccurs.crates/xcl/src/hle/d3d12x/title_textures.rs:reclaim_completed_uploads, preservingON_QUEUE -> FREElock order) before checking upload admission inupload_alland before checking admission for a non-emptyRETRYqueue inretry_failed, so completed staging buffers return toFREE(or drop under low commit) without waiting for a later successful submit.windows::core::Errorthroughupload_queueand maps queue-creation errors viaSubmitError::from_win("upload queue", e)soE_OUTOFMEMORYon a compute/copy queue's first upload arms the500 mscooldown and stops after one batch while queueing all remaining batches for retry.residency::admit_upload()before batches whenXCL_UPLOAD_BACKOFF=1; onDeferred/Oom, forgetsknownhashes for the failed batch and remaining queued items so nothing is lost, queues deduplicated retry entries keyed by(res, Entry::seq)with the backoff delay, trims idleFREEbuffers, and stops spinning in the current submit pass.retry_failed/retry_failed_atprunes retired or registration-mismatchedRETRYentries even while upload admission is closed, preventing retry-queue growth under streaming churn and avoiding spurious rescheduling when a resource address is reused. Default-OFF behavior is unchanged.crates/xcl/src/hle/d3d12x/sparse.rsandcrates/xcl/src/hle/d3d12x/vram.rs: callresidency::allocation_error(e.code().0)on 64 MiB sparse/texture-page pool and arenaCreateHeapfailures so GPU heap OOM immediately pauses staging growth.crates/xcl/src/hle/d3d12x/mod.rsandcrates/xcl/src/report.rs: exposepub mod residency;and emit the opt-in aggregate exit summary inwrite_final.ullAvailPageFile) andE_OUTOFMEMORYfailures rather than DXGI local-VRAM budget. On Windows / WDDM hosts with ample RAM, titles can exceed local VRAM budget cleanly via non-local spill without hitting OOM (as also observed in @Anon64's 300 s RTX 3060 12 GB + 64 GB RAM run); deferring texture uploads on local VRAM budget without active eviction risks texture starvation and belongs in separate eviction/residency work.58ff61c2): Addresses all four pressure-path findings raised by @thehollowedone (non-blocking completed-upload reap,upload_queueHRESULT preservation, debited/reserved 32 ms growth-budget accounting, and(res, Entry::seq)retry identity with closed-admission pruning).hle::d3d12x::residency::tests(disabled no-op, 500 ms OOM cooldown + expiry, dual reserve floors, 32 ms commit-sample cache, debited growth budget + in-flight reservation across sample refresh, thread-local deferral propagation).hle::d3d12x::title_textures::tests(upload_backoff_defers_without_dropping_dirty_or_pending_textures,upload_queue_oom_arms_cooldown_stops_after_one_batch_and_queues_all_retries,retry_prunes_retired_while_closed_and_ignores_same_address_replacement) plus live GPU fence reap verification ingpu_an_upload_still_running_is_kept_when_its_wait_times_out.hle::d3d12x::texture_upload::tests(gpu_upload_backoff_reuses_pooled_buffer_defers_growth_and_recovers) exercising warm pool creation, pooled reuse at 768 MiB commit headroom with bit-exact GPU readback, 2 MiB fresh-growth deferral +FREEtrim + deferral observation, 500 msE_OUTOFMEMORYcooldown, disabled-mode no-op, and post-expiry recovery with bit-exact GPU readback.Part of #2688
Refs #3011
Tested
Tested locally on Windows 11 (
26200), Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (Ada, Wave32, driver32.0.16.2114),rustc 1.100.0, DXC1.9.2609.5, PR head58ff61c296bda172c636a007ff102324c5c5d6f3(fast-forward ontoac52410957a909952e54647e719dcf954cce66bb) offnvidia-dev(d1be8103644791b7a65f068954324e93d4b1b565):cargo clippy --tests -p xcl -- -A clippy::approx_constant -A clippy::while_immutable_condition:exit 0,0new warnings in any touched or new file (residency.rs:0warnings; the-Aflags suppress only pre-existingnvidia-devdeny-by-default lints outside this diff).cargo build --release -p xcl:exit 0,0new warnings in touched files.58ff61c2(3xDebug +3xRelease,--test-threads=1 --nocapture,0GPU test skips):hle::d3d12x::residency:::6 passed; 0 failed; 0 ignored(3xDebug,3xRelease).hle::d3d12x::texture_upload::tests::gpu_upload_backoff_reuses_pooled_buffer_defers_growth_and_recovers:1 passed; 0 failed; 0 ignored(3xDebug, live RTX 4060 D3D12 upload + readback).hle::d3d12x::texture_upload::(full module, live RTX 4060 GPU tests):9 passed; 0 failed; 0 ignored(3xRelease,0skips).hle::d3d12x::title_textures::(including live GPU fence testgpu_an_upload_still_running_is_kept_when_its_wait_times_outand all 3 backoff/retry unit tests):32 passed; 0 failed; 0 ignored(3xDebug,3xRelease,0skips).ac524109(unchanged filessparse.rs,vram.rs,report.rs,mod.rs) also passedhle::d3d12x::sparse::(66 passed; 0 failed; 1 ignored),hle::d3d12x::vram::(22 passed; 0 failed; 1 ignored), andcargo test --release --lib -p xcl -- --test-threads=4(1706 passed; 0 failed; 28 ignored).0upload backofflines inxcl.logwhen unset) and opt-in aggregate exit summary (D3D12.X: upload backoff summary (XCL_UPLOAD_BACKOFF=1): deferrals=0, oom_cooldowns=0, growth_denials=0, free_trims=0 (0 MiB)) on the live 60 s RTX 4060 runs below.Regression run
Quiet 60 s retail smoke runs (
scripts/smoke.ps1 -Seconds 60,XCL_NETWORK=0,title: 29640639, NVIDIA GeForce RTX 4060). Includes a same-daymain(81693f020768ec47dbfe9eefba5eec0ab9aeda6c,XCL_PREPARE=0) baseline forscripts/pr_check.py, thenvidia-devtarget base (d1be8103644791b7a65f068954324e93d4b1b565), the updated PR head (58ff61c296bda172c636a007ff102324c5c5d6f3,XCL_PREPARE=0set, no-op onnvidia-dev) with default settings (XCL_UPLOAD_BACKOFFunset), and the updated PR head withXCL_UPLOAD_BACKOFF=1:mainbaseline (81693f02,XCL_PREPARE=0, forpr_check.py):nvidia-devtarget base (d1be8103):PR head (
58ff61c2, defaultXCL_UPLOAD_BACKOFFunset;0upload-backoff log lines):PR head (
58ff61c2, opt-inXCL_UPLOAD_BACKOFF=1; aggregate summarydeferrals=0, oom_cooldowns=0, growth_denials=0, free_trims=0 (0 MiB)):Not tested
<1024 MiBavailable commit) or real driverE_OUTOFMEMORYduring a retail game session: on this 32 GB RAM / 8 GB VRAM host, available commit remained above the1024 MiBreserve floor throughout the 60 sXCL_UPLOAD_BACKOFF=1smoke (deferrals=0, oom_cooldowns=0, growth_denials=0, free_trims=0). The low-commit deferral, pooled-reuse-between-floors, non-blocking fence reap, debited/reserved growth budget,upload_queueOOM cooldown,(res, Entry::seq)retry pruning,FREEtrimming, and recovery paths are verified deterministically by the unit tests and live RTX 4060 D3D12 GPU tests.XCL_SAMPLE_*game-data tests andtest_title_runs_and_game_folder_is_untouched.texture_upload::tests::some_ranges(tracked separately by Tests: some_ranges in texture_upload wraps its generator instead of overflowing #2771; passes in--release).C5residency slices (active VRAM eviction / residency background worker) and DXGI local-VRAM budget deferral, which are intentionally out of scope for this commit-headroom / OOM back-off PR.AI use
Google Antigravity (Gemini 4 Neon) was used to port, adapt, fix review findings, test, and document this change under human supervision; all edits, unit/GPU tests, clippy checks, and quiet 60 s RTX 4060 regression smokes were executed and verified locally on this machine.