residency: test bounded page exchange at the title VRAM cap #398

Open
github-bot wants to merge 2 commits from github-bot/gh-398 into main AGit
Owner

@⁠lucalocastro on GitHub · 2026-12-04 00:14 UTC · original
lucalocastro:codex/title-cap-exchange-draft → main · +363 −24 · 9 files · 2 commits · draft

El-Biiscuit observed roughly 5,000 pages waiting for promotion on the RX 6700 XT with a 512 MiB title budget. Once the budget filled, very few pages moved up. This draft tests whether making a small amount of room helps frame pacing in that scene. It follows the discussion on #303 and targets main so the eviction experiment can be measured independently.

What changes

With VICTORY_PAGE_CAP_EXCHANGE=1, a saturated title budget and sufficient free device memory, the governor can demote up to 16 previously GPU-used pages per eligible pass. Eligible pages have been idle for 16–149 busy ticks. An ordinary cold candidate or a planned CPU-touch demotion disables exchange for that pass. Eligible promotions must be waiting. The next pass reads the budget again before promoting anything into that space. The switch defaults to off.

What the local replay shows

With 5,000 fixed requests and sufficient idle victims, the baseline served 0 and the experiment served 3,600 in 450 simulated passes. This took 3,600 demotions. With only 64 eligible victims, it served 64. If the simulated driver rejected every demotion, it served 0. Actual GPU reuse, migration cost and frame pacing still need hardware measurements.

Requested hardware comparison

If someone with the RX 6700 XT can reproduce the plateau, the tester guide includes the commands for eight matched four-minute runs in ABBAABBA order. Both arms use the same binary, 512 MiB budget, city save and camera movement. Please share the per-run summary or the eight pairs of residency.csv and bench_stats.txt, plus the GPU and driver version. A useful outcome would be repeatably fewer frames above 200 ms per minute and a lower P99 alongside successful promotions. Quick returns and refused moves help identify costly churn.

A follow-up comparison with #356 would be welcome once there is a baseline for this experiment.

Local verification

The Windows diagnostic executable built successfully. Five residency tests and six benchmark-filtered core tests passed. Both shell scripts passed syntax checks. The repository-wide switch check flags four guard settings already documented on main, and the asset-policy scan reports ten existing paths outside this diff.

