Windows over title memory share one copy in 64 KiB tiles (VICTORY_WINDOW_ARENA=1, off by default) #4750

Closed
xteral67 wants to merge 3 commits from upstream-pr/4750 into main
xteral67 commented 2026-12-01 04:52:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xteral67 on 2026-12-01T04:52:02Z.


What it changes

A window outside buffers (shadow.rs) is a buffer of its own, and windows overlap: a cell's window reaches into the next cell, whose window holds the same bytes again. In a scripted walk through town, 837–888 windows held 5.1–5.5 GB for 3.75–3.9 GB of title memory (the union of their ranges), on a PC with 32 GB of RAM that was short of free memory.

With VICTORY_WINDOW_ARENA=1 (off by default, nothing changes without it):

  • A window is a reserved buffer of its length. Its 64 KiB tiles are mapped (UpdateTileMappings on the host queue, before any submission that reads it) to tiles of a pool shared by every window. A title tile is held once, whichever window shows it.
  • The pool is heaps of VICTORY_WINDOW_ARENA_MB (2–64, default 8 MiB), CUSTOM, write-combined, in the PC's memory. Each heap is mapped once for the CPU through a buffer placed over all of it. New tiles come from the fullest heap, and a heap goes back to the system when all its tiles are free. With 32 MiB heaps the pool held 4.7 GB for 4.1 GB of tiles and only 8 of 148 heaps were given back. With 8 MiB it held 3,640 MB for 3,614 MB.
  • A window keeps its own start, length and GPU address, so whatever the card is given of it is the same as before. Only the CPU side is no longer one run of memory. Refreshes, readbacks, the stale-page check and the sends in host/send.rs go through Shadow::cpu / cpu_runs / cpu_addr, cut where tiles end.
  • With room for windows on the card, the shared copy is the card window's CPU side (CardCpu::Shared over the reserved buffer).
  • Not handled: windows shaders write. Those still get a buffer of their own. A window in the pool that shaders write later gets a one-time warning and isn't copied back; none came up in testing. The recycle pool skips pooled windows, VICTORY_REFRESH_CHECK skips them, and facewatch isn't told about them.
  • If the card refuses a reserved buffer or a heap, the window gets a buffer of its own, as before.
  • windows' shared copy (VICTORY_WINDOW_ARENA=1): … log line every 20th window census: heaps, MB held, windows made, refused and let go, heaps given back, tiles shared and new.

