Page residency: streamed pages wait before the seen moves, read ones stay off #562

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

@⁠TreXito on GitHub · 2026-12-05 07:21 UTC · original
TreXito:pr/stream-fresh → main · +79 −0 · 3 files · 1 commits · open

With VICTORY_PAGES_SEEN=1, streamed pages wait a few seconds before the seen moves may take them to the card, and pages our own reads went through stay off those moves. Nothing changes without VICTORY_PAGES_SEEN=1.

  • A page read_through covers is marked ours, and the seen moves skip it: texture refreshes and buffer copies read the same pages again later.
  • stream_completed stamps the pages it covers. The seen moves skip a page stamped in the last VICTORY_PAGES_STREAM_FRESH ms (5000 unset, 0 turns it off), and a stamped page that is on the card goes down at the next wave.
  • docs/SETTINGS.md has the new switch.

Why

The seen bit stays on a page after the title's pools reuse it, so the seen moves take pages to the card that are about to receive streamed textures. The CPU then reads each texture once, right after it lands (its first refresh), through the bus at ~100 MB/s. On main with VICTORY_PAGES_SEEN=1 that came to 1.1-1.3 GB in six minutes. A per-caller counter (local, not in this PR) put almost all of it in the texture refresh read and the blank-check reads.

Marking every streamed page ours removed those reads, and the gain went with them: the pages that pay off on the card are streamed buffers the GPU reads. Holding streamed pages for a few seconds separates the two. A texture is read in that time, becomes ours and stays down. A buffer only the GPU reads goes up afterwards.

Measured

Release builds of main (b581f7e) and this branch, each with a local frame-time logger that is not part of this PR. Same frozen save, standing at the spawn, 360 s per run, three runs per arm, interleaved. i5-13600KF, RX 7800 XT 16 GB on PCIe 4.0 x16, 32 GB, Nobara kernel 7.3.4 with the IOMMU in translated mode, setup.sh's Mesa. fps = 1000 / frame time; 1% low = 1000 / p99.

avg fps median fps 1% low fps frames over 90 ms CPU reads of title memory on the card
main 25.6-25.7 25.8-27.1 13.2-14.2 12-17 ~300 MB (one run)
main, VICTORY_PAGES_SEEN=1 VICTORY_TITLE_VRAM_MB=6100 25.9-27.5 26.3-29.9 12.6-14.8 24-31 1117-1313 MB
this branch, same switches 27.0-27.7 29.2-29.9 12.5-14.3 20-34 526-607 MB

This halves the CPU's reads of the card's memory and steadies the seen moves' gain: +1.5 fps on average and about +3 fps median over main. Frames over 90 ms stay above main's, as with the seen moves alone.

On an older local base (dc9b7b5 plus local work), the seen moves alone read 1.8-2.4 GB per run and had 58-68 frames over 90 ms. With this rule it was 27.9-28.0 fps average and 13.1-14.6 fps 1% low, against 25.8-26.4 and 13.0-14.7 without seen moves. A 15 s window measured the same as 5 s there (28.0-28.7 fps average, three runs).

Not checked

  • Other GPUs and CPUs, and setups where the CPU reads the card's memory fast (CARD_READ_MB_S ≥ 1000). There the first reads cost little, and the 5 s hold only delays the buffers' moves.
  • Sessions longer than six minutes, and driving.

Checked

  • Release build without new warnings; rustfmt --check shows no new diffs in the two changed files.
  • No crash, hang or reset in 9 runs of this rule (3 on main, 6 on the older base).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4

