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

Manually merged
github merged 3 commits from github-bot/gh-3994 into main 2026-11-30 16:33:27 +00:00 AGit
Owner

@⁠Lyrnc on GitHub · 2026-11-30 14:01 UTC · original
Lyrnc:perf/send-trim-floor → main · +737 −33 · 3 files · 3 commits · merged 2026-11-30 16:28 UTC

Problem

On a 32 GB PC, walking got much slower after 158d3177. 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.
  • Card copies go from 3.4 to 6.6 ms a frame, because the send buffers that are made again are counted there.
  • Page-ins are 2-4 times as many.

A bench-only check, where trim() returns early unless critical_commit() holds, gave:

main trim only at critical commit
fps 21.5 23.3
frames over 100 ms, per 1,000 42 35
longest frame 723 ms 224 ms
card copies, per frame 6.6 ms 3.4 ms
page-ins, per second 7.9k 2.5k

That check is not this branch (see "Verification" and "Not tested").

Root cause

158d3177 ("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 whenever residency::pressured() holds: free RAM under 5 GB, or commit under 6 GB.

  • The pressure never clears. With the title at ~31 GB private, a 32 GB PC is under pressure all the time. Play leaves 0.1-0.8 GB of RAM free.
  • The trim drops the working set. Each sweep cuts the submissions' send spares down to the 16 MiB hot floor. A frame sends ~46 MB (VICTORY_SEND_OWN), so the next frames make the 8-64 MiB upload buffers again: a fresh map, zeroed pages, and later another release.
  • The release is slow, and blocks the submitting thread. The sweep runs there, and the old trim also dropped the buffers while it held the spares' lock.
  • The biggest go first. The pool is sorted biggest first and trimmed from the front, so the spare left at the floor is never the one the next large submission needs.

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 in host.rs and a docs/bug-journal.md entry.

  • What was in use lately, counted per size class. Send memory comes in 10 size classes (doubles from 8 MiB up to 2 GiB, and one for larger).
    • InUse counts, per class, how many buffers submissions hold now and the most they held at once since the last sweep.
    • It also counts the bytes those requests needed at once, each at the size it would be made at. That is not the size of a bigger spare a small request took.
    • It records the bytes in use at the sweep.
    • memory() lends a buffer and give_back() returns it. A Drop on Memory covers a plan given up without coming back.
    • Every sweep, under pressure or not, send::tick() pushes this into a window of the last VICTORY_SEND_KEEP_SECONDS sweeps (10 by default, once a second).
  • What stays under ordinary pressure (trim_line + staying, both pure):
    1. Whatever RAM is free, each class keeps as many spares as were in use at once in the window, so a class shrinks only when it went unused for the whole window.
    2. Also whatever RAM is free, the spares are at least the window's largest need-at-once, less what is in use at the sweep (filled with the smallest others), or the 16 MiB hot floor.
    3. Only spares beyond that are held to 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.
    • At critical commit (critical_commit(), under 1.5 GiB) everything goes, as before.
    • VICTORY_SEND_KEEP_SECONDS=0 gives exactly the old rule: the hot floor alone. A test checks that, so the bench can A/B in one build.
  • Memory past 256 MiB is never kept. A world load's sends (one submission of 2112 MiB) are made at their own size in 64 KiB steps, let go as soon as their submission has run, and not counted in what was in use. By doubles such a request was made at 4 GiB, which one upload buffer may not be. From 64 to 256 MiB, memory is made in 64 MiB steps, not by doubles.
  • Released off the submitting thread. What a trim or a give-back (over kept(), or past 256 MiB) lets go is passed, outside the spares' lock, to victory-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.
  • Why not a fixed floor, or one scaled by free RAM.
    • The copy sources' spares (spare_trim_to, #1520 / PR #57) keep a fixed one: 16 MiB, or SPARE_MOST with 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.
    • Scaling everything kept by free RAM was tried (1ecaa98a). With 0.1-0.8 GB free it trimmed the working set every sweep and the churn came back (see "Verification").
  • The 158d3177 / #1520 intent is kept.
    • The cap of kept() (128 MiB on a small host, 768 MiB on a large one) is unchanged.
    • Critical commit still empties the pool.
    • Spares no frame used for 10 s go, and so do spares beyond the working set when RAM is short.
    • Load-sized buffers are never kept.
  • A log line at the sweep, only when something was made or let go: "submission send memory since the last sweep", with made, made_mib, let_go, let_go_mib, spare_mib and needed_at_once_mib.
  • One buffer per submission is kept. Splitting a submission's sends over buffers of at most 64 MiB each would bound them to one step. But Own::record, its scatter pass and the copy queue's copy of Own::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 marked shortcut: at made_for. With memory past 256 MiB never kept, the slack only matters below 256 MiB, where it is under 64 MiB.
  • Two small refactors make the decision testable: fit (the least spare that holds a request) and made_for.

Verification

Our bench, walking in-world on the 32 GB PC (RTX 5080, Series X 1440p), 300 s each:

697590ad (by use, no RAM line) 1ecaa98a (everything held to the RAM-scaled line)
send buffers made / let go 7 / 6 524 / 522 (19.5 GiB each way)
card copies, per frame 3.4 ms 5.0 ms
fps 23.1 22.6
frames over 100 ms (per 1,000) 36 41
  • On 697590ad the send-trim cost was gone. But one sweep made 640 MiB at once in two buffers, and the spares then stayed at ~656 MiB on a PC that pages heavily. 1ecaa98a was meant for that, but brought the churn back.
  • On 1ecaa98a, needed_at_once was 128-144 MiB against 168-232 MiB of spares, so each sweep made 2-5 buffers and let 1-4 go.
  • 8b801739 has the in-use rule of 697590ad (regardless of RAM), plus the need floor, the RAM-scaled part for spares beyond those, and no keeping past 256 MiB. It is measured in game below.

The tip (8b801739), measured in game on the same 32 GB PC, walking, Series X native 1440p, DLSS off, world +30..330 s:

build fps >100 ms per 1,000 sweep: send trim send buffers made / let go in 300 s card copies
our fork's main (has 158d3177) 21.3 / 22.0 43.9 / 41.1 80-83 ms per sweep (every second) 7.3 / 6.9 ms
that main + sweep spreading + this + #3272's let_go_idle (2 runs) 23.8 / 24.1 10.9 / 10.2 0.1-0.2 ms 3 / 1 and 2 / 1 3.5 ms

Largest kept spare in those runs: 464-504 MiB; needed_at_once 184-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 829188e9 + #3347, walk, first round of two; one run each, so noisy):

arm fps >100 ms per 1,000 send trim per sweep card copies
base 19.5 55.4 68.0 ms 10.6 ms
this (8b801739) 20.3 52.1 0.0 ms 6.1 ms
#3381 21.7 35.0 9.3 ms 6.3 ms
#3411 20.2 52.5 4.9 ms 6.3 ms

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 8b801739:

  • cargo check -p victory-gpu --locked: passes. None of its warnings are in host/send.rs or at the sweep line in host.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 of memory(), give_back() (with its cap), tick() and trim() over 7 seconds of 20 frames, three frames in the air.
      • Each submission's send moves across the sizes made, frame to frame (34 MB takes 64 MiB, 9 MB takes 16 MiB), and one frame in five also sends 66 MB.
      • With 0, 0.5 and 16 GiB free: 13 buffers made in the first second and none after, with 352 MiB of spares.
      • With the hot floor alone, 4 are made again every second.
      • 1ecaa98a's rule, modelled the same way (outside the suite), made one again every second with 224 MiB of spares, close to the bench's 168-232.
    • 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 300 MB buffer is made at its own size and never kept.
      • The 128 MiB one stays while its class was in use in the window. With no RAM free it then goes; with room, it stays.
      • A load's 2112 MiB is made once and never kept.
    • the_trim_line_keeps_what_the_window_used_and_scales_only_the_rest_by_free_ram: room at 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.
    • Also: 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 warnings was not used, because main already fails it elsewhere.
  • The branch merges cleanly with vnv/main 41adb551 (git merge-tree).

NOT tested

  • The shootout's second round (results above are round one). The numbers above for the two earlier commits only.
  • The spares the tip keeps were not measured in game. In the model they are 352 MiB with three frames in the air and sends that move across sizes. In play they are bounded by kept() (768 MiB).
  • The 10-sweep window, the 8 GiB line of room and the 256 MiB line are choices, not measurements.
  • Not run on a 16 GB PC. The 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 #1520 was not measured.
  • Only the host::send:: tests were run. The rest of the victory-gpu lib suite was not, and neither was cargo xtask policy (the change is .rs and .md only).
  • Release timing on the free thread. Whether releasing on victory-send-free while 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, 158d3177):

  • #3381 (Maverick0351a, "host, send, uav_pool: trim only unborrowed low-water spare pools at 1 Hz sweep"). Same problem, different rule:
    • It keeps a low-water mark of the pool's bytes since the last sweep and lets the never-borrowed surplus above the floor go.
    • Its window is one sweep and it is not by size: a buffer unused for one second goes, though the next busy frame may want it.
    • It does not treat load-sized buffers apart.
    • It releases outside the lock, but still on the submitting thread.
    • It also changes the copy-source and UAV pools.
    • Conflicts with this branch in trim, memory and give_back.
  • #3411 (dragoso, "RTX 5060 Ti: … send spares kept under pressure …", bundled with other changes). Same idea:
    • Spares not given back since the sweep before go, down to the floor. Also a one-second window, not by size.
    • It drops them inside the lock, on the submitting thread.
    • Their profile, at 20 GB of title on a 32 GB PC, shows the same thing: 8-9 ms a frame of the submitting thread in Map of new buffers and in releasing them.
    • Conflicts in trim, Memory and give_back.
  • #3650 (happyrain01, a large bundle) adds an opt-in VICTORY_SEND_KEEP=1 after #3411's idea, plus churn stats. It conflicts in trim.
  • #3729 (HQasper, "a submission's memory past what is kept is made at its own size", for a 4 GiB upload refused at world load). Overlaps in effect: here memory past 256 MiB is made at its own size, and never kept. Theirs does it past kept(), and the buffer can then still be pooled. Textual conflict: their made_size(size, kept) against our made_for.
  • #3791, #3426, #3500 touch on_card / kept / a spare-bytes reader in send.rs. Small textual conflicts at most, no overlap in what they change.
  • No open PR keeps the spares by recent use per size regardless of free RAM, uses a window longer than one sweep, keeps load-sized buffers out of the pool, or releases them off the submitting thread.

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 158d3177, #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