How it was tested

  • GPU and profile: RTX 3080 Ti 12 GB (tiled resources tier 4), driver 621.40, i5-14600KF, 32 GB RAM; Series X profile, 1440p, DLSS quality, FSR 3 frame generation 2x, no ray tracing.
  • Before / after: the same scripted walk through town (one run each, the same save; the base was v2026.11.29.05 with VICTORY_SLOT_EVICT=0 in both runs; the arena code there is the same as here). Frame-time spikes are measured after the world has loaded:
    • seconds with a frame over 2× that second's median: 67 → 25;
    • frames over 100 ms: 161 → 87; worst frame 519 → 160 ms;
    • median fps 16.8 → 17.4;
    • PC memory: private 30.0 → 28.4 GB, free 2.4 → 3.5 GB, shared with the card 7.8 → 6.8 GB.
  • No picture faults were seen in a scripted 7-minute walk or in about 9 minutes of town play on a v2026.11.30.03-based tree with this code on.
  • cargo rustc --locked --profile diag -p victory --features diagnostics on this branch (d99f14cb, on 5fabb46e), Windows: finished, no warnings.
  • Not run: cargo clippy and cargo test (one new unit test, arena::tests::runs_cut_where_tiles_end, not run yet). Not tested on a card below tier 4 or on 8 GB cards.
  • For shader changes, the wave sizes tested: no shader changes.
  • cargo test passed for the crates it touches: no (not run).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2910 (windows outside the shared blocks, window growing; also edits shadow.rs around window creation, so one of the two will need a rebase), #4717 and #3646 (host copies of title memory), #2540.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5579286664 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750). Originally posted by [xteral67](https://github.com/xteral67) on 2026-12-01T04:52:02Z. --- ## What it changes A window outside buffers (`shadow.rs`) is a buffer of its own, and windows overlap: a cell's window reaches into the next cell, whose window holds the same bytes again. In a scripted walk through town, 837–888 windows held 5.1–5.5 GB for 3.75–3.9 GB of title memory (the union of their ranges), on a PC with 32 GB of RAM that was short of free memory. With `VICTORY_WINDOW_ARENA=1` (off by default, nothing changes without it): - A window is a reserved buffer of its length. Its 64 KiB tiles are mapped (`UpdateTileMappings` on the host queue, before any submission that reads it) to tiles of a pool shared by every window. A title tile is held once, whichever window shows it. - The pool is heaps of `VICTORY_WINDOW_ARENA_MB` (2–64, default 8 MiB), CUSTOM, write-combined, in the PC's memory. Each heap is mapped once for the CPU through a buffer placed over all of it. New tiles come from the fullest heap, and a heap goes back to the system when all its tiles are free. With 32 MiB heaps the pool held 4.7 GB for 4.1 GB of tiles and only 8 of 148 heaps were given back. With 8 MiB it held 3,640 MB for 3,614 MB. - A window keeps its own start, length and GPU address, so whatever the card is given of it is the same as before. Only the CPU side is no longer one run of memory. Refreshes, readbacks, the stale-page check and the sends in `host/send.rs` go through `Shadow::cpu` / `cpu_runs` / `cpu_addr`, cut where tiles end. - With room for windows on the card, the shared copy is the card window's CPU side (`CardCpu::Shared` over the reserved buffer). - Not handled: windows shaders write. Those still get a buffer of their own. A window in the pool that shaders write later gets a one-time warning and isn't copied back; none came up in testing. The recycle pool skips pooled windows, `VICTORY_REFRESH_CHECK` skips them, and facewatch isn't told about them. - If the card refuses a reserved buffer or a heap, the window gets a buffer of its own, as before. - `windows' shared copy (VICTORY_WINDOW_ARENA=1): …` log line every 20th window census: heaps, MB held, windows made, refused and let go, heaps given back, tiles shared and new. ## How it was tested - GPU and profile: RTX 3080 Ti 12 GB (tiled resources tier 4), driver 621.40, i5-14600KF, 32 GB RAM; Series X profile, 1440p, DLSS quality, FSR 3 frame generation 2x, no ray tracing. - Before / after: the same scripted walk through town (one run each, the same save; the base was v2026.11.29.05 with `VICTORY_SLOT_EVICT=0` in both runs; the arena code there is the same as here). Frame-time spikes are measured after the world has loaded: - seconds with a frame over 2× that second's median: 67 → 25; - frames over 100 ms: 161 → 87; worst frame 519 → 160 ms; - median fps 16.8 → 17.4; - PC memory: private 30.0 → 28.4 GB, free 2.4 → 3.5 GB, shared with the card 7.8 → 6.8 GB. - No picture faults were seen in a scripted 7-minute walk or in about 9 minutes of town play on a v2026.11.30.03-based tree with this code on. - `cargo rustc --locked --profile diag -p victory --features diagnostics` on this branch (d99f14cb, on 5fabb46e), Windows: finished, no warnings. - Not run: `cargo clippy` and `cargo test` (one new unit test, `arena::tests::runs_cut_where_tiles_end`, not run yet). Not tested on a card below tier 4 or on 8 GB cards. - For shader changes, the wave sizes tested: no shader changes. - `cargo test` passed for the crates it touches: no (not run). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2910 (windows outside the shared blocks, window growing; also edits `shadow.rs` around window creation, so one of the two will need a rebase), #4717 and #3646 (host copies of title memory), #2540. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
xteral67 commented 2026-12-01 07:22:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xteral67 on 2026-12-01T07:22:02Z.


PC pool heaps are now write-back, as other windows' buffers: CPU reads of tiles (sends, compares) went from 3.5 to 16.8 GB/s in town on the same PC.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7303970635 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7303970635). Originally posted by [xteral67](https://github.com/xteral67) on 2026-12-01T07:22:02Z. --- PC pool heaps are now write-back, as other windows' buffers: CPU reads of tiles (sends, compares) went from 3.5 to 16.8 GB/s in town on the same PC.
mykimy commented 2026-12-01 09:13:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mykimy on 2026-12-01T09:13:28Z.


Tested on a 32 GB PC that is short of RAM: it helps.

