Launcher: write-watch large XMemAllocDefault allocations on NVIDIA #381

Open
github-bot wants to merge 1 commit from github-bot/gh-381 into main AGit
Owner

@⁠urielbeaupre on GitHub · 2026-11-27 21:35 UTC · original
urielbeaupre:perf/watch-xmem-nvidia → main · +34 −0 · 2 files · 1 commits · open

Sets VICTORY_WATCH_XMEM_ALLOC=1 (#321) in scripts/play.ps1 for the NVIDIA presets, outside -Safe.

Why

A traffic breakdown in the prison cell showed one copy dominating the bus. The title's 21 MB XMemAllocDefault buffer (+0x1412200) went 21.05 MB up and 21.04 MB fetched a frame, all 321 pieces both ways. It is private memory the kernel does not watch, so each refresh copied it whole (copied whole (memory not watched), 1–2× a frame), and the GPU writes it every frame.

With the switch the buffer is write-watched. VICTORY_LAND_ECHO recognises what its landings put back, so nothing of it goes up. Bytes sent up over the bus fell from 60 to 40 MB a frame, and the echo check reported 37 MB a frame of landings "held already and left", against 16 MB without the switch.

When #321 was measured on Windows (RTX 3080, boat scene), the landing re-dirtied ~5,100 pages a frame and made preparing slower. That measurement came before VICTORY_LAND_ECHO (e162982) existed. Here preparing is 1.4 ms faster.

Measurements

RTX 4070 Ti 12 GB, Ryzen 9 7900X (12 cores), 63 GB, Windows 11 26200. Diagnostics build of aa917f3, -Machine 4070, Series S, windowed 1920×1080, ports 6 and 7 on (#375). Unattended with the intro skipped (A held), measured 100–160 s after the loader started in the prison cell. Separate runs, order alternated:

VICTORY_WATCH_XMEM_ALLOC FPS median slowest quarter CPU preparation
1 25.0 24.2 29.1 ms
0 23.9 23.4 32.0 ms
0 24.1 23.8 30.9 ms
1 24.5 24.0 30.1 ms

The mean is 24.0 → 24.75 fps. No run had its video memory budget fall below use. A further run with the switch on, recorded every 4 s, showed the same picture as without it.

What this does not cover

  • One PC, one scene. Open world and the boat scene from #321 were not re-measured.
  • Linux/Wine is not affected by this PR: the launcher is Windows. #321 measured a gain there too.
  • The runs predate #374 (VICTORY_PLACED_FILL_REDIRECT), now on in the same block. The two touch different paths, but they were not measured together.

Verification

The launcher's final settings were printed for -Machine 4070 and auto, with and without -Safe: the switch is on outside -Safe and absent under it. play.ps1 parses with no errors, and cargo xtask policy passes. The measurements are added to docs/rtx4070-performance.md.

🤖 Generated with Claude Code

**@⁠urielbeaupre** on GitHub · 2026-11-27 21:35 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/381) `urielbeaupre:perf/watch-xmem-nvidia` → `main` · +34 −0 · 2 files · 1 commits · open Sets `VICTORY_WATCH_XMEM_ALLOC=1` (#321) in `scripts/play.ps1` for the NVIDIA presets, outside `-Safe`. ## Why A traffic breakdown in the prison cell showed one copy dominating the bus. The title's 21 MB `XMemAllocDefault` buffer (`+0x1412200`) went **21.05 MB up and 21.04 MB fetched a frame, all 321 pieces both ways**. It is private memory the kernel does not watch, so each refresh copied it whole (`copied whole (memory not watched)`, 1–2× a frame), and the GPU writes it every frame. With the switch the buffer is write-watched. `VICTORY_LAND_ECHO` recognises what its landings put back, so **nothing of it goes up**. Bytes sent up over the bus fell from 60 to 40 MB a frame, and the echo check reported 37 MB a frame of landings "held already and left", against 16 MB without the switch. When #321 was measured on Windows (RTX 3080, boat scene), the landing re-dirtied ~5,100 pages a frame and made `preparing` slower. That measurement came before `VICTORY_LAND_ECHO` (e162982) existed. Here `preparing` is 1.4 ms faster. ## Measurements RTX 4070 Ti 12 GB, Ryzen 9 7900X (12 cores), 63 GB, Windows 11 26200. Diagnostics build of `aa917f3`, `-Machine 4070`, Series S, windowed 1920×1080, ports 6 and 7 on (#375). Unattended with the intro skipped (A held), measured 100–160 s after the loader started in the prison cell. Separate runs, order alternated: | `VICTORY_WATCH_XMEM_ALLOC` | FPS median | slowest quarter | CPU preparation | |---|---:|---:|---:| | 1 | 25.0 | 24.2 | 29.1 ms | | 0 | 23.9 | 23.4 | 32.0 ms | | 0 | 24.1 | 23.8 | 30.9 ms | | 1 | 24.5 | 24.0 | 30.1 ms | The mean is **24.0 → 24.75 fps**. No run had its video memory budget fall below use. A further run with the switch on, recorded every 4 s, showed the same picture as without it. ## What this does not cover - One PC, one scene. Open world and the boat scene from #321 were not re-measured. - Linux/Wine is not affected by this PR: the launcher is Windows. #321 measured a gain there too. - The runs predate #374 (`VICTORY_PLACED_FILL_REDIRECT`), now on in the same block. The two touch different paths, but they were not measured together. ## Verification The launcher's final settings were printed for `-Machine 4070` and `auto`, with and without `-Safe`: the switch is on outside `-Safe` and absent under it. `play.ps1` parses with no errors, and `cargo xtask policy` passes. The measurements are added to `docs/rtx4070-performance.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title's 21 MB buffer the GPU writes every frame was copied and sent up whole each refresh (21 MB a frame up, 21 fetched). Watched, VICTORY_LAND_ECHO recognises its landings and nothing of it goes up: 24.0 -> 24.75 fps in the prison cell on an RTX 4070 Ti / Ryzen 9 7900X, 60 -> 40 MB a frame sent up. Outside -Safe; measurements in docs/rtx4070-performance.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:38:30 +00:00
Author
Owner

@⁠urielbeaupre on GitHub · 2026-11-27 22:06 UTC · original

A related finding, posted as a question rather than a proposal.

With this PR the 21 MB buffer (+0x1412200) no longer goes up. It still comes down every frame: 21.04 MB fetched in 321 pieces, about a third of all copy-back. To see whether the title reads it on the CPU, I added a diagnostics-only test switch that skips fetching copies of that one length, at the same point where VICTORY_LAND_SKIP skips pieces in relay_card_back. The switch is local only; it is not in this PR.

Same PC as above, newest main (0148258) plus this PR, ports 6 and 7 off. The intro was skipped, and the measurement is from the prison cell at 100–160 s.

Fetch of the 21 MB buffer Runs (fps median) Mean copy-back
skipped 26.1, 25.8, 25.3 25.7 11.0–11.9 ms
as now 24.4, 23.4 23.9 13.9–14.1 ms

Total fetched fell from 64 to 44 MB a frame. No crash, and screenshots every 4 s looked the same as normal runs.

A scripted walk followed (keys: back to turn into the room, forward, strafing, camera turns; screenshots every 2 s, one run each). Walking, the other inmates, the mission prompt ("Go with the prison guard") and the lighting all looked the same. The blocky wall textures appeared in both runs. FPS while moving was about equal (24.0 skipped vs 24.2 normal; slowest quarter 22.8 vs 20.4), so the gain is clear only in the still scene.

That does not show the title never reads it. It could matter outside the cell, later, or in logic that doesn't show on screen. Do you know what this buffer is, and whether anything on the CPU reads what the GPU writes there? If nothing does, its copy-back could go for everyone.

🤖 Generated with Claude Code

**@⁠urielbeaupre** on GitHub · 2026-11-27 22:06 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/381#issuecomment-7229036966) A related finding, posted as a question rather than a proposal. With this PR the 21 MB buffer (`+0x1412200`) no longer goes **up**. It still comes **down** every frame: 21.04 MB fetched in 321 pieces, about a third of all copy-back. To see whether the title reads it on the CPU, I added a diagnostics-only test switch that skips fetching copies of that one length, at the same point where `VICTORY_LAND_SKIP` skips pieces in `relay_card_back`. The switch is local only; it is not in this PR. Same PC as above, newest main (`0148258`) plus this PR, ports 6 and 7 off. The intro was skipped, and the measurement is from the prison cell at 100–160 s. | Fetch of the 21 MB buffer | Runs (fps median) | Mean | copy-back | |---|---|---:|---:| | skipped | 26.1, 25.8, 25.3 | **25.7** | 11.0–11.9 ms | | as now | 24.4, 23.4 | **23.9** | 13.9–14.1 ms | Total fetched fell from 64 to 44 MB a frame. No crash, and screenshots every 4 s looked the same as normal runs. A scripted walk followed (keys: back to turn into the room, forward, strafing, camera turns; screenshots every 2 s, one run each). Walking, the other inmates, the mission prompt ("Go with the prison guard") and the lighting all looked the same. The blocky wall textures appeared in both runs. FPS while moving was about equal (24.0 skipped vs 24.2 normal; slowest quarter 22.8 vs 20.4), so the gain is clear only in the still scene. That does not show the title never reads it. It could matter outside the cell, later, or in logic that doesn't show on screen. Do you know what this buffer is, and whether anything on the CPU reads what the GPU writes there? If nothing does, its copy-back could go for everyone. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/381/head:github-bot/gh-381'
git switch 'github-bot/gh-381'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-381'
git switch 'github-bot/gh-381'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-381'
git switch 'github-bot/gh-381'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-381'
git switch 'main'
git merge --squash 'github-bot/gh-381'
git switch 'main'
git merge --ff-only 'github-bot/gh-381'
git switch 'main'
git merge 'github-bot/gh-381'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.