GPU: the look for idle textures in slices, the longest refreshes first #3578
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3578"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by BaRian29 on 2026-11-30T01:20:59Z.
GPU: the look for idle textures in slices, the longest refreshes first
Branch:
BaRian29:pr/texture-sweep-slices(one commit onmain41adb551)Open: https://github.com/trustno1-coder/VIctory-NVIDIA/compare/main...BaRian29:VIctory-NVIDIA:pr/texture-sweep-slices
Summary
Two changes on the submitting thread (
victory-submit), the thread the frame waits for when the CPU is the limit.1.
resource::let_go_idleruns in slices instead of one block a second.Once a second, before a submission, the look for host copies of textures to let go walked its part of the texture table with that table's lock held. With the host under memory pressure most of that time went into
VirtualQueryfor textures that stay mapped and are asked about again at the next look. The frame line said 26-27 ms per look, the longest 59.6 ms, once a second: one late frame every second, and title threads that make or drop a texture waited behind the lock meanwhile.Now both parts of the table (streamed-out copies, then idle ones) stop after
VICTORY_SWEEP_SLICE_US(1,000 us by default, the clock read every 8 textures) and go on where they stopped at the next submission (let_go_idle_more). A resumed call only finishes what was left: it starts no part anew, and the rest of the look (by age, dead render targets, slot eviction, flushes) stays once a second. Letting go later keeps a copy a little longer, it never loses one.2. Refreshes of copies are handed to the helper threads longest first.
refresh_frontgives the spans towide_each_scopedin list order, and the submitting thread waits for the last one to finish. A long span taken last kept it waiting alone. The spans are sorted by length, longest first (the classic LPT rule). They are independent (one span of one copy each, already run concurrently in any order).Measurements
i5-14600KF (6P+8E), RTX 4070 Ti SUPER, 32 GB, Series S profile, DLSS Quality + FG, diagnostics build, 30 s sampling profiles of the same area, 2026-11-29/30:
victory-submitsamplesvictory-submitwaiting for the last refreshvictory-submitwaiting samples overallThe gain is frame pacing (no hitch every second), not average fps: on this machine the copies of title memory (14-17 ms and 36-42 MB a frame) hold most of the preparing.
Switches
VICTORY_SWEEP_SLICE_US=0: the whole look at once, as before.VICTORY_REFRESH_IN_ORDER=1: refreshes in list order, as before.Testing
cargo clippy --workspace --all-targets --lockedand the same with--all-features: no new warning. (mainitself does not pass-D warningsright now: 5 and 4 errors invictory-shaderandvictory-loader. This branch has exactly the same set, 34 and 35 warnings in all.)cargo test -p victory-gpu --lib -- --test-threads=1: 921 passed. The failures are also onmain:shader_cache::tests::every_switch_of_the_translator_is_in_the_key(VICTORY_SCALAR_SPLITSis no longer read by the translator), plus the order-dependentcard_steps::places_written_after_sending_are_learned.refreshes_go_longest_first_and_none_is_lost. It sorts an array, not vectors: allocating there moved the heap underplaces_written_after_sending_are_learned, which finds pages another test marked when its memory lands at their address.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoruiopz on 2026-11-30T07:31:06Z.
I tested the idle-sweep slicing portion independently on an RTX 5070 Laptop GPU (8 GB), leaving refresh order unchanged. Both runs used one diagnostics build on
41adb551plus the Series X 1080p startup patch from #3774. The only renderer switch changed between runs wasVICTORY_SWEEP_SLICE_US=0versus1000. Series X, 1920×1080 output, DLSS Performance and 2× FG, 15 rendered FPS cap, warm cache, same saved starting point and input tape.The streaming duty moved into short continuations as intended. The pressure-limited idle pass was active throughout this window, and descriptor-slot eviction was still about three quarters of the regular maintenance time. The two runs diverged in draw load later, so I would not treat the late percentiles as an A/B speed comparison. The 1 ms slice leaves the once-per-second hitch intact on this route, while confirming that the streamed-out work can be bounded. I posted the matching control's breakdown on #1644.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T11:00:35Z.
@BaRian29 The split sweep counters are useful because our RTX 4070 Ti SUPER / 32 GB setup also has long frames. In a native 2560×1440 Series X route with full RT and DLSS/FG off, we saw one multi-second stall near low commit headroom and many shorter >100 ms frames. I am looking for the exact evidence that isolates the shorter stalls. Did you mark the duration of each idle-texture slice separately from slot eviction? If you are interested in an independent match, a 15-second open-world walk with the two switches recorded and GPU list time included would tell us whether the narrowed sweep moves our limit too. Aggregate time and settings are enough.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by BaRian29 on 2026-11-30T11:24:44Z.
Thanks for the careful A/B: one switch changed, same tape, and the note that the draw load diverged later. That's exactly what I couldn't get from free play.
You're right that the slices only bound the texture-table walk. On your route the late frame left once a second is slot eviction, and the PR's "no hitch every second" only held on my machine. There, the card never crosses its line, so
slot_evictnever runs, and the table walk itself was the 27 ms.I've pushed a second commit (
aba135ad) for slot eviction:VICTORY_SLOT_EVICT_DUTY, 1 % by default;0keeps the old every-sweep behaviour). A 28 ms look comes every 2.8 s, every 2 s at most when the card is past its budget, and every 10 s at least. What it lets go per look doesn't shrink: that's set by how far the card is over its line.VICTORY_SLOT_EVICTline now reports the looks:looks,ms_each,longest_ms.On my side (i5-14600KF, RTX 4070 Ti SUPER, Series S), I had to force the line to 60 % (
VICTORY_SLOT_EVICT_PERCENT=60) to make it look at all:DUTY=0)So about 2.4x less submit-thread time spent on it. My free-play slow-frame counts went the other way (16.3 vs 28.4 a minute over 100 ms), which says route and noise decide those here, not the looks. Your tape is the fair test.
One more thing your numbers and mine share: on my runs, every look let go of nothing. Of 68,604 idle-looking textures, none was shown only by slots it could take, so the whole 24 ms bought nothing. If your logs show the same, an early exit before the slot walk would be the next step. I'd rather see your counts first.
If you have time, could you run your tape once more on
aba135ad, withVICTORY_SLOT_EVICT_DUTY=0against the default? The new line'slooks/ms_eachplus your rendered-interval p95 and the ≥95 ms count would settle it.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T11:27:05Z.
@BaRian29 The zero-eviction pattern also occurs in our full Series X native 1440p stock-RT control, RTX 4070 Ti SUPER (617.14), i5-13600KF, 32 GB. With the normal threshold, the last four periodic reports while the open-world scene stayed loaded each said 0 textures and 0 slots released since start. Each sampled look saw about 54.6k–55.1k idle-looking textures, of which roughly 32.3k–33.2k were shown in indexable slots that could not be taken. No pressure threshold was forced. This is a stock idle/AFK stability run. I have not measured the new DUTY switch in movement. A safe early exit for zero-work looks would be worth a matched test here as well. Do you already have a preferred way of detecting those without missing a slot that changes during submission?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by BaRian29 on 2026-11-30T11:57:05Z.
@akimfomin
Thanks for both reports. Answers to each, then what the latest run showed.
Is each idle-texture slice timed separately from slot eviction? Yes, as of
f800aebb. What's timed (diagnostics build):N looks for textures to let go, X ms each, the longest Y" gives the count, the mean and the max since start. It covers the whole slice, both the streamed-out part and the idle part, and excludes slot eviction. Untilf800aebbit started after the streamed-out part, so that part of a slice was in no counter; your question caught that. It's still an aggregate (mean and max), not each slice's duration.VICTORY_SLOT_EVICTline carrieslooks,ms_each,longest_msand, since121b43a9,idle_in_a_row.Detecting zero-work looks without missing a slot that changes during submission. My preferred way is not to predict zero work from slot state at all, and to make the early exit able only to skip, never to take. Pushed as
121b43a9:VICTORY_SLOT_EVICT_BACKOFF=0turns it off).evict_slotsunder the slots' locks, then the idle andstrong_countchecks before the copy is retired. A slot that changes during a submission can't be missed because of this: the worst a skipped look can do is keep a copy a little longer.A predictor, say a per-texture count of index-picked slots kept up to date at every slot write, would sit on a hot path, and it's exactly where a slot changing at the wrong moment would bite.
Measured here (i5-14600KF, 4070 Ti SUPER, Series S). I forced the line to 60 % (
VICTORY_SLOT_EVICT_PERCENT=60), since slot eviction never looks on this card otherwise:idle_in_a_rowSo your stock idle run should show
idle_in_a_rowclimbing andlooksflattening.One more stall the new timer found: the card-limited branch of the idle sweep isn't sliced. When the card is over its line (12.9 of 14.7 GB on the boat here), the sweep takes the "oldest first" path. That path walks every old-enough copy, about 85k per look here, sorts them, and lets go down to the limit, all in one go: 512 such looks, 8.2 ms on average and 121.8 ms the longest. My slices only cover the host-pressure path. On an 8 GB card that's over its line most of the time, I'd expect this to be the next periodic stall after slot eviction. That's what I'd look at next, unless your numbers point elsewhere.
On your multi-second stall. On the same hardware (4070 Ti SUPER, 32 GB, 63 GB commit limit), a Series X run here hit 60.2 of 63 GB committed, 36.4 GB private with only 21 GB resident. The card sat at 14.5 of 14.9 GB with 10.8 GB pushed to shared memory, and 47 host pipelines failed with
0x8007000e. Frames went from 3-15 fps down to 0.2 fps (5 s frames). That matches your "multi-second stall near low commit headroom". In my runs it was memory pressure, not the sweep.Happy to do the independent match. My plan, so we compare like with like:
VICTORY_SWEEP_SLICE_US=0/1000crossed withVICTORY_SLOT_EVICT_DUTY=0/1, withVICTORY_SLOT_EVICT_BACKOFFon and off for the eviction runs.idle_in_a_row; card meter list time; commit and resident memory.My default is Series S with DLSS Quality and FG. If you'd rather I match your native 1440p Series X, full RT, DLSS and FG off, say so. On 32 GB that route runs close to the commit limit here too, so I'd note the commit at the end of each run.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:50:56Z.
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