Experiment with adaptive CPU read-ahead on UMA faults #397

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

@⁠lucalocastro on GitHub · 2026-12-04 00:04 UTC · original
lucalocastro:codex/uma-adaptive-read-ahead → main · +203 −1 · 5 files · 1 commits · open

A first CPU touch currently opens up to 15 neighboring 64 KiB pages. This experiment starts with the requested page and grows the window on consecutive faults. Each thread tracks four streams. The existing 16-page window stays the default.

Windows microbenchmark

Median of 30 measured sequences per setting and workload across ten paired launches. Each sequence used 512 reads with real Windows faults on a synthetic 512 MiB section. Timings came from the integration checkout based on eb51227. Both modes also passed the fixture on this PR commit, 72750c6. P99 is per access.

Access sequence Fixed total, ms Adaptive total, ms Fixed → adaptive P99, µs
Sequential 0.575 0.587 9.0 → 9.1
One read every 16 pages 4.673 1.193 11.35 → 2.50
Shuffled pages 2.830 1.188 9.25 → 2.50
Four-page bursts 1.394 1.026 9.2 → 2.8
Mixed bursts 1.220 1.050 9.1 → 5.5
Two interleaved streams 0.573 0.583 9.1 → 9.1
Three interleaved streams 0.583 0.597 9.2 → 9.05
Eight interleaved streams 0.572 1.176 9.1 → 2.5

The sparse sequence saved 3.48 ms over 512 reads. It opened 8,192 pages with the fixed window and 512 with the adaptive window. With eight interleaved streams, faults increased from 32 to 512 and total time roughly doubled even though per-access P99 fell.

One A/B comparison requested

On this commit, run A with VICTORY_ADAPTIVE_READ_AHEAD=0 and B with VICTORY_ADAPTIVE_READ_AHEAD=1. Restart between arms, restore the same save and use A/B/B/A. Both arms use the upstream migration lock. This experiment is independent of #392.

Please cover a city traversal with camera turns, a steady interior and a streaming transition. Include RT off/on, CPU-limited and GPU-limited settings, the normal title budget and a verified 512 MiB cap where available. Separate cold loads from warm repeats. Record CPU, GPU/VRAM, driver, Wine/Proton, resolution and actual title budget. Keep input, shader cache state, frame cap and frame generation settings matched. For steady play, warm up one minute and record the next three.

Please attach per-run median and P99 frame time, FPS, frames over 50/100 ms, and raw frame times if possible. Report regressions, neutral results and visual issues. The eight-stream regression is why this remains opt-in pending game data.

The isolated Windows test is windows_fault_read_ahead in the victory-gpu library. Run it once per switch value with --ignored --nocapture --test-threads=1.

**@⁠lucalocastro** on GitHub · 2026-12-04 00:04 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/397) `lucalocastro:codex/uma-adaptive-read-ahead` → `main` · +203 −1 · 5 files · 1 commits · open A first CPU touch currently opens up to 15 neighboring 64 KiB pages. This experiment starts with the requested page and grows the window on consecutive faults. Each thread tracks four streams. The existing 16-page window stays the default. ## Windows microbenchmark Median of 30 measured sequences per setting and workload across ten paired launches. Each sequence used 512 reads with real Windows faults on a synthetic 512 MiB section. Timings came from the integration checkout based on `eb51227`. Both modes also passed the fixture on this PR commit, `72750c6`. P99 is per access. | Access sequence | Fixed total, ms | Adaptive total, ms | Fixed → adaptive P99, µs | | --- | ---: | ---: | ---: | | Sequential | 0.575 | 0.587 | 9.0 → 9.1 | | One read every 16 pages | 4.673 | 1.193 | 11.35 → 2.50 | | Shuffled pages | 2.830 | 1.188 | 9.25 → 2.50 | | Four-page bursts | 1.394 | 1.026 | 9.2 → 2.8 | | Mixed bursts | 1.220 | 1.050 | 9.1 → 5.5 | | Two interleaved streams | 0.573 | 0.583 | 9.1 → 9.1 | | Three interleaved streams | 0.583 | 0.597 | 9.2 → 9.05 | | Eight interleaved streams | 0.572 | 1.176 | 9.1 → 2.5 | The sparse sequence saved **3.48 ms over 512 reads**. It opened 8,192 pages with the fixed window and 512 with the adaptive window. With eight interleaved streams, faults increased from 32 to 512 and total time roughly doubled even though per-access P99 fell. ## One A/B comparison requested On this commit, run **A** with `VICTORY_ADAPTIVE_READ_AHEAD=0` and **B** with `VICTORY_ADAPTIVE_READ_AHEAD=1`. Restart between arms, restore the same save and use A/B/B/A. Both arms use the upstream migration lock. This experiment is independent of #392. Please cover a city traversal with camera turns, a steady interior and a streaming transition. Include RT off/on, CPU-limited and GPU-limited settings, the normal title budget and a verified 512 MiB cap where available. Separate cold loads from warm repeats. Record CPU, GPU/VRAM, driver, Wine/Proton, resolution and actual title budget. Keep input, shader cache state, frame cap and frame generation settings matched. For steady play, warm up one minute and record the next three. Please attach per-run median and P99 frame time, FPS, frames over 50/100 ms, and raw frame times if possible. Report regressions, neutral results and visual issues. The eight-stream regression is why this remains opt-in pending game data. The isolated Windows test is `windows_fault_read_ahead` in the `victory-gpu` library. Run it once per switch value with `--ignored --nocapture --test-threads=1`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 00:07:50 +00:00
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 11:28 UTC · original

