victory-gpu: reclaim idle ahead buffers by default under pressure, back off on sustained OOM/device removal, and report buffer OOMs #2015
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2015
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2015"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@superhero-520 on GitHub · 2026-11-29 07:26 UTC · original
superhero-520:fix/ahead-reclaim-and-oom-backoff→main· +238 −23 · 2 files · 1 commits · openSummary
Rebased cleanly onto
v2026.11.29.05(41adb551), reusing upstreamfirst()(residency::scaled_default(..., 512, 4096)),trim_idle(),RetryGate, anduav_buffer_now(), while keeping the remaining valuable reliability fixes for low-RAM / low-VRAM hosts.Root Cause
crates/victory-gpu/src/ahead.rs):VICTORY_LOWSPEC_ADAPTIVE=1,fill()only paused refills underresidency::pressured() || critical_commit()— and when both pools were already full (!more_shared && !more_card), it looped at the idle sleep without ever checking memory/VRAM pressure or trimming already-allocated idle buffers.crates/victory-gpu/src/ahead.rs):DXGI_ERROR_DEVICE_REMOVED/DEVICE_HUNG,fill()kept attempting buffer allocations instead of checkingGetDeviceRemovedReason(), releasing idle buffers, and exiting cleanly.crates/victory-gpu/src/ahead.rs):RetryGatecaps failure rate at a fixed 50 ms per lane (20 attempts/sec indefinitely during prolonged OOM).crates/victory-gpu/src/host.rs):read_back_buffer,shared_buffer_own, anduav_buffer_nowdid not notifycrate::residency::allocation_error(&e)onE_OUTOFMEMORY.Re-Evaluated Scope on
v2026.11.29.05158d3177lowered the default pre-allocation count on< 24 GiBRAM hosts from4096to512viaresidency::scaled_default(..., 512, 4096).32 MiBshared +32 MiBcard), not the older512 MiBceiling (which still applies on>= 24 GiBRAM hosts with low VRAM or commit pressure).Fix Design
crates/victory-gpu/src/ahead.rs:!more_shared && !more_card), checkresidency::pressured(),residency::critical_commit(), and DXGI local VRAM usage vianext_card_vram_pressure()(enters at>= 85%of budget, clears only at<= 70%, matchingcard_has_room()to prevent reclaim/rebuild oscillation).trim_idle()(updated to drop removed resources outside the lock and return the freed count), cap post-reclaimwanttoKEPT, and loglogical_shared_mb/logical_card_mb.GetDeviceRemovedReason()on allocation failures, during pressure pauses, and periodically when idle; on removal, drop all idle buffers outside locks and exitfill()cleanly.RetryGatewithRetryGate::exponential(50ms, 1000ms)per independent lane (shared_retry,card_retry): escalates50 -> 100 -> 200 -> 400 -> 800 -> 1000 mson consecutive failures and is never reset bypressured()/critical_commit()pauses (resolving earlier review feedback), while leavingRetryGate::default()at fixed 50 ms so upstreamretry_testsstay 100% unchanged.crates/victory-gpu/src/host.rs:crate::residency::allocation_error(&e)in theErr(e)paths ofread_back_buffer,shared_buffer_own, anduav_buffer_now(which triggers only onE_OUTOFMEMORY, ignoring device-removed errors).Verification & Results
Automated & Real D3D12 Tests (RTX 3060 Laptop 6 GiB, Windows 11)
cargo test --locked -p victory-gpu --lib ahead:: -- --nocapture --test-threads=1: 12 passed, 0 failed (0.39s):aheadtests remain intact and passing.exponential_retry_gate_backs_off_to_cap_and_survives_pressure_pauses,default_card_vram_pressure_has_hysteresis_aligned_with_card_room,trim_idle_drops_resources_outside_pool_mutex, andd3d12_trim_idle_releases_real_shared_and_card_buffers_cleanly(uses.expect(...)on buffer creation so allocation failures fail the test; debug layer errors:None).cargo clippy --locked -p victory-gpu --all-targets&--all-features: 0 warnings inahead.rs/ modifiedhost.rslines.cargo check --profile diag --locked -p victory --features diagnostics,cargo test --locked -p victory,cargo build --release --locked -p victory,cargo run --locked -p xtask -- policy --staged: all passed.victory-gpu --libsuite: 924 passed, 2 pre-existing unrelated failures already present on untouched41adb551(shared_root_signatures_load_from_library_and_execute_across_pso_switchesandevery_switch_of_the_translator_is_in_the_key).Live Gameplay Validation (RTX 3060 Laptop 6 GiB + Ryzen 7 5800H + 16 GB RAM)
960×540-> DLSS Performance (Model K) -> output1920×1080, RT OFF, warm pipeline library (0in-world slow loads).C1(FG OFF): reclaimed512idle shared buffers (32 MiBlogical, matching 16 GBscaled_default=512),6.17 FPS(1% Low 1.87), 0 OOM / 0 device-removed.E1(combined with PR #2038, FG OFF): reclaimed512shared (32 MiBlogical),6.63 FPS(1% Low 2.10,P99 391.4 ms), 0 OOM / 0 device-removed.G2(combined with PR #2038 + perf fix, FG OFF): reclaimed512shared +392card =904idle buffers (56.5 MiBlogical),6.47 FPS, 0 OOM / 0 device-removed.C-fsr2/E-fsr2(FSR 3 2X): FSR 3 active (0failed prepare dispatches),512shared reclaimed, 0 OOM / 0 device-removed.Limitations & Known Risks
v2026.11.29.05, the reclaimed logical volume is bounded by upstream's512-buffer cap (<= 64 MiBtotal logical); physical RAM/VRAM savings are modest compared to pre-158d3177builds, though preventing sustained OOM retry churn and exiting cleanly on device removal apply across all RAM sizes.AI Assistance Disclosure
AI-Assisted: Rebased, refined, tested, and documented with AI assistance (Antigravity / Gemini), with all unit/D3D12 tests and live RTX 3060 hardware runs verified locally.
On 6-8 GB GPUs and 16 GB RAM hosts, `victory-ahead` pre-allocates up to 4096 x 64 KiB (256 MiB) of pinned L0 `SHARED` buffers and 4096 x 64 KiB (256 MiB) of default-heap `CARD` VRAM buffers at startup, then keeps 1024 (64 MiB) of each: 1. Idle `CARD` buffers were never reclaimed when VRAM reached or exceeded budget, even after `shadow` stopped consuming `ahead::card()` past its budget cutoff, stranding up to 256 MiB of unused VRAM. Idle `SHARED` buffers were likewise never trimmed by `host::sweep()` under host memory pressure or critical commit. 2. When `host.shared_buffer_now(SIZE)` or `host.uav_buffer(SIZE)` returned `None` (`E_OUTOFMEMORY` or `DXGI_ERROR_DEVICE_REMOVED`), `ahead::fill()` looped immediately with zero sleep and never checked `GetDeviceRemovedReason()`, hammering `CreateCommittedResource` in a tight spin loop. 3. `Host::read_back_buffer`, `Host::shared_buffer_own`, and `Host::uav_buffer` did not call `residency::allocation_error(&e)` on `E_OUTOFMEMORY`, unlike `Host::upload_buffer_own`, leaving the 500 ms OOM emergency window inactive until an upload buffer failed. Changes: - `crates/victory-gpu/src/ahead.rs`: - Add `trim(memory)` (wired into `host::sweep()`) to reclaim idle `CARD` buffers at >= 85% VRAM budget or critical commit (preserving a 15% hysteresis band above the 70% refill threshold) and trim idle `SHARED` buffers under host pressure (0 when physical RAM < 8 GiB or commit is critical; 256 / 16 MiB floor when >= 8 GiB free). All COM resources are dropped outside the store mutexes. - Add `drop_all()` (wired into F7 `host::drop_spare_chunks()` and device-removal exit). - Pause `fill()` under host pressure/critical commit, apply exponential backoff (100 ms -> 1000 ms) on allocation failure, and stop cleanly if the D3D12 device is removed. - Add 5 unit tests covering hysteresis, trim limits, backoff progression, lock-free dropping, and live D3D12 resource reclamation. - `crates/victory-gpu/src/host.rs`: - Call `ahead::trim(memory)` in `sweep()` (reusing a single `video_memory()` query) and `ahead::drop_all()` in `drop_spare_chunks()`. - Call `residency::allocation_error(&e)` in `read_back_buffer`, `shared_buffer_own`, and `uav_buffer`. AI-Assisted: Developed and verified with AI assistance (Antigravity / Gemini).github-bot referenced this pull request2026-11-29 11:00:49 +00:00
gpu: reclaim idle ahead buffers under pressure, back off on OOM/device removal, and report buffer OOMsto victory-gpu: reclaim idle ahead buffers by default under pressure, back off on sustained OOM/device removal, and report buffer OOMs8c92331620to8a1abb0af7@tyr0nsur on GitHub · 2026-11-30 12:58 UTC · original
I tested a follow-up for the DXGI non-local budget at
8a1abb0a. The ahead worker already checks physical RAM, commit and the local DXGI budget. On a discrete GPU, Windows can lower the non-local budget while those checks still leave room for speculative shared buffers (#1520).The patch applies the existing 85% entry and 70% recovery thresholds to the non-local segment. The ahead worker pauses speculative shared refill and returns unused buffers. The block sweep shares the same pressure state, so it can release empty CPU-visible heaps after the normal rest even if releasing the ahead inventory first moved usage below 85%. Local VRAM has its own decision. Demand allocations retain their existing path.
With a simulated budget signal and real D3D12 allocations on an RTX 4060, DXGI non-local usage fell from 36 to 28 MiB after dropping 128 committed ahead buffers, and from 92 to 28 MiB in a separate test after a pooled shared heap became empty. A live view and its resting range kept that heap allocated. Both focused tests also passed on WARP, and the diagnostics suite passed 49 tests. These are standalone tests without a title.
Companion commit
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.