**@⁠TreXito** on GitHub · 2026-12-05 07:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/562) `TreXito:pr/stream-fresh` → `main` · +79 −0 · 3 files · 1 commits · open With `VICTORY_PAGES_SEEN=1`, streamed pages wait a few seconds before the seen moves may take them to the card, and pages our own reads went through stay off those moves. Nothing changes without `VICTORY_PAGES_SEEN=1`. - A page `read_through` covers is marked ours, and the seen moves skip it: texture refreshes and buffer copies read the same pages again later. - `stream_completed` stamps the pages it covers. The seen moves skip a page stamped in the last `VICTORY_PAGES_STREAM_FRESH` ms (5000 unset, 0 turns it off), and a stamped page that is on the card goes down at the next wave. - `docs/SETTINGS.md` has the new switch. ### Why The seen bit stays on a page after the title's pools reuse it, so the seen moves take pages to the card that are about to receive streamed textures. The CPU then reads each texture once, right after it lands (its first refresh), through the bus at ~100 MB/s. On main with `VICTORY_PAGES_SEEN=1` that came to 1.1-1.3 GB in six minutes. A per-caller counter (local, not in this PR) put almost all of it in the texture refresh read and the blank-check reads. Marking every streamed page ours removed those reads, and the gain went with them: the pages that pay off on the card are streamed buffers the GPU reads. Holding streamed pages for a few seconds separates the two. A texture is read in that time, becomes ours and stays down. A buffer only the GPU reads goes up afterwards. ### Measured Release builds of main (`b581f7e`) and this branch, each with a local frame-time logger that is not part of this PR. Same frozen save, standing at the spawn, 360 s per run, three runs per arm, interleaved. i5-13600KF, RX 7800 XT 16 GB on PCIe 4.0 x16, 32 GB, Nobara kernel 7.3.4 with the IOMMU in translated mode, `setup.sh`'s Mesa. fps = 1000 / frame time; 1% low = 1000 / p99. | | avg fps | median fps | 1% low fps | frames over 90 ms | CPU reads of title memory on the card | |---|---|---|---|---|---| | main | 25.6-25.7 | 25.8-27.1 | 13.2-14.2 | 12-17 | ~300 MB (one run) | | main, `VICTORY_PAGES_SEEN=1 VICTORY_TITLE_VRAM_MB=6100` | 25.9-27.5 | 26.3-29.9 | 12.6-14.8 | 24-31 | 1117-1313 MB | | this branch, same switches | 27.0-27.7 | 29.2-29.9 | 12.5-14.3 | 20-34 | 526-607 MB | This halves the CPU's reads of the card's memory and steadies the seen moves' gain: +1.5 fps on average and about +3 fps median over main. Frames over 90 ms stay above main's, as with the seen moves alone. On an older local base (`dc9b7b5` plus local work), the seen moves alone read 1.8-2.4 GB per run and had 58-68 frames over 90 ms. With this rule it was 27.9-28.0 fps average and 13.1-14.6 fps 1% low, against 25.8-26.4 and 13.0-14.7 without seen moves. A 15 s window measured the same as 5 s there (28.0-28.7 fps average, three runs). ### Not checked - Other GPUs and CPUs, and setups where the CPU reads the card's memory fast (`CARD_READ_MB_S` ≥ 1000). There the first reads cost little, and the 5 s hold only delays the buffers' moves. - Sessions longer than six minutes, and driving. ### Checked - Release build without new warnings; `rustfmt --check` shows no new diffs in the two changed files. - No crash, hang or reset in 9 runs of this rule (3 on main, 6 on the older base). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4
With VICTORY_PAGES_SEEN=1 the seen moves take streamed textures to the card,
and the processor then reads them there (their first refresh, ~100 MB/s
through the bus): 1.1-1.3 GB in six minutes standing at the spawn.

A page our reads went through stays off the seen moves (it is read again
later). A page streamed into waits VICTORY_PAGES_STREAM_FRESH ms (5 s unset,
0 never) before a seen move, and goes down if it was on the card: a streamed
texture is read in that time and stays down, a streamed buffer only the card
reads goes up after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 07:26:58 +00:00
Author
Owner

@⁠TreXito on GitHub · 2026-12-05 13:42 UTC · original

Walking runs on the same base (camera turning, new areas streaming in), last 110 s in the world, x16 PCIe:

avg fps median 1% low
baseline 23.1 23.6 13.8
this PR + RADV_PERFTEST=sam, 2 runs 25.9 27.0-27.6 13.0-13.8

Standing, same day: baseline 26.2 / 27.6 / 14.3, with this PR + SAM 28.9-29.0 / 30.3-31.3 / 12.5-13.2. The lows dip in the first minute or two after loading while the moves settle; longer runs earlier settled at lows equal to or above the baseline. A walking run with a diagnostics build and captures showed no visual artifacts.

