perf: batch contiguous XMem page-view registration #651

Open
github-bot wants to merge 3 commits from github-bot/gh-651 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 23:56 UTC · original
tommiehansen:perf/phase13-mapping-views-20261206 → main · +219 −25 · 5 files · 3 commits · open

Why

A contiguous XMem mapping can register many individual 64 KiB page views while holding mapping metadata locks and invalidating guards repeatedly. Streaming or large mapping operations can therefore incur avoidable CPU bookkeeping even when the backing and offsets form one compatible run.

What changes

With VICTORY_BATCH_MAPPING_VIEWS=1, register compatible contiguous views under one lock, update the run index once and invalidate guards once per run. Individual view identity and alias/partial-unmap behavior remain intact. Driver mapping calls, ordering and HWRT address visibility are unchanged. Incompatible runs retain the existing path. Inspired by Boxon's structural mapping work; this is XMEM's metadata implementation, not a sparse Vulkan backend.

Benchmark results — Windows CPU metadata registration

Latest CI 47587142974, 62e9f08. Eight paired blocks per size, 16 samples per arm; all 40 blocks exact. Absolute times are medians of block medians; changes are median paired percentages.

Pages Before After Paired time reduction Wins
1 0.150 µs 0.150 µs 0% 0/8
4 0.525 µs 0.300 µs 42.73% 8/8
16 2.225 µs 1.000 µs 55.05% 8/8
64 10.200 µs 4.175 µs 58.33% 8/8
256 50.250 µs 24.750 µs 50.50% 8/8

At 256 pages the absolute median difference is 25.5 µs; pooled p95 90.6 → 30.6 µs. Independent earlier run found 55–57% reductions for 4–256 pages and a neutral one-page median, 32/32 multi-page wins. These results isolate CPU metadata, not driver ioctl cost, full mapping time or gameplay FPS.

Why this should be merged

Repeated, exact results demonstrate a scoped CPU bookkeeping benefit for multi-page runs without requiring a driver change. The conservative opt-in path and one-page control bound the impact; actual end-to-end mapping benefit remains a separate hardware question.

Validation and compatibility

Initial alias/partial-unmap tests and latest concurrent alias/partial-unmap test and HLE production compile passed. The actual patched-driver XMemMapPhysicalPages/physical backing read/activation fixture compiles but has not been run on a patched physical AMD driver.
Reproduce: cargo test --locked --release -p victory-gpu --lib page_run_paired_registration_cost -- --ignored --nocapture --test-threads=1. Request full mapping and activation measurements with the patched UM driver, option off/on, before claiming wider benefit or enabling by default.

Continuous comparison verified

CI 47590692671 at unchanged 62e9f08 completed generic Quick and Standard (2/8 runs per arm), both comparable, but explicitly missing changed-path coverage. Native metadata job also completed all 40 exact paired blocks. Generic Mapping evidence is not an XMem driver performance measurement. Generic raw report · Native raw data.

**@⁠tommiehansen** on GitHub · 2026-12-05 23:56 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/651) `tommiehansen:perf/phase13-mapping-views-20261206` → `main` · +219 −25 · 5 files · 3 commits · open ## Why A contiguous XMem mapping can register many individual 64 KiB page views while holding mapping metadata locks and invalidating guards repeatedly. Streaming or large mapping operations can therefore incur avoidable CPU bookkeeping even when the backing and offsets form one compatible run. ## What changes With `VICTORY_BATCH_MAPPING_VIEWS=1`, register compatible contiguous views under one lock, update the run index once and invalidate guards once per run. Individual view identity and alias/partial-unmap behavior remain intact. Driver mapping calls, ordering and HWRT address visibility are unchanged. Incompatible runs retain the existing path. Inspired by Boxon's structural mapping work; this is XMEM's metadata implementation, not a sparse Vulkan backend. ## Benchmark results — Windows CPU metadata registration [Latest CI 47587142974](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47587142974), `62e9f08`. Eight paired blocks per size, 16 samples per arm; all 40 blocks exact. Absolute times are medians of block medians; changes are median paired percentages. | Pages | Before | After | Paired time reduction | Wins | |---:|---:|---:|---:|---:| | 1 | 0.150 µs | 0.150 µs | 0% | 0/8 | | 4 | 0.525 µs | 0.300 µs | 42.73% | 8/8 | | 16 | 2.225 µs | 1.000 µs | 55.05% | 8/8 | | 64 | 10.200 µs | 4.175 µs | 58.33% | 8/8 | | 256 | 50.250 µs | 24.750 µs | 50.50% | 8/8 | At 256 pages the absolute median difference is 25.5 µs; pooled p95 90.6 → 30.6 µs. [Independent earlier run](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47585449161) found 55–57% reductions for 4–256 pages and a neutral one-page median, 32/32 multi-page wins. These results isolate CPU metadata, not driver ioctl cost, full mapping time or gameplay FPS. ## Why this should be merged Repeated, exact results demonstrate a scoped CPU bookkeeping benefit for multi-page runs without requiring a driver change. The conservative opt-in path and one-page control bound the impact; actual end-to-end mapping benefit remains a separate hardware question. ## Validation and compatibility [Initial alias/partial-unmap tests](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47584563142) and latest concurrent alias/partial-unmap test and HLE production compile passed. The actual patched-driver XMemMapPhysicalPages/physical backing read/activation fixture compiles but has not been run on a patched physical AMD driver. Reproduce: `cargo test --locked --release -p victory-gpu --lib page_run_paired_registration_cost -- --ignored --nocapture --test-threads=1`. Request full mapping and activation measurements with the patched UM driver, option off/on, before claiming wider benefit or enabling by default. ### Continuous comparison verified [CI 47590692671](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47590692671) at unchanged 62e9f08 completed generic Quick and Standard (2/8 runs per arm), both comparable, but explicitly missing changed-path coverage. [Native metadata job](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47590692671/job/145899136877) also completed all 40 exact paired blocks. Generic Mapping evidence is not an XMem driver performance measurement. [Generic raw report](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47590692671/artifacts/15962899968) · [Native raw data](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47590692671/artifacts/15963058320).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 23:56:24 +00:00
This pull request can be merged automatically.
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/651/head:github-bot/gh-651'
git switch 'github-bot/gh-651'

Merge

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