victory-gpu: fence-tracked LRU VRAM GC and upload buffer pooling #72
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!72
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-72"
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?
@godsfathermixtape on GitHub · 2026-11-26 01:38 UTC · original
godsfathermixtape:feat/gpu-fence-lru-gc→main· +2028 −64 · 9 files · 1 commits · draftChanges
HostHeap::kept: Added aWeak-backed reverse slot map to unpin stale bindless descriptor references prior tolet_go_idledeallocation.gc.rs: Added upload and staging buffer pooling forHostList::upload, gated per queue fence (Host::fenceand copy-queueWorker::fence).Host::present: Added a capped per-frame LRU eviction sweep targeting 75% of the DXGILOCALmemory budget.Configuration
VICTORY_GC=0|1VICTORY_UPLOAD_POOL=0|1VICTORY_MEM_BUDGET_MB=<MiB>Verification
cargo test -p victory-gpu --lib: 329/329 passed (includes live D3D12 descriptor slot-nulling test).cargo xtask policy: passed.--console series-x, RTX 4060 8 GB, 32 GB RAM): reached opening street cutscene with zero DRED faults or texture corruption. Frame-time delta not isolated due to host RAM paging saturation.Limitations
LOCALmemory only;NON_LOCAL(shared GPU memory) is not tracked or evicted.needed_bytes.is_some()) bypass the 120-frameIDLE_FRAMESfloor inresource::evict_lruandshadow::evict_lru, evicting fence-completed resources oldest-first. On GPUs where the active working set exceeds theLOCALbudget, this can cause re-upload thrashing.resource::evict_lruholdsTEXTURESandshadow::evict_lruholdsLOOSE/BUFFERSlocks while invokingslot_ref_count(RESOURCE_SLOTS+ per-slotkeptlocks) per candidate, which may cause recording-thread contention under sustained budget pressure.@Adika713 on GitHub · 2026-11-26 02:07 UTC · original
I read the full diff at
4f0d563. Two points matter for the reported 24–28 GB working-set and commit target:The budget is DXGI
LOCALonly.gc::budget_bytes_fromusesVICTORY_MEM_BUDGET_MBor 75% of the DXGI local budget, with a 90% hysteresis target; I found no read ofK32GetProcessMemoryInfo,WorkingSetSize,PagefileUsageorGlobalMemoryStatusExin the diff. On the 32 GB host here, a local run reached10191 MB private,4452 MB in memory,16047 MB free physicaland154 MB left to commit— that commit pressure would not be visible to a VRAM-only watermark, and process working set is the metric the plan asks to reduce. A second band based on process working set, private commit and system commit headroom, with hysteresis, would address the stated target.Both new switches are on by default (
VICTORY_GCandVICTORY_UPLOAD_POOLare disabled only when set to0), and the over-watermark path bypasses the 120-frame floor and the 64-per-frame cap. The PR body already notes possible re-upload thrashing and recording-thread lock contention. I could not find a game-free unit test forshadow::evict_lruitself: the added tests coverUploadPoolCore, the budget/hysteresis helpers and one live D3D12 descriptor-slot case.I am not claiming a frame-time or visual result; no game run was done for this review. Independently, at head
4f0d563on RX 6950 XT / Ryzen 5 3600 / 32 GB / Windows 11,cargo test --locked -p victory-gpu --lib -- --test-threads=1with an isolated target dir returned328 passed; 1 failed; 34 ignored, exit 101. The single failure is the pre-existingdescriptor::host::tests::views_are_made_beside_the_heap_and_copied_in(assertion atdescriptor/host.rs:4945); all three newgc::testspassed, including the live D3D12 descriptor case. At base0a43566with the same command I got325 passed; 1 failed; 34 ignored, exit 101, with the same test failing. The PR adds three tests and all three pass; it introduces no new failure in this run.Tool/model: OpenCode, Big Pickle.
@MoonYueya on GitHub · 2026-11-26 09:42 UTC · original
RTX 3080 (10 GB) measurement of
4f0d563, with the PR's defaults left on(
VICTORY_GCandVICTORY_UPLOAD_POOLunset, so both enabled).Setup: Ryzen 7 7700, 31.1 GB, Windows 11, driver 32.0.16.1742. Same save,
same switch set, same prewarmed cache policy (25,764 shaders translated,
206 that do not translate) for both arms; each arm on its own build so the
caches cannot mix. 480 s per run, unattended into the world. The control is
f59a315of MoonYueya/VIctory-Kira (this repo'se2a28ecplus the open NVIDIA PRs #47 #48 #24 #23 #78 #42 #66 #18 #10 #4 #58 #17 and #69), which does not contain this PR; n = 71 worldframe lines on the PR, 74 on the control.
f59a3154f0d563The only improvement is
lack of room(-8%). Everything else that mattersmoved the wrong way: 4.3x the frame time, 7.3x the textures skipped for want
of a mapping, 27% more uploaded bytes, and a visibly darker frame.
The log says why. Five watermark sweeps ran in 480 s, and the eviction counts
are not the routine path:
budget_mbsits at 5.5-5.9 GB, which is 75% of a DXGI local budget that onthis card is itself only 7.0-7.9 GB. The layer's existing admission test
(
resource.rs room()) admits work up to 90% of that same DXGI budget. So thenew watermark is below the line the renderer already considers full: the
sweep takes away host copies the renderer would still have used, and the next
frame uploads them again. That is the re-upload thrashing the PR body warns
about, and at 75% it is the normal case rather than an edge case on a 10 GB
card.
Two concrete suggestions, both small:
(90% to start evicting / 85% target, as Marvisak/VIctory
63bcca4does incrates/victory-gpu/src/resource.rsevict_unused(), with its evict-then-rebuild guard) instead of 75% / 67.5%. Note that theover-budget path bypasses
IDLE_FRAMESandROUTINE_SWEEP_CAPentirely,so the fraction is the only thing standing between a sweep and a 12,798
object eviction in one frame.
that are safe on their own; at
VICTORY_GC=0this run's control numbersare reproduced, so the risk is contained to the sweep.
I am not claiming the upload-pool half of the PR is bad; I only measured the
PR as a whole with its defaults, and as a whole it is a regression here. Two
runs, one of which I discarded because a
cargo test --workspacewas runningbeside it on the same 10 GB card.
AI-assisted: an AI agent ran the builds, runs and measurements.
@Adika713 on GitHub · 2026-11-26 11:26 UTC · original
Target: #72
I checked MoonYueya's report against
4f0d563. It matches the code:gc::budget_bytes_fromdefaults to 75% of DXGILOCAL;hysteresis_target_bytesis 90% of that watermark, so the pressure sweep starts at 75% and stops at 67.5% of the local budget.resource::roomadmits more host textures whileused < budget * room_percent(), withroom_percentdefaulting to 90. On the reported 7.0-7.9 GB budget, the sweep therefore starts below the renderer's own admission line.usize::MAXtoresource::evict_lruandshadow::evict_lru, bypassing bothIDLE_FRAMESandROUTINE_SWEEP_CAP. That is consistent with the logged 12,798-object eviction frame.VICTORY_GC=0leaves upload pooling on, but also leaves the newpool::room_with_budgetpath active; that caps empty blocks at 1 when local use is over the same 75% watermark. The control result withVICTORY_GC=0points at the sweep, not the upload pool, as the main source of the regression.I prepared a minimal patch against
4f0d563(not pushed): default VRAM high watermark 90% of DXGI local, pressure target 85%, explicitVICTORY_MEM_BUDGET_MBstill an exact watermark with its existing 90% target, and the upload-pool target unchanged. Thegc::testsbudget test is updated to assert 90%/85% while keeping the override and upload-pool assertions.Verified on RX 6950 XT / Ryzen 5 3600 / 32 GB / Windows 11:
cargo test --locked -p victory-gpu --lib mem_budget_default_90_percent_85_target -- --test-threads=1: 1 passed, 0 failed.cargo test --locked -p victory-gpu --lib -- --test-threads=1: 328 passed, 1 failed, 34 ignored, exit 101. The failure is the same pre-existingdescriptor::host::tests::views_are_made_beside_the_heap_and_copied_inseen at the PR head before this patch.Given the measured 4.33x median regression, I would not merge the pressure sweep with its current 75% defaults. Either align it to 90%/85% and retest, or gate the pressure sweep off by default while keeping fence tracking and upload pooling. The branch also currently conflicts with
main, so a rebase is needed before merge.Tool/model: OpenCode, Big Pickle.
4f0d563447to7d0bf9785a@godsfathermixtape on GitHub · 2026-11-26 17:02 UTC · original
Rebased onto
main(c9c932c, preserving PR #77'shost::RamBand/shadow::window_victimsandVICTORY_RESIDENCYpaths) and updated at7d0bf97to address review feedback and add a minimalresource.rsretry-on-evict hook for #256.Changes
gc::on: ChangedVICTORY_GCdefault from1to0(opt-in); keptVICTORY_UPLOAD_POOLdefaulting to1.gc::budget_and_target_bytes_from/pool::spares_with_budget: Raised the default DXGILOCALhigh watermark from 75% to 90% (matchingresource::room()) with an 85% DXGILOCALhysteresis stop target. Retained explicitVICTORY_MEM_BUDGET_MBoverrides as an exact watermark with a 90% hysteresis target.pool::room_with_budgetno longer clamps spare blocks whenVICTORY_GC=0.gc::on_present/resource::evict_lru/shadow::evict_lru/texture::evict_lru: Removedusize::MAXeviction caps on the over-budget path. Over-budget sweeps now enforceOVER_BUDGET_SWEEP_CAP = 128per frame andOVER_BUDGET_MIN_IDLE_FRAMES = 16so recently used allocations are not evicted and re-uploaded on the next frame.resource::Hosted::refused(#256): ReplacedAtomicBoolwithRefusalState(None,Transient,Permanent).E_OUTOFMEMORY/ERROR_COMMITMENT_LIMITand non-device-loss residency failures recordTransientwhile keepinghost_waitsactive; invalid/unsupported descriptions and device removal recordPermanent. Whenresource::evict_lrufrees VRAM (freed_bytes > 0), onlyTransientrefusals are cleared.Configuration
VICTORY_GC=0|1(default0)VICTORY_UPLOAD_POOL=0|1(default1)VICTORY_MEM_BUDGET_MB=<MiB>(exact watermark override; 90% hysteresis stop target)VICTORY_UPLOAD_BUDGET_MB=<MiB>Verification
cargo test -p victory-gpu --lib:386 passed; 0 failed; 34 ignored(includes updated 90%/85% andVICTORY_GC=0default tests, asset-freeshadow::evict_lrufence/age-floor/cap test, #256 transient-vs-permanent refusal reset test, and live D3D12 descriptor slot-nulling test).cargo xtask policy:asset policy: 266 files ok.7d0bf97Limitations
gcbudgets DXGILOCALmemory only;NON_LOCALmemory is not tracked bygc(system-RAM pressure remains gated separately underVICTORY_WINDOW_BUDGET_MBandVICTORY_RESIDENCY).resource.rs(Refusal::Transientreset whenresource::evict_lrufrees VRAM, plushost_waitsretention);draw.rsbindless queue completion and descriptor-cache fast paths described in #256 are not modified in this PR.VICTORY_GC=1,resource::evict_lruholdsTEXTURESandshadow::evict_lruholdsLOOSE/BUFFERSlocks while callingslot_ref_count(RESOURCE_SLOTS+ per-slotkeptlocks) per candidate, and working sets exceeding 90% of DXGILOCALwith idle ages>= 16frames can still incur bounded (<= 128/frame) re-upload churn.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.