Rebase first, please: the branch predates f374dbf ("count the views an aliased open actually cleared"), so the diff against main deletes that open_given counter at crates/victory-gpu/src/watch.rs:2514-2530. A rebase removes it; merging the tree as-is would undo a merged fix.

Then the comment is one step off: "Cover 1, 2, 4, ... pages" at watch.rs:1604 does not match the code — the stored window starts at 0, window <= 1 takes the one-page branch (:1605-1609), and only then does it store (window * 2).clamp(1, 16) (:1612), so the sequence is 1, 1, 2, 4, 8, 16. That also explains your own numbers (sequential slightly worse, 0.575 -> 0.587 ms) better than the comment does.

Docs: docs/SETTINGS.md:59 puts the row in "Ray tracing, memory and paging", where every other row has a run.conf.default line; either add one or move it to the runtime-only table (:144).

The install-time read (watch.rs:3113) and the const { Cell::new(..) } initialiser (:1593-1594, no lazy-init lock inside a vectored handler) are both the right call.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/397#issuecomment-7410143820) Rebase first, please: the branch predates `f374dbf` ("count the views an aliased open actually cleared"), so the diff against main *deletes* that `open_given` counter at `crates/victory-gpu/src/watch.rs:2514-2530`. A rebase removes it; merging the tree as-is would undo a merged fix. Then the comment is one step off: "Cover 1, 2, 4, ... pages" at `watch.rs:1604` does not match the code — the stored window starts at 0, `window <= 1` takes the one-page branch (`:1605-1609`), and only then does it store `(window * 2).clamp(1, 16)` (`:1612`), so the sequence is 1, 1, 2, 4, 8, 16. That also explains your own numbers (sequential slightly worse, 0.575 -> 0.587 ms) better than the comment does. Docs: `docs/SETTINGS.md:59` puts the row in "Ray tracing, memory and paging", where every other row has a `run.conf.default` line; either add one or move it to the runtime-only table (`:144`). The install-time read (`watch.rs:3113`) and the `const { Cell::new(..) }` initialiser (`:1593-1594`, no lazy-init lock inside a vectored handler) are both the right call.
github-bot force-pushed github-bot/gh-397 from 72750c66c7 to 56ce551c10 2026-12-04 12:11:20 +00:00 Compare
Author
Owner

@⁠lucalocastro on GitHub · 2026-12-04 12:05 UTC · original · edited 2026-12-04 12:09 UTC

@⁠Luxuride I’ve rebased the patch locally onto 0fd7614 and verified that the full open_given function matches upstream main, including the actual-open count from f374dbf. The comment now gives the requested windows as 1, 1, 2, 4, 8, then up to 16 pages. I also added VICTORY_ADAPTIVE_READ_AHEAD to run.conf.default, unset by default, to match the menu table. The changes are now on this PR in 56ce551c10. I verified the exported patch against main; I haven’t run the Windows tests on this revision.

**@⁠lucalocastro** on GitHub · 2026-12-04 12:05 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/397#issuecomment-7410949008) · edited 2026-12-04 12:09 UTC @⁠Luxuride I’ve rebased the patch locally onto `0fd7614` and verified that the full `open_given` function matches upstream main, including the actual-open count from `f374dbf`. The comment now gives the requested windows as 1, 1, 2, 4, 8, then up to 16 pages. I also added `VICTORY_ADAPTIVE_READ_AHEAD` to `run.conf.default`, unset by default, to match the menu table. The changes are now on this PR in 56ce551c1090db673abde729f59ccaec3fcbfecc. I verified the exported patch against main; I haven’t run the Windows tests on this revision.
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/397/head:github-bot/gh-397'
git switch 'github-bot/gh-397'

Merge

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