**@⁠Lyrnc** on GitHub · 2026-11-30 14:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3994) `Lyrnc:perf/send-trim-floor` → `main` · +737 −33 · 3 files · 3 commits · merged 2026-11-30 16:28 UTC ## Problem On a 32 GB PC, walking got much slower after 158d3177. 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. - Card copies go from 3.4 to 6.6 ms a frame, because the send buffers that are made again are counted there. - Page-ins are 2-4 times as many. A bench-only check, where `trim()` returns early unless `critical_commit()` holds, gave: | | main | trim only at critical commit | |---|---|---| | fps | 21.5 | 23.3 | | frames over 100 ms, per 1,000 | 42 | 35 | | longest frame | 723 ms | 224 ms | | card copies, per frame | 6.6 ms | 3.4 ms | | page-ins, per second | 7.9k | 2.5k | That check is not this branch (see "Verification" and "Not tested"). ## Root cause 158d3177 ("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 whenever `residency::pressured()` holds: free RAM under 5 GB, or commit under 6 GB. - **The pressure never clears.** With the title at ~31 GB private, a 32 GB PC is under pressure all the time. Play leaves 0.1-0.8 GB of RAM free. - **The trim drops the working set.** Each sweep cuts the submissions' send spares down to the 16 MiB hot floor. A frame sends ~46 MB (`VICTORY_SEND_OWN`), so the next frames make the 8-64 MiB upload buffers again: a fresh map, zeroed pages, and later another release. - **The release is slow, and blocks the submitting thread.** The sweep runs there, and the old trim also dropped the buffers while it held the spares' lock. - **The biggest go first.** The pool is sorted biggest first and trimmed from the front, so the spare left at the floor is never the one the next large submission needs. 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 in `host.rs` and a `docs/bug-journal.md` entry. - **What was in use lately, counted per size class.** Send memory comes in 10 size classes (doubles from 8 MiB up to 2 GiB, and one for larger). - `InUse` counts, per class, how many buffers submissions hold now and the most they held at once since the last sweep. - It also counts the bytes those requests needed at once, each at the size it would be made at. That is not the size of a bigger spare a small request took. - It records the bytes in use at the sweep. - `memory()` lends a buffer and `give_back()` returns it. A `Drop` on `Memory` covers a plan given up without coming back. - Every sweep, under pressure or not, `send::tick()` pushes this into a window of the last `VICTORY_SEND_KEEP_SECONDS` sweeps (10 by default, once a second). - **What stays under ordinary pressure** (`trim_line` + `staying`, both pure): 1. **Whatever RAM is free,** each class keeps as many spares as were in use at once in the window, so a class shrinks only when it went unused for the whole window. 2. **Also whatever RAM is free,** the spares are at least the window's largest need-at-once, less what is in use at the sweep (filled with the smallest others), or the 16 MiB hot floor. 3. **Only spares beyond that** are held to `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. - At critical commit (`critical_commit()`, under 1.5 GiB) everything goes, as before. - `VICTORY_SEND_KEEP_SECONDS=0` gives exactly the old rule: the hot floor alone. A test checks that, so the bench can A/B in one build. - **Memory past 256 MiB is never kept.** A world load's sends (one submission of 2112 MiB) are made at their own size in 64 KiB steps, let go as soon as their submission has run, and not counted in what was in use. By doubles such a request was made at 4 GiB, which one upload buffer may not be. From 64 to 256 MiB, memory is made in 64 MiB steps, not by doubles. - **Released off the submitting thread.** What a trim or a give-back (over `kept()`, or past 256 MiB) lets go is passed, outside the spares' lock, to `victory-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. - **Why not a fixed floor, or one scaled by free RAM.** - The copy sources' spares (`spare_trim_to`, #1520 / PR #57) keep a fixed one: 16 MiB, or `SPARE_MOST` with 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. - Scaling everything kept by free RAM was tried (1ecaa98a). With 0.1-0.8 GB free it trimmed the working set every sweep and the churn came back (see "Verification"). - **The 158d3177 / #1520 intent is kept.** - The cap of `kept()` (128 MiB on a small host, 768 MiB on a large one) is unchanged. - Critical commit still empties the pool. - Spares no frame used for 10 s go, and so do spares beyond the working set when RAM is short. - Load-sized buffers are never kept. - **A log line at the sweep, only when something was made or let go:** "submission send memory since the last sweep", with `made`, `made_mib`, `let_go`, `let_go_mib`, `spare_mib` and `needed_at_once_mib`. - **One buffer per submission is kept.** Splitting a submission's sends over buffers of at most 64 MiB each would bound them to one step. But `Own::record`, its scatter pass and the copy queue's copy of `Own::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 marked `shortcut:` at `made_for`. With memory past 256 MiB never kept, the slack only matters below 256 MiB, where it is under 64 MiB. - **Two small refactors** make the decision testable: `fit` (the least spare that holds a request) and `made_for`. ## Verification **Our bench, walking in-world on the 32 GB PC (RTX 5080, Series X 1440p), 300 s each:** | | 697590ad (by use, no RAM line) | 1ecaa98a (everything held to the RAM-scaled line) | |---|---|---| | send buffers made / let go | 7 / 6 | 524 / 522 (19.5 GiB each way) | | card copies, per frame | 3.4 ms | 5.0 ms | | fps | 23.1 | 22.6 | | frames over 100 ms (per 1,000) | 36 | 41 | - On 697590ad the send-trim cost was gone. But one sweep made 640 MiB at once in two buffers, and the spares then stayed at ~656 MiB on a PC that pages heavily. 1ecaa98a was meant for that, but brought the churn back. - On 1ecaa98a, `needed_at_once` was 128-144 MiB against 168-232 MiB of spares, so each sweep made 2-5 buffers and let 1-4 go. - 8b801739 has the in-use rule of 697590ad (regardless of RAM), plus the need floor, the RAM-scaled part for spares beyond those, and no keeping past 256 MiB. It is measured in game below. **The tip (8b801739), measured in game on the same 32 GB PC**, walking, Series X native 1440p, DLSS off, world +30..330 s: | build | fps | >100 ms per 1,000 | sweep: send trim | send buffers made / let go in 300 s | card copies | |---|---:|---:|---:|---:|---:| | our fork's main (has 158d3177) | 21.3 / 22.0 | 43.9 / 41.1 | 80-83 ms per sweep | (every second) | 7.3 / 6.9 ms | | that main + sweep spreading + this + #3272's `let_go_idle` (2 runs) | **23.8 / 24.1** | **10.9 / 10.2** | **0.1-0.2 ms** | 3 / 1 and 2 / 1 | 3.5 ms | Largest kept spare in those runs: 464-504 MiB; `needed_at_once` 184-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 829188e9 + #3347, walk, first round of two; one run each, so noisy): | arm | fps | >100 ms per 1,000 | send trim per sweep | card copies | |---|---:|---:|---:|---:| | base | 19.5 | 55.4 | 68.0 ms | 10.6 ms | | this (8b801739) | 20.3 | 52.1 | **0.0 ms** | 6.1 ms | | #3381 | **21.7** | **35.0** | 9.3 ms | 6.3 ms | | #3411 | 20.2 | 52.5 | 4.9 ms | 6.3 ms | 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 8b801739: - `cargo check -p victory-gpu --locked`: passes. None of its warnings are in `host/send.rs` or at the sweep line in `host.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 of `memory()`, `give_back()` (with its cap), `tick()` and `trim()` over 7 seconds of 20 frames, three frames in the air. - Each submission's send moves across the sizes made, frame to frame (34 MB takes 64 MiB, 9 MB takes 16 MiB), and one frame in five also sends 66 MB. - With 0, 0.5 and 16 GiB free: 13 buffers made in the first second and none after, with 352 MiB of spares. - With the hot floor alone, 4 are made again every second. - 1ecaa98a's rule, modelled the same way (outside the suite), made one again every second with 224 MiB of spares, close to the bench's 168-232. - `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 300 MB buffer is made at its own size and never kept. - The 128 MiB one stays while its class was in use in the window. With no RAM free it then goes; with room, it stays. - A load's 2112 MiB is made once and never kept. - `the_trim_line_keeps_what_the_window_used_and_scales_only_the_rest_by_free_ram`: `room` at 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. - Also: `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 warnings` was not used, because main already fails it elsewhere. - The branch merges cleanly with vnv/main 41adb551 (`git merge-tree`). ## NOT tested - **The shootout's second round** (results above are round one). The numbers above for the two earlier commits only. - **The spares the tip keeps were not measured in game.** In the model they are 352 MiB with three frames in the air and sends that move across sizes. In play they are bounded by `kept()` (768 MiB). - **The 10-sweep window, the 8 GiB line of `room` and the 256 MiB line are choices, not measurements.** - **Not run on a 16 GB PC.** The `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 #1520 was not measured. - **Only the `host::send::` tests were run.** The rest of the `victory-gpu` lib suite was not, and neither was `cargo xtask policy` (the change is `.rs` and `.md` only). - **Release timing on the free thread.** Whether releasing on `victory-send-free` while 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, 158d3177): - **#3381** (Maverick0351a, "host, send, uav_pool: trim only unborrowed low-water spare pools at 1 Hz sweep"). Same problem, different rule: - It keeps a low-water mark of the pool's bytes since the last sweep and lets the never-borrowed surplus above the floor go. - Its window is one sweep and it is not by size: a buffer unused for one second goes, though the next busy frame may want it. - It does not treat load-sized buffers apart. - It releases outside the lock, but still on the submitting thread. - It also changes the copy-source and UAV pools. - Conflicts with this branch in `trim`, `memory` and `give_back`. - **#3411** (dragoso, "RTX 5060 Ti: … send spares kept under pressure …", bundled with other changes). Same idea: - Spares not given back since the sweep before go, down to the floor. Also a one-second window, not by size. - It drops them inside the lock, on the submitting thread. - Their profile, at 20 GB of title on a 32 GB PC, shows the same thing: 8-9 ms a frame of the submitting thread in `Map` of new buffers and in releasing them. - Conflicts in `trim`, `Memory` and `give_back`. - **#3650** (happyrain01, a large bundle) adds an opt-in `VICTORY_SEND_KEEP=1` after #3411's idea, plus churn stats. It conflicts in `trim`. - **#3729** (HQasper, "a submission's memory past what is kept is made at its own size", for a 4 GiB upload refused at world load). Overlaps in effect: here memory past 256 MiB is made at its own size, and never kept. Theirs does it past `kept()`, and the buffer can then still be pooled. Textual conflict: their `made_size(size, kept)` against our `made_for`. - **#3791, #3426, #3500** touch `on_card` / `kept` / a spare-bytes reader in `send.rs`. Small textual conflicts at most, no overlap in what they change. - No open PR keeps the spares by recent use per size regardless of free RAM, uses a window longer than one sweep, keeps load-sized buffers out of the pool, or releases them off the submitting thread. ## 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 158d3177, #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](https://claude.com/claude-code)
158d3177 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 <[email protected]>
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 <[email protected]>
The bench on 1ecaa98a: 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 697590ad, 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 1ecaa98a, 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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 14:02:43 +00:00
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-30 14:13 UTC · original