**@⁠lucalocastro** on GitHub · 2026-12-04 00:14 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/398) `lucalocastro:codex/title-cap-exchange-draft` → `main` · +363 −24 · 9 files · 2 commits · draft El-Biiscuit observed roughly 5,000 pages waiting for promotion on the RX 6700 XT with a 512 MiB title budget. Once the budget filled, very few pages moved up. This draft tests whether making a small amount of room helps frame pacing in that scene. It follows [the discussion on #303](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303) and targets main so the eviction experiment can be measured independently. ### What changes With `VICTORY_PAGE_CAP_EXCHANGE=1`, a saturated title budget and sufficient free device memory, the governor can demote up to 16 previously GPU-used pages per eligible pass. Eligible pages have been idle for 16–149 busy ticks. An ordinary cold candidate or a planned CPU-touch demotion disables exchange for that pass. Eligible promotions must be waiting. The next pass reads the budget again before promoting anything into that space. The switch defaults to off. ### What the local replay shows With 5,000 fixed requests and sufficient idle victims, the baseline served 0 and the experiment served 3,600 in 450 simulated passes. This took 3,600 demotions. With only 64 eligible victims, it served 64. If the simulated driver rejected every demotion, it served 0. Actual GPU reuse, migration cost and frame pacing still need hardware measurements. ### Requested hardware comparison If someone with the RX 6700 XT can reproduce the plateau, the [tester guide](https://github.com/lucalocastro/VIctory-xmem/blob/codex/title-cap-exchange-draft/docs/CAP-EXCHANGE-TEST.md) includes the commands for eight matched four-minute runs in ABBAABBA order. Both arms use the same binary, 512 MiB budget, city save and camera movement. Please share the per-run summary or the eight pairs of `residency.csv` and `bench_stats.txt`, plus the GPU and driver version. A useful outcome would be repeatably fewer frames above 200 ms per minute and a lower P99 alongside successful promotions. Quick returns and refused moves help identify costly churn. A follow-up comparison with #356 would be welcome once there is a baseline for this experiment. ### Local verification The Windows diagnostic executable built successfully. Five residency tests and six benchmark-filtered core tests passed. Both shell scripts passed syntax checks. The repository-wide switch check flags four guard settings already documented on main, and the asset-policy scan reports ten existing paths outside this diff.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 00:18:39 +00:00
Author
Owner

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

The replay test convinced me the ordinary path is unchanged — available + reclaimed, lacking and the remaining decrement all reduce to the old arithmetic, and the exchange path deliberately leaves available alone so a freed slot is spent the next pass.

One doc fix before testers see it: docs/SETTINGS.md:58 says "idle for at least 16 busy ticks" but exchange_candidate is (16..COLD) with COLD = 150 (um/residency.rs:8, :491-494), and a victim aged >= 150 goes to cold, which makes exchange_limit's cold == 0 test disable the exchange for that pass. So it is 16..149, and any colder victim cancels the pass — otherwise a tester watching older pages will conclude the switch does nothing.

Also: VICTORY_BENCH_TITLE_512 is benchmark-only but sits in the menu table (row 59) with no run.conf.default entry; the runtime-only section is its home. And an exchange demotion is counted twice (DOWN_EXCHANGE and DOWN_ROOM, :832-836), so that log column is no longer comparable with a switch-off run.

Unrelated but next to it: crates/victory-core/src/bench.rs:120 indexes p99 with div_ceil while low_1pct (:99) floors, so a 100-frame sample reports two different frames; your new test only pins the 304-frame case where both agree.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/398#issuecomment-7410144272) The replay test convinced me the ordinary path is unchanged — `available + reclaimed`, `lacking` and the `remaining` decrement all reduce to the old arithmetic, and the exchange path deliberately leaves `available` alone so a freed slot is spent the next pass. One doc fix before testers see it: `docs/SETTINGS.md:58` says "idle for at least 16 busy ticks" but `exchange_candidate` is `(16..COLD)` with `COLD = 150` (`um/residency.rs:8`, `:491-494`), and a victim aged >= 150 goes to `cold`, which makes `exchange_limit`'s `cold == 0` test disable the exchange for that pass. So it is 16..149, and any colder victim cancels the pass — otherwise a tester watching older pages will conclude the switch does nothing. Also: `VICTORY_BENCH_TITLE_512` is benchmark-only but sits in the menu table (row 59) with no `run.conf.default` entry; the runtime-only section is its home. And an exchange demotion is counted twice (`DOWN_EXCHANGE` and `DOWN_ROOM`, `:832-836`), so that log column is no longer comparable with a switch-off run. Unrelated but next to it: `crates/victory-core/src/bench.rs:120` indexes p99 with `div_ceil` while `low_1pct` (`:99`) floors, so a 100-frame sample reports two different frames; your new test only pins the 304-frame case where both agree.
Author
Owner

@⁠El-Biiscuit on GitHub · 2026-12-04 11:57 UTC · original

@⁠lucalocastro Here are the eight runs on the RX 6700 XT, plus one extra run with the probe at debug level.

Setup. This PR at fff93be, diagnostics build, shaders warmed. Settings from docs/CAP-EXCHANGE-TEST.md: VICTORY_BENCH_TITLE_512=1, VICTORY_PAGES=1, VICTORY_PAGE_PASS_MS=400, VICTORY_PAGE_MOVE_MB=32, VICTORY_PAGE_ADAPTIVE=0, VICTORY_LOG=info. Same harness as my #303 runs: city save on foot, camera turning for the whole run, 4 min per run, Series X, FSR 4 Quality to 3840x2160, RT off. RADV (Mesa 26.3.1), Linux 7.3. card_mb_for_title=512 in every run. Order A B B A A B B A; 8/8 valid, 0 kernel faults, 0 driver refusals.

Output of tools/cap-exchange-summary.sh, in run order:

arm	fps	p99_ms	hitches_per_min	wait_start	wait_end	wait_peak	up	exchange_down	cold_down	quick_returns	refused	directory
A	10.0	275.533	21.329	4740	4941	5328	217	0	190	0	0	01-A-echange-0
B	10.2	234.743	16.662	4615	4700	5328	14	4	1	0	0	02-B-echange-1
B	10.0	257.481	18.006	4509	4827	5266	6	2	1	0	0	03-B-echange-1
A	10.1	242.117	13.665	4918	4744	5294	237	0	233	0	0	04-A-echange-0
A	9.7	286.577	26.681	5159	4862	5337	116	0	97	0	0	05-A-echange-0
B	10.2	270.263	20.332	4728	4868	5260	3	2	1	0	0	06-B-echange-1
B	10.2	270.976	16.679	4467	4981	5349	30	4	1	0	0	07-B-echange-1
A	10.2	243.777	16.330	3185	4654	5264	269	0	238	2	0	08-A-echange-0
A (exchange 0) B (exchange 1)
median frame time, median of 4 [range] 90.1 ms [88.9–91.3] 89.6 ms [89.0–91.0]
p99, median of 4 [range] 243.4 ms [220.2–269.6] 251.4 ms [220.0–258.1]
promotions, whole run 6,023–6,203 6,051–6,215
exchange demotions 0 153–289
cold demotions 99–240 1
quick returns 3–13 1–3
pages waiting at the end 4,654–4,941 4,700–4,981

Frame times, P99 and hitches per minute overlap, so I see no effect on frame pacing here.

Note on the summary window. Almost all exchanges happen in the first minute: run 2 reached 279 by 60 s and 283 by the end. The script starts at 60 s, so it shows up 3–30 for B against 116–269 for A. Over the whole run both arms promote the same number of pages, and in B the exchanges take the place of A's cold demotions.

Why it stops. One extra B run with victory_gpu::um::residency=debug: 496 page cap exchange probe lines, and 485 of them have candidates=0, with cold=0, about 4,500–4,800 waiting and about 1 GB of the card free. So after the first minute no on-card title page is in the 16–149 tick age band: everything in the 512 MiB is being used by the GPU. In this scene the queue isn't stuck for lack of a victim policy. The title room is full of hot pages, so an exchange would only help if a waiting page is worth more than a hot resident one.

Related: in an overnight series on the same card (1080p, low preset, main 6064c04), #369 with a larger title share (VICTORY_CARD_KEPT_MB=6144) was the only memory change that improved both median and P99 (~41.7 ms vs ~46.1 ms on main, P99 ~82 vs ~100 ms, 2 runs each). That points the same way: more room helps here, reshuffling a full room doesn't.

**@⁠El-Biiscuit** on GitHub · 2026-12-04 11:57 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/398#issuecomment-7410784103) @⁠lucalocastro Here are the eight runs on the RX 6700 XT, plus one extra run with the probe at debug level. **Setup.** This PR at `fff93be`, diagnostics build, shaders warmed. Settings from `docs/CAP-EXCHANGE-TEST.md`: `VICTORY_BENCH_TITLE_512=1`, `VICTORY_PAGES=1`, `VICTORY_PAGE_PASS_MS=400`, `VICTORY_PAGE_MOVE_MB=32`, `VICTORY_PAGE_ADAPTIVE=0`, `VICTORY_LOG=info`. Same harness as my #303 runs: city save on foot, camera turning for the whole run, 4 min per run, Series X, FSR 4 Quality to 3840x2160, RT off. RADV (Mesa 26.3.1), Linux 7.3. `card_mb_for_title=512` in every run. Order A B B A A B B A; 8/8 valid, 0 kernel faults, 0 driver refusals. Output of `tools/cap-exchange-summary.sh`, in run order: ``` arm fps p99_ms hitches_per_min wait_start wait_end wait_peak up exchange_down cold_down quick_returns refused directory A 10.0 275.533 21.329 4740 4941 5328 217 0 190 0 0 01-A-echange-0 B 10.2 234.743 16.662 4615 4700 5328 14 4 1 0 0 02-B-echange-1 B 10.0 257.481 18.006 4509 4827 5266 6 2 1 0 0 03-B-echange-1 A 10.1 242.117 13.665 4918 4744 5294 237 0 233 0 0 04-A-echange-0 A 9.7 286.577 26.681 5159 4862 5337 116 0 97 0 0 05-A-echange-0 B 10.2 270.263 20.332 4728 4868 5260 3 2 1 0 0 06-B-echange-1 B 10.2 270.976 16.679 4467 4981 5349 30 4 1 0 0 07-B-echange-1 A 10.2 243.777 16.330 3185 4654 5264 269 0 238 2 0 08-A-echange-0 ``` | | A (exchange 0) | B (exchange 1) | |---|---|---| | median frame time, median of 4 [range] | 90.1 ms [88.9–91.3] | 89.6 ms [89.0–91.0] | | p99, median of 4 [range] | 243.4 ms [220.2–269.6] | 251.4 ms [220.0–258.1] | | promotions, whole run | 6,023–6,203 | 6,051–6,215 | | exchange demotions | 0 | 153–289 | | cold demotions | 99–240 | 1 | | quick returns | 3–13 | 1–3 | | pages waiting at the end | 4,654–4,941 | 4,700–4,981 | Frame times, P99 and hitches per minute overlap, so I see no effect on frame pacing here. **Note on the summary window.** Almost all exchanges happen in the first minute: run 2 reached 279 by 60 s and 283 by the end. The script starts at 60 s, so it shows `up` 3–30 for B against 116–269 for A. Over the whole run both arms promote the same number of pages, and in B the exchanges take the place of A's cold demotions. **Why it stops.** One extra B run with `victory_gpu::um::residency=debug`: 496 `page cap exchange probe` lines, and 485 of them have `candidates=0`, with `cold=0`, about 4,500–4,800 waiting and about 1 GB of the card free. So after the first minute no on-card title page is in the 16–149 tick age band: everything in the 512 MiB is being used by the GPU. In this scene the queue isn't stuck for lack of a victim policy. The title room is full of hot pages, so an exchange would only help if a waiting page is worth more than a hot resident one. Related: in an overnight series on the same card (1080p, low preset, main `6064c04`), #369 with a larger title share (`VICTORY_CARD_KEPT_MB=6144`) was the only memory change that improved both median and P99 (~41.7 ms vs ~46.1 ms on main, P99 ~82 vs ~100 ms, 2 runs each). That points the same way: more room helps here, reshuffling a full room doesn't.
Author
Owner

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

@⁠El-Biiscuit Thanks for running all eight sessions and collecting the debug trace. The 485 of 496 passes with zero exchange candidates explain why the queue persists after warm-up. The frame-time ranges overlap on this save, so I’ll keep the experiment opt-in. The whole-run and post-warm-up promotion totals answer different questions, and I’ll use the same measurement window when comparing them.

@⁠Luxuride I’ve prepared the documentation and counter fixes locally. Exchange demotions now have their own count, and P99 uses the same frame as the existing 1% low. I added a 100-frame regression case. The changes are now on this PR in 44d6f0ad1b.

**@⁠lucalocastro** on GitHub · 2026-12-04 12:04 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/398#issuecomment-7410937242) · edited 2026-12-04 12:09 UTC @⁠El-Biiscuit Thanks for running all eight sessions and collecting the debug trace. The 485 of 496 passes with zero exchange candidates explain why the queue persists after warm-up. The frame-time ranges overlap on this save, so I’ll keep the experiment opt-in. The whole-run and post-warm-up promotion totals answer different questions, and I’ll use the same measurement window when comparing them. @⁠Luxuride I’ve prepared the documentation and counter fixes locally. Exchange demotions now have their own count, and P99 uses the same frame as the existing 1% low. I added a 100-frame regression case. The changes are now on this PR in 44d6f0ad1bba43212abf2c4a714a4f67db38a2d8.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/bench.rs
  • crates/victory-gpu/src/um/residency.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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