Windows of title memory that grow from what is asked for, instead of 4 MiB each (VICTORY_WINDOW_GROW=1, off by default): windows 1.4-1.5 GB smaller #477

Merged
wildheathen merged 5 commits from upstream-pr/477 into main 2026-11-29 08:16:59 +00:00
wildheathen commented 2026-11-27 23:13:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wildheathen on 2026-11-27T23:13:50Z.


What this changes

A read of title memory outside the known buffers gets a host copy, a "window". Today each window is a 4 MiB host buffer on the 4 MiB grid, whatever is read in it, and all of it is resident. On my machine, at the end of a three-minute run, 727 windows held 3,100 MB, while what was read in them lay within about 1,700 MB.

The finer grid that is already in main (VICTORY_WINDOW_KB=256 VICTORY_WINDOW_TAILS=1) saved nothing here: 3,060 MB of windows over 1,746 MB of title memory. The descriptor slots made on the shorter windows kept those windows alive beside the longer ones made later for the same memory.

With VICTORY_WINDOW_GROW=1, each 4 MiB cell has one window, from the lowest to the highest 256 KiB step asked for in it (to the cell's end for an ask without a length; with main's reach, past it as main's window does). When an ask goes past it, a longer window takes the place of the shorter one:

  • find returns the longer one from then on;
  • the pass over the heap makes the slots that show the shorter one again, on the longer one;
  • until no slot shows the shorter one, what is brought up to date or written through the longer one also goes to the shorter one (Shadow::forward, only to windows a slot still shows);
  • the shorter one waits in TAKEN_OVER until no slot, list or pass holds it, then goes with the idle windows.

Only the window that begins in the ask's own cell holds an ask, so the window find returns for an address changes only when one is replaced. Memory at a cell's edge can be in two windows.

The switch is off by default. When it is off, the behaviour is the same as before: the new paths return after one OnceLock read.

Update: main merged in (77df871e), measured again

Main now gives a window asked for without a length its cell and VICTORY_WINDOW_REACH_KB of the next (906f656, bfb3749: vehicle blocks cut off at the cell's end). With the switch on, such an ask now grows its window to the cell's end plus that reach, so a grown window holds what main's window holds (new test a_grown_window_for_an_ask_without_a_length_holds_the_reach). HeapRanges::slots_where follows main's new HeapRanges.

Same diagnostics build of e867ec3, the same 3-minute scripted run, alternated off/on/off/on, plus one more off run (the first off run stopped at 112 s in the title's own code, a write to address 0, with the switch off; it is left out):

off VICTORY_WINDOW_GROW=1
Windows in all 4,716 / 4,694 MB 3,320 / 3,166 MB
... over title memory 3,500 / 3,498 MB 2,772 / 2,625 MB
Shared buffers made in the run 10,347 / 10,679 MB 6,275 / 6,871 MB
Process private memory, mean 120-180 s 27.52 / 27.62 GB 28.26 / 27.60 GB

With main's reach the windows are larger than before (3.2 GB to 4.7 GB here), and the switch takes 1.4-1.55 GB off them. The process's private memory does not go down measurably on this build (runs of the same setup differ by about 0.4 GB); on the previous main it went down by about 0.8 GB (table below). I have not found where the difference goes. In the frames I compared (two runs on, one off) the police car of the opening scene is whole.

cargo test -p victory-gpu --features diagnostics: 614 passed.

Before main's reach (first version of this PR)

The same diagnostics build of this branch (on main 64d4931), the same 3-minute scripted run (Series X, 2560x1440, DLSS Quality, frame generation), switch off against on; memory line at the end:

off (4 MiB grid) VICTORY_WINDOW_GROW=1
Windows in all 3,216 MB 2,283 MB
... over title memory 2,856 MB 2,268 MB
Windows shown by descriptor slots 733, 3,116 MB 704, 2,235 MB
Windows replaced and still held 3, 2 MB
Process private memory, mean 120-180 s 26.06 GB 25.27 GB
GPU committed memory, mean 120-180 s 15.93 GB 15.01 GB
fps in the world, median (5 s lines) 24.2 28.7
5 s lines under 10 fps entering the world 3 1

One run each, so the fps rows only say it is not slower. Windows grew 3,739 times in the run; 62,106 slots of the heap and 7 of draws' tables were made again on the longer windows, none was left null. I saw no difference in the picture. Two earlier pairs of runs on the previous main gave the same window figures (3,204 against 2,177 and 2,184 MB).

PR #321 reaches for the same memory from the launcher side, with a finer grid on 16 GB PCs (3,400 to 2,598 MB there). On this 32 GB machine the finer grid did not help, for the reason given above. The two can be combined.

Slots and replaced windows

A slot that shows a replaced window is made again on the longer one where it is next used: by the pass over the heap (at once for the slots the pass keeps ranges for), and by a draw that reads its table. Until then Shadow::forward keeps the replaced window up to date, so nothing is lost; what shaders write through one window can reach a reader of the other a frame late. In the run above that was rare: 7 table slots in three minutes.

The diagnostics line "memory, heap slots elsewhere" (only with the switch on) says how often the pass finds a slot showing another copy than the one it brings up to date: 128 times in 2,490 passes (0.05 a pass; it was 0.33 a pass before these slots were made again), none still so after being made again.

Tests

The window choice, the overlap that forwarding uses and the chain of replaced windows are pure functions now (holding_in, overlap, chained), with seven new tests in shadow::window_tests: a window of the cell below does not hold an ask (this test fails if the lookup goes back to starting in the cell below), the cell's window holds an ask only up to its end, an ask without a length when the window already runs past the cell's end, each grown window holds the one before, overlaps (inside, across either end, disjoint, adjacent), and chains (windows gone are dropped, the old one comes last, the list it was taken from stays as it was).
cargo test -p victory-gpu: 443 passed; everything passes except indirect::tests::host_list_budget_starts_empty_at_each_submission and indirect::tests::warp_batch_charges_every_execution, which also fail on main.

Setup

RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, 32 GB, Windows 11 Pro. Series X profile, 2560x1440, DLSS Quality. My own dump. No game files are attached or quoted.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5534305278 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/477). Originally posted by [wildheathen](https://github.com/wildheathen) on 2026-11-27T23:13:50Z. --- ## What this changes A read of title memory outside the known buffers gets a host copy, a "window". Today each window is a 4 MiB host buffer on the 4 MiB grid, whatever is read in it, and all of it is resident. On my machine, at the end of a three-minute run, 727 windows held 3,100 MB, while what was read in them lay within about 1,700 MB. The finer grid that is already in `main` (`VICTORY_WINDOW_KB=256 VICTORY_WINDOW_TAILS=1`) saved nothing here: 3,060 MB of windows over 1,746 MB of title memory. The descriptor slots made on the shorter windows kept those windows alive beside the longer ones made later for the same memory. With `VICTORY_WINDOW_GROW=1`, each 4 MiB cell has **one** window, from the lowest to the highest 256 KiB step asked for in it (to the cell's end for an ask without a length; with main's reach, past it as main's window does). When an ask goes past it, a longer window takes the place of the shorter one: - `find` returns the longer one from then on; - the pass over the heap makes the slots that show the shorter one again, on the longer one; - until no slot shows the shorter one, what is brought up to date or written through the longer one also goes to the shorter one (`Shadow::forward`, only to windows a slot still shows); - the shorter one waits in `TAKEN_OVER` until no slot, list or pass holds it, then goes with the idle windows. Only the window that begins in the ask's own cell holds an ask, so the window `find` returns for an address changes only when one is replaced. Memory at a cell's edge can be in two windows. The switch is off by default. When it is off, the behaviour is the same as before: the new paths return after one `OnceLock` read. ## Update: main merged in (`77df871e`), measured again Main now gives a window asked for without a length its cell and `VICTORY_WINDOW_REACH_KB` of the next (`906f656`, `bfb3749`: vehicle blocks cut off at the cell's end). With the switch on, such an ask now grows its window to the cell's end **plus that reach**, so a grown window holds what main's window holds (new test `a_grown_window_for_an_ask_without_a_length_holds_the_reach`). `HeapRanges::slots_where` follows main's new `HeapRanges`. Same diagnostics build of `e867ec3`, the same 3-minute scripted run, alternated off/on/off/on, plus one more off run (the first off run stopped at 112 s in the title's own code, a write to address 0, with the switch off; it is left out): | | off | `VICTORY_WINDOW_GROW=1` | |---|---|---| | Windows in all | 4,716 / 4,694 MB | **3,320 / 3,166 MB** | | ... over title memory | 3,500 / 3,498 MB | 2,772 / 2,625 MB | | Shared buffers made in the run | 10,347 / 10,679 MB | 6,275 / 6,871 MB | | Process private memory, mean 120-180 s | 27.52 / 27.62 GB | 28.26 / 27.60 GB | With main's reach the windows are larger than before (3.2 GB to 4.7 GB here), and the switch takes 1.4-1.55 GB off them. **The process's private memory does not go down measurably on this build** (runs of the same setup differ by about 0.4 GB); on the previous main it went down by about 0.8 GB (table below). I have not found where the difference goes. In the frames I compared (two runs on, one off) the police car of the opening scene is whole. `cargo test -p victory-gpu --features diagnostics`: 614 passed. ## Before main's reach (first version of this PR) The same diagnostics build of this branch (on `main` 64d4931), the same 3-minute scripted run (Series X, 2560x1440, DLSS Quality, frame generation), switch off against on; memory line at the end: | | off (4 MiB grid) | `VICTORY_WINDOW_GROW=1` | |---|---|---| | Windows in all | 3,216 MB | **2,283 MB** | | ... over title memory | 2,856 MB | 2,268 MB | | Windows shown by descriptor slots | 733, 3,116 MB | 704, 2,235 MB | | Windows replaced and still held | | 3, 2 MB | | Process private memory, mean 120-180 s | 26.06 GB | **25.27 GB** | | GPU committed memory, mean 120-180 s | 15.93 GB | 15.01 GB | | fps in the world, median (5 s lines) | 24.2 | 28.7 | | 5 s lines under 10 fps entering the world | 3 | 1 | One run each, so the fps rows only say it is not slower. Windows grew 3,739 times in the run; 62,106 slots of the heap and 7 of draws' tables were made again on the longer windows, none was left null. I saw no difference in the picture. Two earlier pairs of runs on the previous `main` gave the same window figures (3,204 against 2,177 and 2,184 MB). PR #321 reaches for the same memory from the launcher side, with a finer grid on 16 GB PCs (3,400 to 2,598 MB there). On this 32 GB machine the finer grid did not help, for the reason given above. The two can be combined. ## Slots and replaced windows A slot that shows a replaced window is made again on the longer one where it is next used: by the pass over the heap (at once for the slots the pass keeps ranges for), and by a draw that reads its table. Until then `Shadow::forward` keeps the replaced window up to date, so nothing is lost; what shaders write through one window can reach a reader of the other a frame late. In the run above that was rare: 7 table slots in three minutes. The diagnostics line "memory, heap slots elsewhere" (only with the switch on) says how often the pass finds a slot showing another copy than the one it brings up to date: 128 times in 2,490 passes (0.05 a pass; it was 0.33 a pass before these slots were made again), none still so after being made again. ## Tests The window choice, the overlap that forwarding uses and the chain of replaced windows are pure functions now (`holding_in`, `overlap`, `chained`), with seven new tests in `shadow::window_tests`: a window of the cell below does not hold an ask (this test fails if the lookup goes back to starting in the cell below), the cell's window holds an ask only up to its end, an ask without a length when the window already runs past the cell's end, each grown window holds the one before, overlaps (inside, across either end, disjoint, adjacent), and chains (windows gone are dropped, the old one comes last, the list it was taken from stays as it was). `cargo test -p victory-gpu`: 443 passed; everything passes except `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `indirect::tests::warp_batch_charges_every_execution`, which also fail on `main`. ## Setup RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, 32 GB, Windows 11 Pro. Series X profile, 2560x1440, DLSS Quality. My own dump. No game files are attached or quoted.
eleboucher commented 2026-11-29 01:41:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by eleboucher on 2026-11-29T01:41:48Z.


Tested on top of #1823 on a 16 GB PC (RTX 4070 Ti SUPER, native 1440p, RT structure builder on; full numbers on #1823).

VICTORY_WINDOW_GROW=1 together with VICTORY_CARD_CPU_HEAP=1 held 16-18 fps from 180 to 420 s. CARD_CPU_HEAP=1 alone held 7-11 fps. Shared GPU memory went 3.8 → 3.6 GB.

The base was main f9dfb76f + #1640 + #1700 + #1823; this PR merged clean on top. It is untested without #1823 here, because that base doesn't survive the builder's unpack burst on 16 GB.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7248953987 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/477#issuecomment-7248953987). Originally posted by [eleboucher](https://github.com/eleboucher) on 2026-11-29T01:41:48Z. --- Tested on top of #1823 on a 16 GB PC (RTX 4070 Ti SUPER, native 1440p, RT structure builder on; full numbers on #1823). `VICTORY_WINDOW_GROW=1` together with `VICTORY_CARD_CPU_HEAP=1` held 16-18 fps from 180 to 420 s. `CARD_CPU_HEAP=1` alone held 7-11 fps. Shared GPU memory went 3.8 → 3.6 GB. The base was main f9dfb76f + #1640 + #1700 + #1823; this PR merged clean on top. It is untested without #1823 here, because that base doesn't survive the builder's unpack burst on 16 GB.
Sign in to join this conversation.
No reviewers
No labels
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.

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