PC: RTX 4090 24 GB, i7-14700KF, 32 GB RAM, Windows 11 23H2, page file on its own drive (16-32 GB).
Build: the PR's three commits (d99f14cb, dc33b7bf, 26ab8f86) cherry-picked onto the v2026.11.30.03 tag with no conflict, release build from CI.
Settings: Series X, 1440p, DLAA, DLSS frame generation 2x, 20 fps cap, VICTORY_CARD_CPU_FILE=1, VICTORY_WINDOW_ARENA=1 (default heap size). Compared with a run of v2026.11.30.03 on the same settings without the arena, from the same save (normal play, not a fixed route). The figures leave out the first 2 minutes of each run.

without arena (6 min) with arena (8 min)
victory.exe working set 26.3 GB 22.9 GB
free physical RAM 0.5-1 GB ~2.9 GB
CPU mirrors in file-backed memory (file_mib) 5,390 MB 1,256 MB
committed (memory line, avg / max) 33.2 / 35.2 GB 35.3 / 37.5 GB
PC memory shared with the card 2.4 GB 5.9 GB
card's own memory 17.8 GB 16.5 GB
median frame 50.1 ms 50.1 ms
seconds with a frame over 100 ms 2.9 % 1.1 %
errors in the log 0 0
  • About 3.4 GB less in physical memory, and free RAM went from 0.5-1 GB to about 2.9 GB.
  • Commit rose by about 2 GB. With VICTORY_CARD_CPU_FILE=1, part of what the windows held was in file-backed memory, which does not count as commit. The arena heaps are committed memory shared with the card. The page file grew to 24.7 GB, with about 7 GB of commit still left, so nothing was refused. On a PC with a small or fixed page file this may matter.
  • No visual problems noticed in play and no errors in the log. Frame generation stopped twice, during what looked like cutscenes, as it does without the arena.
  • Hard page-ins still come in bursts (up to ~14,000 pages/s), so the PC is still tight on RAM, but less so.

This is one session per setting, so the over-100 ms figure is a trend only.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7306390813 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7306390813). Originally posted by [mykimy](https://github.com/mykimy) on 2026-12-01T09:13:28Z. --- Tested on a 32 GB PC that is short of RAM: it helps. **PC:** RTX 4090 24 GB, i7-14700KF, 32 GB RAM, Windows 11 23H2, page file on its own drive (16-32 GB). **Build:** the PR's three commits (d99f14cb, dc33b7bf, 26ab8f86) cherry-picked onto the `v2026.11.30.03` tag with no conflict, release build from CI. **Settings:** Series X, 1440p, DLAA, DLSS frame generation 2x, 20 fps cap, `VICTORY_CARD_CPU_FILE=1`, `VICTORY_WINDOW_ARENA=1` (default heap size). Compared with a run of `v2026.11.30.03` on the same settings without the arena, from the same save (normal play, not a fixed route). The figures leave out the first 2 minutes of each run. | | without arena (6 min) | with arena (8 min) | |---|---|---| | victory.exe working set | 26.3 GB | **22.9 GB** | | free physical RAM | 0.5-1 GB | **~2.9 GB** | | CPU mirrors in file-backed memory (`file_mib`) | 5,390 MB | 1,256 MB | | committed (memory line, avg / max) | 33.2 / 35.2 GB | 35.3 / 37.5 GB | | PC memory shared with the card | 2.4 GB | 5.9 GB | | card's own memory | 17.8 GB | 16.5 GB | | median frame | 50.1 ms | 50.1 ms | | seconds with a frame over 100 ms | 2.9 % | **1.1 %** | | errors in the log | 0 | 0 | - About 3.4 GB less in physical memory, and free RAM went from 0.5-1 GB to about 2.9 GB. - Commit rose by about 2 GB. With `VICTORY_CARD_CPU_FILE=1`, part of what the windows held was in file-backed memory, which does not count as commit. The arena heaps are committed memory shared with the card. The page file grew to 24.7 GB, with about 7 GB of commit still left, so nothing was refused. On a PC with a small or fixed page file this may matter. - No visual problems noticed in play and no errors in the log. Frame generation stopped twice, during what looked like cutscenes, as it does without the arena. - Hard page-ins still come in bursts (up to ~14,000 pages/s), so the PC is still tight on RAM, but less so. This is one session per setting, so the over-100 ms figure is a trend only.
trustno1-coder commented 2026-12-01 18:33:25 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:33:25Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321133690 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7321133690). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:33:25Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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!4750
No description provided.