Host texture sweep: keep copies the title wants back soon after a host-pressure let-go (#3512) #3681
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!3681
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3681"
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?
@Smoodie7 on GitHub · 2026-11-30 03:42 UTC · original
Smoodie7:rayane/host-sweep-backoff→main· +114 −13 · 2 files · 4 commits · closed without mergingFixes #3512
What it changes
Under host memory pressure,
let_go_idlelets go host copies of placed textures whose title memory is unmapped after 1 s (below 8 GiB of headroom, which on a 32 GB PC is every time the PC is pressured) or 5 s. In the minigame the title still reads many of those textures, so the same copies are let go and made again every second, and every look of the sweep gets slower as the table grows.What the logs show:
VICTORY_HOST_TEXTURE_SWEEP=0removed the stall (seconds with a frame over 150 ms: 40–54 of every 58 → 0–2), but it turns the host rule off entirely.Two commits:
host_evicted). If that copy is made again within 10 s (HOST_BACK_MS), the title is still reading it: the host-pressure sweep passes it over for 2 minutes (HOST_PROTECT_MS). The card's own rule and a flush still apply. Copies that do not come back are still freed. Same pattern as the slot eviction protection (slot_evicted/slot_returned).VICTORY_HOST_SWEEP_PROTECT=0turns it off.VICTORY_SWEEP_BUDGET_MS(default 4 ms; 0: no limit) and go on from the same place a second later (theFROMcursors were already there). That bounds the cost on the submitting thread whatever the table size. Reclaiming under pressure is spread over more seconds instead. This is the same idea as #3578 (VICTORY_SWEEP_SLICE_US), which I found after writing it. I kept it here so this branch can be tested as a whole fix; if #3578 lands first, I will drop this commit and keep only the first one, which #3578 does not cover (slices make each look cheaper, but the copies are still let go and remade every second).The diagnostics line "host memory reclamation since the start" now also says how many let-go copies were made again, how many within 10 s, how often a protected one was passed over, and how many looks were cut short, so the effect can be read from a log.
#3475 adds a back-off to the card's rule. That does not apply here: in #3512 the card was under budget and the unmapped-only host rule was the one churning. The two change different branches of
let_go_idle.How it was tested
cargo test -p victory-gpu --lib: 921 passed. The 2 failures (a_change_is_saved_at_once_however_the_game_was_started,every_switch_of_the_translator_is_in_the_key) fail the same way on main. New unit testa_copy_back_soon_after_a_host_pressure_let_go_is_kept_for_a_while. Clippy shows nothing on the changed lines, with and without--features diagnostics.function unwind_copy is never usedincrates/victory-loader/src/crash.rs. That is not touched here and fails the same way on main (41adb55).Checked for overlap
unmapped_onlycheck inlet_go_idle), #3502 (sweep stutter), #3578 (the look in slices, same idea as the second commit).@saltdam36 on GitHub · 2026-11-30 05:28 UTC · original
Tested on the RX 7800 XT from #3512 (Ryzen 7 7800X3D, 32 GB, Series S, FSR upscaler, no frame generation). Build:
41adb551+ #1236 + #2764 + this PR at90998501, rule on (VICTORY_HOST_TEXTURE_SWEEPunset), dense urban area, host memory pressure on from world entry.The stall is still here with this PR:
41adb551, earlier session)The two runs are different areas of the map, so the frame lengths aren't a like-for-like comparison, but the once-a-second pattern is unmistakable and uploads did not drop. The card was under its budget throughout (11.8 GB of 13.3 GB).
This was not a diagnostics build, so I don't have the "copies made again" count. I can rerun with the diagnostics feature at the same spot if that would show why the protection isn't catching them here.
One correction to the description: the ~650 ms figure is from the 4070 Ti SUPER log; on this card the stalled frame was about 200 ms.
@Smoodie7 on GitHub · 2026-11-30 05:32 UTC · original · edited 2026-11-30 05:37 UTC
Thanks @saltdam36, and noted on the ~200 ms figure for your card.
One important point first: this PR targets the minigame of #3512, the mission where you start the game console and play on it, not the open world. Your run was in a dense urban area, so it does not cover the case this fixes. In the minigame the change is large: up to two to three times the frame rate, and the once-a-second stall gone (table below). Could you rerun at
66fe197inside that minigame?About the open world: your run is at
90998501, before the third commit, and I think it shows the same thing I saw: with the card at 11.8 of 13.3 GB, the card's rule is the one deciding (vram_keep_belownear its line), not the host-pressure rule. The first two commits only act on the host-pressure rule. The card's rule still hit thehost_idle/unmapped_onlygate (#3272), so every look walked the whole list and freed almost nothing.dea4b48fixes that gate and applies the look budget to the card's rule as well.My runs, same minigame as in #3512
RTX 4070 Ti SUPER, Ryzen 7 7700, 32 GB, Series X 1440p, DLSS Quality, frame generation 4x, ray tracing off, release builds. One log line per second:
The relapse came when the card went from 11.7 to 13.3 GB of its 15.3 GB budget. At that point looks took 60–75 ms again, which matches your
90998501run. With all three commits, I played the minigame again on my second PC and checked the logs: the stall did not come back, including past the point where it used to.Before (main), in the minigame:
With this PR (commits 1–2), in the minigame:
For the rerun in the minigame, a diagnostics build would be ideal: the "host memory reclamation" line now gives copies made again, copies protected and looks cut short, so we would see which rule is acting on your card.
@dyshay on GitHub · 2026-11-30 05:50 UTC · original
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.github-bot referenced this pull request2026-11-30 09:34:54 +00:00
@mia03ther on GitHub · 2026-11-30 11:10 UTC · original
Adding a
v2026.11.29.0516 GB RAM data point (#3909) showing why texture/memory-pressure PRs like this matter even when VRAM stays under budget:36–48 GBpagefile), Win11 26300, Series S 540p, DLSS Performance, FG off,VICTORY_TEXTURE_ROOM_PERCENT=78,VICTORY_SLOT_EVICT_PERCENT=80,VICTORY_SLOT_EVICT_LOW_PERCENT=70.8,650–8,856 / 10,818 MB) with0pipeline failures or crashes across 10,933 frames, yet private commit hit20.6–21.0 GBwith only5,494–5,863 MBresident (487–790 MBfree RAM). Even after preload (early=3676), 694/10,933 frames exceeded 100 ms (longest 4,295.9 ms) andVICTORY_THIN/landguards swung between259 msand617.8 msunder memory pressure. Hoping to see #3681 land in.06!@saltdam36 on GitHub · 2026-11-30 19:43 UTC · original
Reran at
66fe197on the RX 7800 XT 16 GB (Ryzen 7 7800X3D, 32 GB, Series S, AMD FSR upscaler 720p→1080p, no frame generation): the port's main at84bd61e2with #1236, #2764 and this PR merged,VICTORY_HOST_TEXTURE_SWEEP=1, defaults otherwise. Host memory pressure was reported from the first minute in the world.The once-a-second stall is gone in all three. At
90998501the open world had a ~280 ms frame in 34–52 of every 57 seconds; here the remaining long frames coincide with new shaders being translated (the cache was a few minutes old, this base translates differently) and thin out as it fills.Two limits: this is not a diagnostics build, so I have no "host memory reclamation" counts. And I have no valid before-run in the minigame: a second session with
VICTORY_HOST_SWEEP_PROTECT=0was just as smooth, but host memory pressure was never reported in it, so the rule did not act.@SmartIngenieriayDesarrollo on GitHub · 2026-12-01 02:22 UTC · original
An AMD measurement of this idea, ported to our tree as an opt-in switch.
Setup
Port.
VICTORY_SWEEP_BUDGET=1puts a time budget on each sweep pass (VICTORY_SWEEP_BUDGET_MS, default 4 ms).VICTORY_HOST_SWEEP_PROTECT=1keeps the copies the title wants back soon, as this PR does.In-run A/B. The switches are toggled every 4 s inside one run, in the same scene. 49 phases were used:
SWEEP_BUDGEToffSWEEP_BUDGETonThe median does not move, but the mean and the p90 do: the budget removes the once-a-second spike, which is what the PR targets.
HOST_SWEEP_PROTECTon its own was neutral in the cell (−0.24 ms). I expect it to matter more in the city, which I have not measured yet.Thanks for the PR. It was the first one where we could see the sweep cost clearly.
— El_Santo
AI-assisted: yes
@trustno1-coder on GitHub · 2026-12-01 18:49 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