Shootout, final (2 runs per arm): RTX 5080 + 9800X3D, 32 GB, vnv 829188e9 + #3347, walking, Series X native 1440p, DLSS off, world +30..330 s. Every arm has the same local per-step sweep timing.

arm fps (2 runs) >100 ms per 1,000 send trim per sweep (submitting thread) card copies send buffers made / let go in 300 s largest kept spare
base 19.5 / 19.7 55.4 / 51.6 68.0 / 73.5 ms 10.6 / 10.0 ms (every second) n/a
#3994 (8b801739) 20.3 / 21.4 52.1 / 39.0 0.0 / 0.0 ms 6.1 / 6.2 ms 6/4, 7/4 416–480 MiB
#3381 21.7 / 20.1 35.0 / 46.3 9.3 / 9.2 ms 6.3 / 6.5 ms n/a n/a
#3411 (bundle) 20.2 / 20.8 52.5 / 45.4 4.9 / 4.9 ms 6.3 / 6.1 ms n/a n/a
  • Means: base 19.6 fps; #3994 20.9, #3381 20.9, #3411 20.5. Frames over 100 ms: 53.5 → 45.6 / 40.7 / 49.0.
  • The churn: all three remove it. Card copies drop from ~10.3 to ~6.2 ms, and heaps+sweep from 8.2 to 3.6–4.5 ms. No new stalls in any arm.
  • Where they differ: #3994 is the only one that leaves 0 ms of send trim on the submitting thread, since releases go to their own thread. #3381 still trims about 9 ms per sweep there. The fps differences are within run noise.
  • What none of them touches: the rest of the sweep, the resource let-go looks at 47–60 ms per sweep. #3272 takes care of those.

