Physical pages can be held in our working set so the pagefile is not written behind the title (VICTORY_KEEP_PAGES=1, off by default) #1291

Open
flxppr wants to merge 2 commits from upstream-pr/1294 into main
flxppr commented 2026-11-26 12:02:34 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by flxppr on 2026-11-26T12:02:34Z.


What

When the title unmaps the last view of physical pages it wrote (it remaps all the time), Windows moves them to the modified list and writes them to the pagefile, even though the title still holds them. On a slow drive that write-back starves DirectStorage reads.

With VICTORY_KEEP_PAGES=1, each section of physical pages gets one view of all of it that is never unmapped, and each page a view commits is read once through it. The pages stay in the working set and only leave if Windows trims us. Cost: address space, plus one read per 4 KiB at each mapping. Off under Wine (its sections are sparse files). Off by default; one file changed (crates/victory-hle/src/modules/xmem.rs).

Measured

RX 7600 XT, Ryzen 7 5800X, 48 GB RAM, DRAM-less SATA SSD (89% full), 32 GB fixed pagefile. Same save, the diagnostics build, the speed switches (ASYNC_SUBMIT, QUEUE2, TEXTURE_NO_WAIT, INDIRECT_WINDOW, COPY_PLAIN, CARD_WINDOWS_MB=512) on in both runs. Disk counters sampled once a second.

Without With
Run length 8 min 16 min
Written to disk 8,479 MB (nearly all pagefile) 315 MB
Modified list, max 1,883 MB 52 MB
Seconds of 100+ MB/s writes 31 (up to 335 MB/s) 0 (max 14 MB/s)
Seconds with the drive ≥95% busy 305 17 (startup reads only)
Seconds with reads over 300 ms 239 (max 1,821 ms) 0 (max 3.7 ms)
Worst frame 7.3 s 3.9 s
System's unmapping, worst frame 1,149 ms 650 ms
Usual frame ~310 ms ~310 ms (unchanged)
Free memory, min 16 GB 7.8 GB

Without the switch, after a heavy remap the drive sat at 100% busy moving 1 to 2 MB/s for 60 to 90 s, and loading stopped until it drained. With it that never happened. The remaining ~0.5 s hitches line up with streaming reads on a healthy drive.

When it helps

Worth trying with a SATA drive and spare RAM. A tester's run on 16 GB RAM with an NVMe drive (Series S profile, ~19 GB committed) was neutral to slightly worse, within run-to-run noise: with that little room, Windows trims the working set anyway, and an NVMe never showed the write-back stalls. That is why it stays opt-in.