SAM is a separate setting (run.sh appends nosam, RADV_PERFTEST=sam overrides it); on its own it measured about +0.5 fps, with this PR about +1-1.5 fps on top.

AI-assisted: yes

**@⁠TreXito** on GitHub · 2026-12-05 13:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/562#issuecomment-7438964540) Walking runs on the same base (camera turning, new areas streaming in), last 110 s in the world, x16 PCIe: | | avg fps | median | 1% low | |---|---|---|---| | baseline | 23.1 | 23.6 | 13.8 | | this PR + `RADV_PERFTEST=sam`, 2 runs | 25.9 | 27.0-27.6 | 13.0-13.8 | Standing, same day: baseline 26.2 / 27.6 / 14.3, with this PR + SAM 28.9-29.0 / 30.3-31.3 / 12.5-13.2. The lows dip in the first minute or two after loading while the moves settle; longer runs earlier settled at lows equal to or above the baseline. A walking run with a diagnostics build and captures showed no visual artifacts. SAM is a separate setting (run.sh appends `nosam`, `RADV_PERFTEST=sam` overrides it); on its own it measured about +0.5 fps, with this PR about +1-1.5 fps on top. AI-assisted: yes
Author
Owner

@⁠TreXito on GitHub · 2026-12-05 16:15 UTC · original

Follow-up with longer runs (7 min, last 200 s in the world): baseline 24.7 / 25.6 avg fps, this PR alone 27.9 avg / 29.0 median / 14.9 1% low with the fewest long frames, this PR + RADV_PERFTEST=sam 28.2 / 29.2 / 14.5. So SAM adds about nothing here; the gain is this PR's. One run per arm in this block, consistent with the earlier ones.

AI-assisted: yes

**@⁠TreXito** on GitHub · 2026-12-05 16:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/562#issuecomment-7441151859) Follow-up with longer runs (7 min, last 200 s in the world): baseline 24.7 / 25.6 avg fps, this PR alone 27.9 avg / 29.0 median / 14.9 1% low with the fewest long frames, this PR + `RADV_PERFTEST=sam` 28.2 / 29.2 / 14.5. So SAM adds about nothing here; the gain is this PR's. One run per arm in this block, consistent with the earlier ones. AI-assisted: yes
Author
Owner

@⁠TreXito on GitHub · 2026-12-05 23:07 UTC · original

Walking runs added (7 min each, last 200 s in the world, release build, same save copy, this PR's switches without SAM):

avg fps median 1% low frames over 90 ms
baseline, walking 22.5 23.0 12.7 5
this PR, walking, run 1 24.9 25.7 14.6 3
this PR, walking, run 2 26.2 27.0 15.2 1

Standing baseline again the same evening: 26.3 / 27.8 / 14.3. The gain holds while moving and the 1% lows don't drop. Caveat: only one baseline walking run tonight, and walking fps varies a lot between runs (an earlier baseline walk read 30.2 avg), so read the walking delta as the direction more than the size.

AI-assisted: yes

**@⁠TreXito** on GitHub · 2026-12-05 23:07 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/562#issuecomment-7447324696) Walking runs added (7 min each, last 200 s in the world, release build, same save copy, this PR's switches without SAM): | | avg fps | median | 1% low | frames over 90 ms | |---|---|---|---|---| | baseline, walking | 22.5 | 23.0 | 12.7 | 5 | | this PR, walking, run 1 | 24.9 | 25.7 | 14.6 | 3 | | this PR, walking, run 2 | 26.2 | 27.0 | 15.2 | 1 | Standing baseline again the same evening: 26.3 / 27.8 / 14.3. The gain holds while moving and the 1% lows don't drop. Caveat: only one baseline walking run tonight, and walking fps varies a lot between runs (an earlier baseline walk read 30.2 avg), so read the walking delta as the direction more than the size. AI-assisted: yes
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/562/head:github-bot/gh-562'
git switch 'github-bot/gh-562'

Merge

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