Host lists: pool the copy sources; memory pressure trims spares down to 128 MiB instead of to nothing #57
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!57
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-57"
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?
@Yorivel on GitHub · 2026-11-27 15:22 UTC · original
Yorivel:fix/reuse-list-upload-buffers→main· +91 −8 · 1 files · 1 commits · openTwo changes in
host.rsthat remove most of the "new memory waited for" time in gameplay on a 24 GB card with 64 GB of RAM.1.
HostList::uploadtakes its buffers from a pool.Every copy a list recorded made a new upload or shared buffer and waited for it to be resident (
MakeResident), then freed it at the list's reset (theshortcut:note on the function asked for this). The buffers now come from a pool by size class (a power of two, at least 64 KiB) and go back at the reset.VICTORY_UPLOAD_POOL_MBcaps what is kept per kind: 1024 by default,0restores the old behaviour. The callers write or zero the bytes they use and copy by offset, so a reused buffer with old contents is fine.2. Memory pressure trims spares down to
SPARE_MOSTinstead of dropping them all.trim_spare_chunksemptied the spare scratch chunks every second whileresidency::pressured()held. On this PC (64 GB of RAM, system-managed page file, commit limit 67.8 GB) the commit headroom stays under 4 GiB for the whole session while the title runs: victory.exe commits about 40 GB with about 22 GB of physical memory still free. So the pressure never ended, and lists made the chunks again right away: 12,925 chunks (13.5 GB) in 5 minutes. The trim now keeps the 128 MiB given last, and it covers the new copy-source pool as well.Measured
RTX 4090, i9-14900K, 64 GB, driver 621.40, release build. About 5 minutes of play each, same save. Counts come from a local per-caller counter around
upload_buffer/shared_buffer/uav_bufferandresident(); that counter is not part of this PR.HostList::upload)take_chunk)No visual differences were noticed in play.
What is left (not in this PR), for whoever picks it up
budget,make_card_budget) and the batch buffers (batch_place), about 13,500 buffers and 7.5 s of waits per 5 minutes. The idle pool (IDLE_MOST, 512) still lets about 3,000 lists be made per session.shadow.rs5255/466/5579/5669, about 10,000 buffers and 4 s.residency::pressured()on 64 GB machines: commit headroom is a poor signal when the page file is system-managed (it can grow), and the pressure stays on for the whole session.Testing
cargo checkon this branch (based ond12eb1b).959dcafplus these changes, as measured above. The three commits since then (thread groups, shaders) were not played with this change yet.🤖 Generated with Claude Code
@Yorivel on GitHub · 2026-11-27 15:50 UTC · original
A follow-up from the same machine (RTX 4090, i9-14900K, 64 GB, release build with this PR), in case it helps with where the frame time goes after the waits are gone.
The frame is bound by preparing, not by the card. In the prison area, the frame line reads 34-55 ms a frame, with the card busy 0-2 ms of it. The submitting thread spends about 28 ms a frame preparing:
refresh_front, ~970 real updates)CPU profile (samply, 60 s, symbolicated against the PDB). Of the submitting thread's wall time:
wide_eachrefresh workers;watch::guards, throughwatch::writes→guard()fromShadow::update_free. Every refresh worker takes the oneGUARDSlock, andprotect()(VirtualProtect) runs while it is held, so the parallel refreshes mostly run one at a time.retire_resource, throughHostHeap::keep←constant_at: the push rate on the globalRETIREDqueue. The drops are already outside the lock.watch::kernel_written, throughask_ahead, mostly kernel time.What we tried, and why it is not in this PR. A local prototype ran
VirtualProtectwith the guards' lock released:protect_aliasdoesn't trust them yet;protect().It was slower: preparing 30 ms against 28, refreshes 8.5-8.8 ms against 6.7. Taking the lock twice per run costs more than the wait it removes, and about 15 % of the blocks fell back anyway. In that run one NPC's arms also showed RGB squares, normal at the same spot after a restart without it. That is a single sighting, but it is the kind of lost write such a change can cause, so we dropped it.
So the contention is real, but releasing the lock around the syscall alone doesn't pay. Fewer, larger protection calls per refresh, or guard state split per region, look like the directions that could. That is your call on the design, of course. Happy to test anything on a 4090.
Also seen, not looked into: 330-400 draws a frame dropped "without a host pipeline (0 being made)" in the same area, with the cache warm.
One thing about memory pressure on this PC: with a system-managed page file, the commit limit here is 67.8 GB, and victory.exe commits about 40 GB with ~22 GB of RAM still free. So
residency::pressured()is on for the whole session.@bob7up on GitHub · 2026-11-27 17:10 UTC · original
Here’s a baseline data point for this PR from a 10 GB RTX 3080. I ran a release build with my checkout at
d12eb1b. My system has a Ryzen 7 9800X3D, 64 GB RAM, Windows 11 Pro build 26300, and NVIDIA driver621.24. Settings were Series X, 2560×1440 output, DLSS Balanced, and frame generation off.I loaded a save and left the game mostly idle for about 2 hours 30 minutes. I saved again and closed it manually. The log showed no crash or GPU device-loss messages.
Shortly before shutdown, VIctory logged host memory pressure limiting texture prefetch and idle upload storage, with 3,066 MiB of available commit and 13,735 MiB of free physical memory. The attached F3 snapshot from the waterfront porch shows 106.0 ms/frame (9.4 FPS), 96.4 ms submit busy, 41.7 ms GPU busy, and 8.7 of 8.8 GB of the reported VRAM budget in use. That’s a single snapshot from the run.
Would a same-save comparison with this PR on the 3080 be useful?
I ran the test locally and used OpenAI Codex to help draft this report.
victory-nvidia-stability-redacted.log
@Yorivel on GitHub · 2026-11-27 17:17 UTC · original
Another finding from the same 4090, this time with the structure builder on (
VICTORY_BVH_BUILDER=1, frame generation off). It's about the stutter in the first minute or two of ray tracing, when the builder makes the scene's structures.What the stutter frames wait for. The submitting thread waits 50-250 ms for flights, settled for "title memory read … by a fill of upload memory". A release-build counter at that wait (in
blocked_by) shows every one of those fills isFillTo::Slot, i.e. constants for a descriptor slot. So they are fillscard_stepscan do on the card, and it already does 3,000-4,000 of them a frame. None were scratch fills or buffer starts.Why card steps don't take them. A release-build counter of
take_steps' refusals gives about 100 a minute, allBEHIND_PLACED("a copy at its place in a list writes what it reads, or reads or writes what it writes"). That is the case the doc comment onplaced_order()describes: a copy of a few hundred bytes into the title's constant ring, placed in a list, ahead of fills that read the ring. With the builder's work in flight, each refusal costs the whole wait.VICTORY_PLACED_ORDER=1doesn't clear it here. The refusals stay at about 100 a minute, so the placed copy really does stand ahead of a fill that reads its bytes, and the submission is not cut (cut_for) at that point. The doc says the case did not come up in runs submit-1 to submit-3. In this game's ray tracing start-up it comes up constantly, so the cut path may deserve a look with a real capture.We are trying a local prototype of the cut, and will report back with numbers either way.
Also on the ray tracing side, with fixes on a local branch, PR to follow if you want it:
+0x23cf683). Onceupload::reservefound no 64 MiB gap in [4 GiB, 2^37),memory::readyasked for another arena at every builder dispatch, under the MEMORY lock. Frames took 7-32 s.victory warmunless it runs withVICTORY_BVH_BUILDER=1, yet they are still marked done inwarm-done.txt. Warming with the switch (--again --used) removed the RT pipeline builds at start-up.@heklokate on GitHub · 2026-11-27 17:25 UTC · original
Test results on an RTX 3070 Laptop GPU
I saw fewer calls that waited for residency in both runs. Total wait time and frame-time tails improved in one run and worsened in the other. The mean of the two median FPS readings was 9.60 on main and 9.73 with the PR, a 0.13 FPS difference with 1.01 FPS of run-to-run spread on main.
Hardware and setup. Intel Core i9-12900H, RTX 3070 Laptop GPU (8 GB, driver
32.0.16.1742), 32 GB DDR5-4800, Windows 11 build 26100. Release build, Series S, DLSS Quality, frame generation off. The same deck save and independently warmed caches were used throughout.Samples. Two valid runs per build, one 30-second PresentMon window per run starting at 180–181 seconds after launch. The table lists each run separately. Warm-ups and an earlier main capture affected by background compilation were excluded.
Revisions. Main
d12eb1band PR99096e6. The upload pool used the PR defaults.Both builds logged host memory pressure. In the first run, the warnings reported 2,581/2,589 MiB physical memory free and 7,042/7,033 MiB available commit on main/PR. The residency counter is cumulative and is logged in steps of 1,000 waits.
In run 2 the PR had already accumulated more wait time at the earlier log line. Its longest reported wait in these snapshots was 4.79 s, versus 1.49 s on main. The same deck view was visible in each run, with draw counts within 3%. The GPU was still busy for most of the frame interval on this laptop.
A first warm-up attempt for each build hit the same guest access violation. Both completed warm-up after a retry.
Tested and documented by Codex.
@Yorivel on GitHub · 2026-11-27 17:35 UTC · original
Follow-up on the
BEHIND_PLACEDfinding above, with numbers from a local prototype.Prototype (
VICTORY_FILL_FROM_PLACED=1, local only):blocked_by, inplace::read_by, and inrun_deferred(the CPU fill).Result (RTX 4090, ray tracing start-up, ~3 minutes):
BEHIND_PLACEDrefusals went from ~100 a minute to 0.So the copy at its place in the same list is one cause of those waits, but not the one that dominates the stutter. We're now logging the remaining waiting fills: what last wrote their bytes, and whether a flight writes them. We'll post what that shows.
@Yorivel on GitHub · 2026-11-27 17:49 UTC · original
Last follow-up on the ray tracing start-up waits. Three local prototypes, all behind switches, all now off again. Each one removed the refusal it targeted, and each time the next rule took its place; the stutter did not change.
BEHIND_PLACEDVICTORY_FILL_FROM_PLACED(a fill behind a copy at its place reads the copy's source)BEHIND_PLACEDVICTORY_PLACED_ORDER=1BEHIND_PLACEDVICTORY_PLACED_IN_FRONT(such a copy is also done on the card in front, if nothing ahead in its list reads its destination)BEHIND_PLACED, 51 × "a copy done on the card is read through another host copy"What this says:
copied_read.card_stepsends (nothing in the air / not blocked / nothing chosen / taken);take_steps' refusals by reason.Two directions look worth trying: refusing step by step instead of the whole submission, and one host copy for the ring (or
copied_readfor it). Both are your design calls. The prototypes are a local patch; I can share it if it helps.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.