gpu: stop full-card texture-queue hold/wake thrashing and VirtualQuery churn #3832
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!3832
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3832"
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?
@KuNQil-o on GitHub · 2026-11-30 08:44 UTC · original
KuNQil-o:perf/full-card-held-texture-thrash→main· +380 −89 · 2 files · 2 commits · closed without mergingWhat it changes
In a 4-hour play log on a 6 GB RTX 3060 Laptop (Series S, DXGI budget ~4,868 MB), the texture queue had no
room in 2,726 of 2,729 five-second windows (99.9%) and re-held 121.5 M of 124.7 M slots taken
(97.4%). Every 5 seconds that drove:
(
noting a slot's record) for 290–364 ms / 5 s;taking the slots due;VirtualQuery(mapped_bytes) and 115–164 ms / 5 s telling the queueTold::Held.Three issues in the full-card hold path caused this churn:
!roomwere held withframe + most(~4 s) instead ofu64::MAX,waking tens of thousands of un-admissible slots every few seconds even though
TextureQueue::roomwakes allheld slots as soon as room returns and
sampled_wakewakes them when sampled.TextureQueue::collect_due_and_censusdid aself.held.get(&e.index)HashMap lookup under the queuemutex for every non-due entry, and
sampled_wakewoke any held slot withe.due > frame && sampled_lately == Some(true)— including visible slots just refused on the same frame, busy-looping every pass.self.heldalso leaked stale entries whenever held slots were overwritten or removed while!room.View::Placedslots with no host copy (!made) ran kernelVirtualQuery(mapped_bytes) and lockedself.away(texture_slot_here) before the!room/!first_uploadrefusal gate.This PR makes a minimal, targeted fix across two files (
crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/draw.rs):FLAG_HELD = 1 << 3onEntry(keepssize_of::<Entry>() == 32), keepsFLAG_HELD↔TextureQueue::held↔marks.has_heldstrictly consistent across all queue mutations (put,take_out,later,hold,room,partly,recheck), and replaces the per-entryself.held.get()HashMap lookupunder the lock with a bit check.
held_sampled_waketoFLAG_HELDentries withdue == u64::MAX(with parity inDueBucketsfor
VICTORY_DUE_INDEX=1), and letsTextureQueue::holdlowerduefromu64::MAXto a finite cooldownwhen a sampled-woken slot is refused again so visible refused slots do not spin every pass.
draw.rs, holds off-screen refused slots (!visible) untilu64::MAXwhile keeping theframe + mostcooldown for visible ones, and short-circuits!room && !madeplaced textures that cannot be admittedas first uploads before
mapped_bytes/texture_slot_here(reusingmadeandroom_for_first_uploadwithout double-counting).
How it was tested
4-hour play log on NVIDIA GeForce RTX 3060 Laptop GPU (6 GB VRAM), Series S, 1080p→1440p, DLSS Performance,
frame generation off, ray tracing off.
no room; 121.5 M / 124.7 M (97.4%) slots taken held back for room;texture queue lock wait 546 ms median (1,794 ms max) per 5 s;
mapped_bytes31–70 ms / 5 s;telling the queue115–164 ms / 5 s.DueBucketsparity,FLAG_HELD↔held↔marks.has_heldinvariants, off-screenu64::MAXsleep, immediatesampled_wake, finite cooldownanti-spin, and
room()wakeup. (Full Windows GPU A/B run pending CI / Windows build.)cargo check --target x86_64-pc-windows-msvc --workspace --all-targets --locked(default &--all-features): passed.cargo clippy --no-deps --target x86_64-pc-windows-msvc -p victory-gpu --lib --tests --locked(default&
--all-features): zero new warnings/errors in modified files.TextureQueue/DueBuckets/held_due_frameunit tests (including 4,000-step randomized equivalencetest and new
indefinite_held_slots_wake_when_sampled_and_cooldown_prevents_spin+held_due_frame_sleeps_offscreen_and_bounds_visible_retry): 5 passed, 0 failed.cargo xtask policy --staged:asset policy: 2 files ok.Checked for overlap
(skips
mapped_bytesbefore full-card check), #2608 (sampled readback / held sweep latency), #2770 (heldflag bit). This PR additionally eliminates off-screen 4 s hold/wake churn (
u64::MAXhold), fixes thesampled_wakesame-frame busy-loop on visible refused slots, cleans staleself.heldentries acrossmutations, and brings
DueBuckets(VICTORY_DUE_INDEX=1) into parity.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-30 08:44 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@tyr0nsur on GitHub · 2026-11-30 09:25 UTC · original
The early first-upload gate can keep an old mip view alive after its backing is decommitted. On
86ad3ad, I reproduced this through the real texture pass on an RTX 4060 with a synthetic texture. After rewriting a placed SRV to expose more mips,texture_slot_made_fromis false for the new record while the slot still shows the old view. When the queue has no room, it takesHeldbeforemapped_bytescan report that the memory is gone. That skipstexture_slot_gone, which releases the descriptor's reference even while the card is full.Follow-up commit b1aa330 keeps the page-walk shortcut for slots with no made host descriptor. Slots retaining a placed view still check for decommit and keep a bounded retry if that view is still mapped. The regression checks the old view is released and that a second slot with no host view still takes the fast hold path.
The targeted draw/descriptor suite passed on the RTX 4060 (96 passed, 1 ignored). The regression and held-queue test also passed on WARP with the indexed queue enabled. The staged asset policy check passed. Playback impact remains to be measured.
@mstrmoos on GitHub · 2026-11-30 19:22 UTC · original
Picked onto our branch with #3753, #3756, #3760, #3881, #3832, #3858 and four that have since merged (#3818, #3850, #3874, #3871). #3760 needed a hand merge on top of the others.
All of victory-gpu's and victory-shader's tests passed. On the RTX 5080 16 GB, Ryzen 7 9800X3D, Windows 11, Series X profile, same save and 90 s bench route each run, the frame median went from 40.4 to 39.1 ms for the whole set. I didn't measure the PRs one by one, so this is evidence of no regression rather than this PR's own gain. Screenshots looked clean.
86ad3ad61dtoefcff10a65@KuNQil-o on GitHub · 2026-12-01 02:51 UTC · original
Rebased and fixed the stale mip view issue reported by @tyr0nsur:
Added regression tests for both cases. Still need to test
efcff10aon Windows at runtime.@mstrmoos on GitHub · 2026-12-01 03:22 UTC · original
A Windows runtime test of
efcff10a, since you asked for one. It found a visible problem on a full card.Setup: RTX 5080 16 GB with
VICTORY_VRAM_BUDGET_MB=5000to stand in for a small card (about your laptop's 4,868 MB). Series X, DLSS Balanced, frame generation off, launcher defaults otherwise. The player stands still on a pier for 120 s with the clock held: water fills the left of the frame, a wooden deck and a railing are in front, people sit at a terrace behind, and a shore is in the distance. That's about 8,900 draws a frame. Main isde21ed57, and the test build isde21ed57with this PR merged. One run each.The queue does what you describe:
The frame time is set by the budget on this scene (about 6.1 GB in use against 5.0), so neither run is playable, and the frame doesn't separate them.
The problem is that surfaces in view stay untextured with the PR. Screenshots at 60 s and 116 s:
My guess, not checked in code: slots refused while there's no room are now held at
u64::MAXand woken when room returns. On a card that stays full, room doesn't return, so visible slots that were refused once may never be asked again unless the sampled wake reaches them. These runs had the launcher'sVICTORY_SAMPLED_MARKSdefault. Your laptop log may not show this if its card dropped under the line now and then.I can rerun with any switch you'd like, or with a longer route.
@KuNQil-o on GitHub · 2026-12-01 04:31 UTC · original
@mstrmoos Thanks for the thorough Windows test and the clear breakdown.
Your guess matches a real path in the code: when VRAM stays pinned above budget and never drops below the threshold, a refused slot parked at
u64::MAXwon't retry unless a sampled wake hits it. I'll check why the foreground pier surfaces aren't getting woken on that path, and also look at replacingu64::MAXwith a bounded fallback delay so a missed mark can't leave visible geometry untextured indefinitely.Since you offered, a quick rerun on
efcff10awithVICTORY_SAMPLED_MARKS=0on the same pier setup would be super helpful to confirm whether the planks/railing recover.@mstrmoos on GitHub · 2026-12-01 04:54 UTC · original
Rerun on
efcff10awithVICTORY_SAMPLED_MARKS=0. Same pier, same 5,000 MB budget, clock held, 120 s,de21ed57+ this PR.The deck and railing recover. They're textured in both the 60 s and the 116 s screenshots, where with marks on they stayed flat for the whole run.
But something else is flat this time. The palm trees right of the terrace (behind the people) render white in both pictures. On main with marks on they're textured, and so are the trees in this PR's marks-on run. The player character is untextured in every build, which is the budget.
So which visible surfaces stay bare depends on which wake path reaches them: with marks on, the planks and railing; with marks off, the trees. That fits the held-forever path more than the marks. A bounded fallback delay instead of
u64::MAX, as you suggest, should cover both cases. Happy to run whatever you push next on the same setup.@trustno1-coder on GitHub · 2026-12-01 18:48 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed