Repository navigation
Sends: under host memory pressure the spares the frames use stay, memory past 256 MiB is never kept, and releases leave the submitting thread (a 32 GB PC made them again every second) - #3994
Open
Lyrnc wants to merge 3 commits into
Conversation
…and go on a thread of their own 158d317 trimmed the submissions' send spares to the 16 MiB hot floor at every sweep while the host memory is pressured. On a 32 GB PC with the title at ~31 GB private the pressure never clears (free RAM under 5 GB), and a frame sends ~46 MB (VICTORY_SEND_OWN), so the next frames made the 8-64 MiB upload buffers again, every second. Walking (RTX 5080, 9800X3D, Series X at 1440p) the trim took ~71 ms of the sweep each second, single sweeps 79-98 ms on the submitting thread; the card copies went from 3.4 to 6.6 ms a frame with the fresh buffers counted there, and page-ins were 2-4 times as many. - Send memory in use is counted by size class (doubles from 8 MiB): how many submissions hold now, and the most at once between sweeps (InUse; a Drop on Memory covers a plan given up). Each sweep, under pressure or not, send::tick() keeps those peaks for the last VICTORY_SEND_KEEP_SECONDS sweeps (10 by default). - Under ordinary pressure a trim keeps, of each class, as many spares as were in use at once in that window, then the smallest others up to the 16 MiB hot floor if that keeps more; what no frame of the window used goes. At critical commit all go, as before. The small host's cap (kept()) is unchanged. VICTORY_SEND_KEEP_SECONDS=0 is the floor alone, exactly the rule before (a test replays it). - What a trim or a give-back past kept() lets go is released outside the spares' lock on a thread of its own (victory-send-free), not on the submitting thread; in place if that thread cannot be made. - The sweep says what send memory was made and let go, when any was. Eight new tests in host::send, among them a model of five seconds of steady frames under pressure that never clears: nothing is made again after the first second, against the 32 and 16 MiB buffers made again every second with the floor alone. Not measured in game on this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e RAM, and made in 64 MiB steps past 64 MiB The bench on the first commit: the send-trim cost is gone and the send buffers made and let go fell to a handful in 5 minutes of a walk, but one sweep made 640 MiB at once in two buffers (by doubles, 512 and 128), and the spares then sat at ~656 MiB on a 32 GB PC that pages heavily: a burst's buffers were in use in the window, so they stayed for all of it. - What was in use is counted in the bytes the requests needed at once too, each at the size made for it (not the size of a bigger spare a small request took). A trim keeps within a line: all of what the last sweep needed (the working set, made again within a frame if it goes, so letting it go saves nothing; with two frames in the air, the busiest frame twice over), and of the window's busiest moment beyond that only kept() scaled by the share of 8 GiB of RAM that is free (the copy sources' keeps_under_pressure line); at least the hot floor. Past the line the biggest go first, in use or not. - Send memory past 64 MiB is made in 64 MiB steps, not by doubles: at most 64 MiB more than asked for (512 MiB for a request just past 256 before). A submission's sends stay in one buffer (shortcut: record, its scatter pass and the copy queue each address one). - The sweep's line also says the bytes needed at once. host::send: 15 passed, 1 ignored; among them a walk with two frames in the air and a burst of 300 + 100 MB: 320 + 128 MiB made, kept one sweep, then 184 MiB with 2 GiB free (504 with 16), 56 once the window passed, nothing made again. Not run in game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st 256 MiB is never kept The bench on 1ecaa98: with 0.1-0.8 GB of RAM free in play on the 32 GB PC the free-RAM-scaled part of the line was ~0, so all that stayed was what the last sweep needed at once (128-144 MiB) while the spares the frames use were 168-232 MiB: 524 buffers made and 522 let go in 300 s (19.5 GiB each way) against 7 and 6 on 697590a, card copies 3.4 to 5.0 ms, fps 23.1 to 22.6, frames over 100 ms 36 to 41. - Whatever RAM is free, of each class as many spares stay as were in use at once in the window (a class shrinks only when it went unused for all of it), and at least what the window's busiest moment needed at once less what is in use at the sweep, or the hot floor. Only spares beyond that are held to kept() scaled by the free RAM. - Send memory past 256 MiB is made at its own size (64 KiB steps) and let go as soon as its submission has run, not kept nor counted in what was in use: at load one of 2112 MiB was made and dropped by a sweep. From 64 to 256 MiB, 64 MiB steps as before. host::send: a walk whose sends move across sizes, three frames in the air, with 0, 0.5 and 16 GiB free: 13 made in the first second, none after (the rule of 1ecaa98, modelled the same way, made one again every second with 224 MiB of spares). Not run in game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Shootout, final (2 runs per arm): RTX 5080 + 9800X3D, 32 GB, vnv 829188e + #3347, walking, Series X native 1440p, DLSS off, world +30..330 s. Every arm has the same local per-step sweep timing.
AI use: Claude Code (Claude Opus 5.5). |
stasadance
added a commit
to stasadance/VIctory-NVIDIA
that referenced
this pull request
Nov 30, 2026
…ast 256 MiB is never kept, and releases go to the bury thread (upstream trustno1-coder#3994) Since 158d317 send::trim() cut the submissions' send spares to the 16 MiB hot floor at every sweep under host memory pressure. On a 32 GB PC with the title at ~31 GB private the pressure never clears, and a frame sends ~46 MB, so the next frames made the 8-64 MiB upload buffers again every second: ~71 ms of the sweep, card copies 3.4 -> 6.6 ms a frame, page-ins 2-4x. Upstream (RTX 5080, walking): fps 21.5 -> 23.3, longest frame 723 -> 224 ms. Ported from upstream trustno1-coder#3994 (Lyrnc: 697590a, 1ecaa98, 8b80173), as its tip: - Send memory in use is counted by size class (doubles from 8 MiB), with the bytes needed at once (InUse; a Drop on Memory covers a plan given up). send::tick() runs at every sweep (in sweep_parts, so on the victory-sweep thread when the sweep runs beside) and keeps the last VICTORY_SEND_KEEP_SECONDS sweeps (10 by default; 0 = the hot floor alone, the rule of 158d317). - Under ordinary pressure a trim keeps, whatever RAM is free, of each class as many spares as were in use at once in the window, and at least the window's busiest need less what is in use (or the hot floor); only spares beyond that are held to kept() scaled by the share of 8 GiB of RAM free. Critical commit lets all go, as before. - Send memory is made by doubles to 64 MiB, in 64 MiB steps to 256 MiB, and past 256 MiB at its own size (64 KiB steps), let go as soon as its submission has run and never kept. - The sweep logs what send memory was made and let go, when any was. Adapted to this branch: - Releases: upstream starts a victory-send-free thread of its own. Here let_go() hands them to super::release_apart (the trustno1-coder#3951 port, 7c30f85), so they drop on victory-bury with the sweep's other trims; one release thread, and VICTORY_RELEASE_APART=0 drops them in place for both. give_back's lets-go (past kept(), past 256 MiB) now go there too. - Replaces this branch's send-pool low-water trim (SparePool, 96cf1b1) and made_size (ceaad09, "past what is kept at its own size") with trustno1-coder#3994's window and made_for. The 4 GiB upload-buffer note moves to made_for. On a small host (kept() 64/128 MiB) memory from 128 to 256 MiB is now made in 64 MiB steps rather than at its own size, and still let go by give_back as soon as it comes back. - memory() takes a spare with remove, not swap_remove (the order fix of the trustno1-coder#3947 port); give_back's cap now evicts the biggest first, as upstream. - The made_size test is replaced by upstream's twelve.
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a 32 GB PC, walking got much slower after 158d317. Measured on an RTX 5080 + 9800X3D, Series X at 1440p, walking:
send::trim()takes ~71 ms of the sweep every second. Single sweeps take 79-98 ms, and they run on the submitting thread.A bench-only check, where
trim()returns early unlesscritical_commit()holds, gave:That check is not this branch (see "Verification" and "Not tested").
Root cause
158d317 ("Small hosts of RAM: the L0 caches of ours sized down…", 2026-11-28) added
send::trim()to the once-a-second sweep. It runs wheneverresidency::pressured()holds: free RAM under 5 GB, or commit under 6 GB.VICTORY_SEND_OWN), so the next frames make the 8-64 MiB upload buffers again: a fresh map, zeroed pages, and later another release.Letting go of buffers the next frames make again saves no memory at the frame's peak, however little RAM is free. It only adds the cost of making and releasing them every second.
Fix
All in
crates/victory-gpu/src/host/send.rs, plus one line in the sweep inhost.rsand adocs/bug-journal.mdentry.InUsecounts, per class, how many buffers submissions hold now and the most they held at once since the last sweep.memory()lends a buffer andgive_back()returns it. ADroponMemorycovers a plan given up without coming back.send::tick()pushes this into a window of the lastVICTORY_SEND_KEEP_SECONDSsweeps (10 by default, once a second).trim_line+staying, both pure):kept()(the host cap) scaled by the share of 8 GiB of RAM that is free. That is the line the copy sources' spares use too (keeps_under_pressure): 768 MiB with 8 GiB free, 0 with none.critical_commit(), under 1.5 GiB) everything goes, as before.VICTORY_SEND_KEEP_SECONDS=0gives exactly the old rule: the hot floor alone. A test checks that, so the bench can A/B in one build.kept(), or past 256 MiB) lets go is passed, outside the spares' lock, tovictory-send-free, a thread started on first use that only drops them. If that thread cannot be started, they are dropped in place as before.spare_trim_to, 16 GB RAM regression on 923e38c: 8 GiB WDDM L0 Shared GPU Memory exhausted in ~95s (CommandList::Close 0x8007000E) + VICTORY_WINDOWS_BAR_MB auto-config dropped #1520 / PR Host lists: pool the copy sources; memory pressure trims spares down to 128 MiB instead of to nothing #57) keep a fixed one: 16 MiB, orSPARE_MOSTwith 8 GiB of RAM free. That works for 4 MiB scratch chunks. A frame's sends are ~46 MB in buffers of up to 64 MiB, so any fixed floor small enough for a 16 GB PC is too small for the working set.kept()(128 MiB on a small host, 768 MiB on a large one) is unchanged.made,made_mib,let_go,let_go_mib,spare_mibandneeded_at_once_mib.Own::record, its scatter pass and the copy queue's copy ofOwn::source(upq) each address one buffer, so the split would change the path the card reads its bytes from. That is not done here; it is markedshortcut:atmade_for. With memory past 256 MiB never kept, the slack only matters below 256 MiB, where it is under 64 MiB.fit(the least spare that holds a request) andmade_for.Verification
Our bench, walking in-world on the 32 GB PC (RTX 5080, Series X 1440p), 300 s each:
needed_at_oncewas 128-144 MiB against 168-232 MiB of spares, so each sweep made 2-5 buffers and let 1-4 go.The tip (8b80173), measured in game on the same 32 GB PC, walking, Series X native 1440p, DLSS off, world +30..330 s:
let_go_idle(2 runs)Largest kept spare in those runs: 464-504 MiB;
needed_at_once184-192 MiB. With the camera turning (standing, steady turn), this alone takes the turn from ~15 to 17.8 fps and card copies from 12.5 to 6.3 ms.Side by side with the other open fixes for the same churn (on vnv 829188e + #3347, walk, first round of two; one run each, so noisy):
All three remove most of the churn. #3381 had the better fps in this round; this branch is the only one that takes the send trim to zero and frees off the submitting thread. The second round is running; I'll add it here. If #3381 holds its lead, merging it and keeping this branch's per-size window and off-thread release on top would be the combination to consider.
Windows 11, MSVC, own target dir,
-j 6, on 8b80173:cargo check -p victory-gpu --locked: passes. None of its warnings are inhost/send.rsor at the sweep line inhost.rs.cargo test -p victory-gpu --lib --locked -- host::send::: 15 passed, 0 failed, 1 ignored (the existing GPU scatter test). The 12 new tests:with_no_ram_free_a_walk_whose_sends_move_makes_nothing_after_its_first_second. This is the bench's case: a model ofmemory(),give_back()(with its cap),tick()andtrim()over 7 seconds of 20 frames, three frames in the air.under_pressure_that_never_clears_a_steady_frame_makes_nothing_again: steady 30 + 12 + 4 MB frames, with one and two in the air, 16 GiB or no RAM free. Nothing is made after the first second. The old rule makes 2 again every second.a_bursts_buffers_go_with_the_window_or_at_once_past_256_mib: one frame also sends 300 + 100 MB.the_trim_line_keeps_what_the_window_used_and_scales_only_the_rest_by_free_ram:roomat 0, 2, 8 and 32 GiB free. The in-use counts and the need floor are the same whatever RAM is free. Nothing seen gives the hot floor; critical commit gives nothing.a_trim_keeps_what_was_in_use_lately_whatever_ram_is_free: classes kept, the need fill, and the room fill.critical_commit_lets_every_spare_go_and_free_ram_governs_only_the_rest.with_nothing_in_use_lately_a_trim_is_the_hot_floor_of_158d3177: with an empty window the result equals the old rule on five pools.send_memory_classes_are_doubles_from_8_mib,send_memory_is_made_by_doubles_then_in_steps_then_at_its_own_size,in_use_counts_the_most_at_once_between_sweeps,the_window_wants_the_most_of_each_class_in_its_sweeps,what_a_scene_left_behind_goes_once_the_window_has_passed.cargo clippy -p victory-gpu --all-targets --locked: passes. Its warnings are all in code this branch does not touch, none on a line it adds or changes.-D warningswas not used, because main already fails it elsewhere.git merge-tree).NOT tested
kept()(768 MiB).roomand the 256 MiB line are choices, not measurements.kept()cap, critical commit and the scaled part beyond what is used are as described. Whether keeping the working set under pressure moves anything toward the 8 GiB shared cap of 16 GB RAM regression on 923e38c: 8 GiB WDDM L0 Shared GPU Memory exhausted in ~95s (CommandList::Close 0x8007000E) + VICTORY_WINDOWS_BAR_MB auto-config dropped #1520 was not measured.host::send::tests were run. The rest of thevictory-gpulib suite was not, and neither wascargo xtask policy(the change is.rsand.mdonly).victory-send-freewhile the submitting thread makes new upload buffers still contends in the driver was not measured.Overlap
Open PRs found by title and by touching
host/send.rs(searched: send, trim, spare, send own, L0, upload buffers, 158d317):trim,memoryandgive_back.Mapof new buffers and in releasing them.trim,Memoryandgive_back.VICTORY_SEND_KEEP=1after RTX 5060 Ti: heap writes in pieces, Reflex's sleep off the submitting thread, send spares kept under pressure, launcher folding first #3411's idea, plus churn stats. It conflicts intrim.kept(), and the buffer can then still be pooled. Textual conflict: theirmade_size(size, kept)against ourmade_for.on_card/kept/ a spare-bytes reader insend.rs. Small textual conflicts at most, no overlap in what they change.AI use
Claude Code (Claude Opus 5.5) wrote the change, its tests and this description from our bench's measurements and a reading of 158d317, #1520 / PR #57 (
spare_trim_to's floor) and the overlapping PRs. The numbers in "Problem" and the bench rows in "Verification" come from our bench runs, not from the model.🤖 Generated with Claude Code