AI use: Claude Code (Claude Opus 5.5).

**@⁠Lyrnc** on GitHub · 2026-11-30 14:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3994#issuecomment-7281024351) **Shootout, final (2 runs per arm)**: RTX 5080 + 9800X3D, **32 GB**, vnv 829188e9 + #3347, walking, Series X native 1440p, DLSS off, world +30..330 s. Every arm has the same local per-step sweep timing. | arm | fps (2 runs) | >100 ms per 1,000 | send trim per sweep (submitting thread) | card copies | send buffers made / let go in 300 s | largest kept spare | |---|---:|---:|---:|---:|---:|---:| | base | 19.5 / 19.7 | 55.4 / 51.6 | 68.0 / 73.5 ms | 10.6 / 10.0 ms | (every second) | n/a | | #3994 (8b801739) | 20.3 / 21.4 | 52.1 / 39.0 | **0.0 / 0.0 ms** | 6.1 / 6.2 ms | 6/4, 7/4 | 416–480 MiB | | #3381 | 21.7 / 20.1 | 35.0 / 46.3 | 9.3 / 9.2 ms | 6.3 / 6.5 ms | n/a | n/a | | #3411 (bundle) | 20.2 / 20.8 | 52.5 / 45.4 | 4.9 / 4.9 ms | 6.3 / 6.1 ms | n/a | n/a | - **Means:** base 19.6 fps; #3994 20.9, #3381 20.9, #3411 20.5. Frames over 100 ms: 53.5 → 45.6 / 40.7 / 49.0. - **The churn:** all three remove it. Card copies drop from ~10.3 to ~6.2 ms, and heaps+sweep from 8.2 to 3.6–4.5 ms. No new stalls in any arm. - **Where they differ:** #3994 is the only one that leaves 0 ms of send trim on the submitting thread, since releases go to their own thread. #3381 still trims about 9 ms per sweep there. The fps differences are within run noise. - **What none of them touches:** the rest of the sweep, the resource let-go looks at 47–60 ms per sweep. #3272 takes care of those. AI use: Claude Code (Claude Opus 5.5).
github manually merged commit 0c8c2092a5 into main 2026-11-30 16:33:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3994
No description provided.