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

Closed
github-bot wants to merge 3 commits from github-bot/gh-4750 into main AGit
Owner

@⁠xteral67 on GitHub · 2026-12-01 04:52 UTC · original
xteral67:window-arena → main · +549 −12 · 4 files · 3 commits · closed without merging

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), #4718 and #3646 (host copies of title memory), #2540.

🤖 Generated with Claude Code

**@⁠xteral67** on GitHub · 2026-12-01 04:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750) `xteral67:window-arena` → `main` · +549 −12 · 4 files · 3 commits · closed without merging ## 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), #4718 and #3646 (host copies of title memory), #2540. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A window outside buffers is a buffer of its own, and windows overlap: in
a scripted walk through town 837-888 windows held 5.1-5.5 GB for
3.75-3.9 GB of title memory. With VICTORY_WINDOW_ARENA=1 a window is a
reserved buffer whose tiles are tiles of a pool shared by every window
(heaps of VICTORY_WINDOW_ARENA_MB, default 8 MiB, write-combined in the
PC's memory, each mapped once for the CPU): a title tile is held once,
whichever window shows it. The CPU side of such a window is in tiles:
refreshes, sends and readbacks go through Shadow::cpu / cpu_runs. Windows
shaders write, and the recycle pool, stay as before. A heap goes back
when all its tiles are free. A memory line every 20th window census.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 04:53:57 +00:00
Clippy without features: arena::line was never used (-D dead-code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠xteral67 on GitHub · 2026-12-01 07:22 UTC · original

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.

**@⁠xteral67** on GitHub · 2026-12-01 07:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7303970635) 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.
Author
Owner

@⁠mykimy on GitHub · 2026-12-01 09:13 UTC · original

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.

**@⁠mykimy** on GitHub · 2026-12-01 09:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7306390813) 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.
github-bot closed this pull request 2026-12-01 18:36:42 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:33 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4750#issuecomment-7321133690) 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

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