Repository navigation
Host lists: pool the copy sources; memory pressure trims spares down to 128 MiB instead of to nothing - #57
Conversation
|
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:
CPU profile (samply, 60 s, symbolicated against the PDB). Of the submitting thread's wall time:
What we tried, and why it is not in this PR. A local prototype ran
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 |
GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
|
Here’s a baseline data point for this PR from a 10 GB RTX 3080. I ran a release build with my checkout at 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
|
|
Another finding from the same 4090, this time with the structure builder on ( 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 Why card steps don't take them. A release-build counter of
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:
|
Test results on an RTX 3070 Laptop GPUI 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 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
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. |
|
Follow-up on the Prototype (
Result (RTX 4090, ray tracing start-up, ~3 minutes):
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. |
|
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.
What this says:
Two directions look worth trying: refusing step by step instead of the whole submission, and one host copy for the ring (or |
Host lists: pool the copy sources; memory pressure trims spares down to 128 MiB instead of to nothing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pressure trims spares down to 128 MiB instead of to nothing
…k when its submission lands Conflict with PR trustno1-coder#57 (upload pool) in host.rs: both additions kept. The memory bench counts RETIRED over its shards (PR trustno1-coder#139).
GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
|
A data point from a 16 GB machine, where the pressure never clears: here this goes the wrong way, and so does the trim half on its own. Tree:
(The first run with the PR had a browser drawing on the same card; the second did not.) So with the spare chunks kept, the submitting thread stands waiting for flights about 40 ms more a frame and the card idles behind it, and it is the keeping itself that does it here, not the pooled copy sources. On this PC the pressure rule (under 3 GB free) is true for the whole run, so before the change every spare chunk went each second and the lists made about 63 upload buffers a second again; that churn turns out to be cheaper than whatever reusing a chunk costs with the relay on. I have not traced where the wait comes from; my guess is a chunk given back and taken again while a flight that names it is still in the air. The thread does not say whether the 4090 / 64 GB runs had |
… to spare, keep 128 MiB of spares Every copy a list recorded (HostList::upload) made a new upload or shared buffer and waited for it to be resident, then freed it at the list's reset. They are now taken from a pool by size class (power of two, 64 KiB at least) and given back at the reset; VICTORY_UPLOAD_POOL_MB (1024 per kind, 0 = as before) caps what is kept. Under memory pressure, the spare scratch chunks (and the pooled copy sources) are trimmed down to SPARE_MOST (128 MiB) instead of all of them, but only while 8 GiB or more of the PC's memory is free (keeps_under_pressure). Then the pressure is the commit limit's, not the memory's: with 64 GB and a system-managed page file the commit headroom stays under 4 GiB for the whole session with ~20 GB free, and the spares freed every second were made again at once. With memory really short they all go, as before: on a 16 GB PC keeping them cost ~40 ms a frame of waits for flights (review on trustno1-coder#57). RTX 4090, i9-14900K, 64 GB, about 5 minutes of play each: - waits for new memory to be resident: 68,000 / 17.3 s -> 37,000 / 9.3 s - longest single wait: 1,006 ms -> 152 ms - copy-source buffers made: 19,324 -> 93 - scratch chunks made: 12,925 -> 2,462 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99096e6 to
924911f
Compare
|
@claudeFrancoisAI thanks, that's a clear result, and it fits what we see: on this PC the pressure is the commit limit's, not the memory's (64 GB, system-managed page file, ~20 GB free while Updated the branch (now on top of
If you have a moment for a rerun on your 16 GB machine: it should now match "PR reverted, trim to nothing as before" whenever less than 8 GB is free. If 8 GiB turns out to be the wrong line for you, the free-memory figure in your pressure warnings would tell us where it should sit. |
|
Thanks for the quick turn. The figures you asked for, from the same 16 GB machine (page file now fixed at 40 GB): The one pressure warning of a session comes at world load: physical_free_mib=3032, available_commit_mib=38320, spare_scratch_mib=126. Free physical memory sampled every 3 s during play: 1.1 to 2.5 GB in the prison dormitory, 0.3 to 1.6 GB in heavier scenes, and dips to 30 to 350 MB for a few seconds while a new scene loads. So with a line at 8 GiB of free memory this PC always takes the "all go" branch, and I expect 924911f to behave like main here. I will rerun it and post the numbers. A line that this machine could ever cross would have to sit near 2 GiB, and I would not trust that: the regression I measured (submitting thread waiting for flights 6.9 ms to 48 ms) appeared with 2 to 3 GB free. One more data point that may explain why kept spares hurt here: on this machine the scarce resource is not RAM or commit but the memory shared with the card (budget 7,517 MB, half the RAM, no Resizable BAR so every upload and shared buffer lives there). A scene load takes it from 5.3 to 7.8 GB in ten seconds. 128 MiB of spare upload chunks is counted in that budget too. If the trim could look at the shared budget (video_memory()'s third and fourth numbers) instead of free RAM, it would follow the thing that actually runs out on 16 GB PCs. |
|
The rerun, with two caveats first. It is a port, not 924911f itself. My tree is on an older base with a different shader translator, and moving it to 63b902f would mean rebuilding the whole shader cache, so I applied 924911f onto my base instead. What carried over: the pool of copy sources, keeps_under_pressure() with the 8 GiB line and residency::physical_free(), and both trims following it. What did not: the memory stack's low window (my base has no Spare::low), so those three lines are out. The scene is not the one from my first report. The save moved on, and the run now starts on the boat at the beginning of the next mission, so I measured there, on the same view for both builds (about 3,560 draws a frame). One run each, 90 to 100 seconds, medians of the 5-second lines. without the PR: 14.6 fps, 68.4 ms a frame, submitting thread 53.9 ms in its submissions, 5.2 ms of them waiting for flights So the regression is gone: the wait for flights that went from 6.9 to 48 ms with the first version stays at 5 to 6 ms, and the frame is within my run-to-run noise (about 0.3 fps). The run with the port also had 254 host pipelines being made in the background during the measurement, because the executable changed, so if anything it is the pessimistic side. Free memory was 1.2 to 2.3 GB in both, far under the 8 GiB line, so this PC took the "all go" branch the whole time, as intended. One thing to watch on 16 GB machines: the memory shared with the card (GPU Process Memory, Shared Usage, sampled every 3 s). In the measured scene 2,545 MB without the PR and 2,717 MB with the port. At the peak of the load, 3,381 MB without and 4,132 MB with. That is the pool of copy sources filling before the first trim. On this PC the budget is 7,517 MB and a heavier load already reaches 5.4 GB, so 750 MB more is affordable here, but on a card without spare room it is the kind of margin that decides whether the load survives. A smaller VICTORY_UPLOAD_POOL_MB default when the shared budget is small would cover it. |
Adapt upstream PR trustno1-coder#57 while releasing idle sources under host pressure and tracking allocations by the existing submission lifetime.

Two 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