Not tested: Wine.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5509665442 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1294). Originally posted by [flxppr](https://github.com/flxppr) on 2026-11-26T12:02:34Z. --- ## What When the title unmaps the last view of physical pages it wrote (it remaps all the time), Windows moves them to the modified list and writes them to the pagefile, even though the title still holds them. On a slow drive that write-back starves DirectStorage reads. With `VICTORY_KEEP_PAGES=1`, each section of physical pages gets one view of all of it that is never unmapped, and each page a view commits is read once through it. The pages stay in the working set and only leave if Windows trims us. Cost: address space, plus one read per 4 KiB at each mapping. Off under Wine (its sections are sparse files). Off by default; one file changed (`crates/victory-hle/src/modules/xmem.rs`). ## Measured RX 7600 XT, Ryzen 7 5800X, 48 GB RAM, DRAM-less SATA SSD (89% full), 32 GB fixed pagefile. Same save, the diagnostics build, the speed switches (`ASYNC_SUBMIT`, `QUEUE2`, `TEXTURE_NO_WAIT`, `INDIRECT_WINDOW`, `COPY_PLAIN`, `CARD_WINDOWS_MB=512`) on in both runs. Disk counters sampled once a second. | | Without | With | |---|---|---| | Run length | 8 min | 16 min | | Written to disk | 8,479 MB (nearly all pagefile) | 315 MB | | Modified list, max | 1,883 MB | 52 MB | | Seconds of 100+ MB/s writes | 31 (up to 335 MB/s) | 0 (max 14 MB/s) | | Seconds with the drive ≥95% busy | 305 | 17 (startup reads only) | | Seconds with reads over 300 ms | 239 (max 1,821 ms) | 0 (max 3.7 ms) | | Worst frame | 7.3 s | 3.9 s | | System's unmapping, worst frame | 1,149 ms | 650 ms | | Usual frame | ~310 ms | ~310 ms (unchanged) | | Free memory, min | 16 GB | 7.8 GB | Without the switch, after a heavy remap the drive sat at 100% busy moving 1 to 2 MB/s for 60 to 90 s, and loading stopped until it drained. With it that never happened. The remaining ~0.5 s hitches line up with streaming reads on a healthy drive. ## When it helps Worth trying with a SATA drive and spare RAM. A tester's run on 16 GB RAM with an NVMe drive (Series S profile, ~19 GB committed) was neutral to slightly worse, within run-to-run noise: with that little room, Windows trims the working set anyway, and an NVMe never showed the write-back stalls. That is why it stays opt-in. Not tested: Wine.
Exopus-0x65f7ad0 commented 2026-11-26 14:03:30 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Exopus-0x65f7ad0 on 2026-11-26T13:15:53Z.


Data point for the untested case: 16 GB RAM, RTX 5060 Ti 8 GB, NVMe, Windows 11, Series S profile.

Setup: our tree with this commit ported onto 2 MiB sections (the keeping view is made per section). Same save, standing at the cell window, about 6 minutes in the world each.

run VICTORY_KEEP_PAGES world fps (median) title-copy cost (ms per MB copied)
A unset 7.1 0.88
B unset (another run) 7.1 1.01
C 1 6.3 0.92
  • No crash, and no "no keeping view" warning.
  • On this machine it is neutral to slightly worse, within run-to-run noise (about ±0.6 fps). That fits your note: with ~19 GB committed on 16 GB, Windows trims the working set anyway.
  • I did not measure disk writes. The NVMe here never showed the 100 %-busy stalls you describe.

Leaving it off here. It looks worth keeping opt-in for SATA drives with plenty of RAM.

AI-assisted (Claude Code). Counts only, nothing from the game.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7193098730 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1294#issuecomment-7193098730). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-26T13:15:53Z. --- Data point for the untested case: **16 GB RAM**, RTX 5060 Ti 8 GB, NVMe, Windows 11, Series S profile. Setup: our tree with this commit ported onto 2 MiB sections (the keeping view is made per section). Same save, standing at the cell window, about 6 minutes in the world each. | run | `VICTORY_KEEP_PAGES` | world fps (median) | title-copy cost (ms per MB copied) | |---|---|---:|---:| | A | unset | 7.1 | 0.88 | | B | unset (another run) | 7.1 | 1.01 | | C | `1` | 6.3 | 0.92 | - No crash, and no "no keeping view" warning. - On this machine it is neutral to slightly worse, within run-to-run noise (about ±0.6 fps). That fits your note: with ~19 GB committed on 16 GB, Windows trims the working set anyway. - I did not measure disk writes. The NVMe here never showed the 100 %-busy stalls you describe. Leaving it off here. It looks worth keeping opt-in for SATA drives with plenty of RAM. AI-assisted (Claude Code). Counts only, nothing from the game.
flxppr commented 2026-11-26 15:04:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by flxppr on 2026-11-26T14:23:57Z.


Thanks, that's exactly the case I couldn't test. It matches what I'd expect: keeping pages resident only helps when RAM has room to spare and the disk is the bottleneck. On 16 GB with ~19 GB committed, Windows trims the working set anyway, and an NVMe never hits the 100%-busy flush stalls a SATA SSD did here (48 GB RAM, SATA, the stalls stopped with VICTORY_KEEP_PAGES=1).

It stays opt-in (off unless set to 1). I've added a line to the description: worth trying on SATA drives with spare RAM, neutral to slightly worse on 16 GB.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7194764254 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1294#issuecomment-7194764254). Originally posted by [flxppr](https://github.com/flxppr) on 2026-11-26T14:23:57Z. --- Thanks, that's exactly the case I couldn't test. It matches what I'd expect: keeping pages resident only helps when RAM has room to spare and the disk is the bottleneck. On 16 GB with ~19 GB committed, Windows trims the working set anyway, and an NVMe never hits the 100%-busy flush stalls a SATA SSD did here (48 GB RAM, SATA, the stalls stopped with `VICTORY_KEEP_PAGES=1`). It stays opt-in (off unless set to `1`). I've added a line to the description: worth trying on SATA drives with spare RAM, neutral to slightly worse on 16 GB.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1294:upstream-pr/1294'
git switch 'upstream-pr/1294'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1294'
git switch 'upstream-pr/1294'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1294'
git switch 'upstream-pr/1294'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1294'
git switch 'main'
git merge --squash 'upstream-pr/1294'
git switch 'main'
git merge --ff-only 'upstream-pr/1294'
git switch 'main'
git merge 'upstream-pr/1294'
git push origin 'main'
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
fxceless/victory-fork!1291
No description provided.