KernelX: a page mapped away moves to its next address directly, not by way of its home #849

Manually merged
github merged 2 commits from gh-pr/849/head into gh-pr/849/base 2026-11-26 04:34:28 +00:00
Owner

@⁠Sr-0w on GitHub · 2026-11-24 06:44 UTC · original
Sr-0w:direct-page-moves-pr → main · +106 −6 · 1 files · 2 commits · merged 2026-11-24 09:31 UTC

A physical page that is mapped at one address and that the title maps at another went back home first. Its home was committed again and the page copied there, then the old address was decommitted. After that, the home was copied to the new address and decommitted. In a sparse window, each of those commits and decommits is also a tile mapping (UpdateTileMappings + a signal), so every page move cost about four of them.

A retail game, after its first movie, moves tens of thousands of pages one at a time. Measured with a counter in MapTitlePhysicalPages (not in this PR):

  • 16384 calls took 6 s;
  • 32768 took 23 s, the cost per call growing with the mapped tiles;
  • the game's watchdog then ended the process.

The page is now copied from where it is to the new address, and the old address is given up; its home is not touched. A page that was never used where it was (lazy) still comes from its home, as before.

What is in it

  • crates/xcl/src/hle/kernelx.rs:
    • move_away, called from map_pages for a page already mapped away;
    • release_at, the decommit that unmap_away already did, factored out;
    • the test a_page_away_moves_on_without_going_home and a test-only counter of pages copied home.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.32029.2010), Ryzen 7 3700X, Windows 11 26300, rustc 1.100.0, release.
  • cargo test --release --workspace -- --test-threads=4: 661 passed, 3 failed, 21 ignored.
    • The 3 failures are placed_title_textures_share_vram_and_preserve_pixels, transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory.
    • They fail the same way on main (e50836b) with --test-threads=4 and pass when run alone, on both.
    • No SKIPPED tests.
  • a_page_away_moves_on_without_going_home fails without the change ("the page went by way of its home") and passes with it.
  • scatter_timing (--ignored, XCL_SCATTER_PAGES=4096,16384), "reverse" being the pass that moves pages already mapped away:
pages reverse, main reverse, this PR
4096 203 ms 147 ms
16384 857 ms 588 ms
  • In the retail game the title screen and the loading screen after the first movie show as on main (below).

Regression run

main:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: AMD  Radeon RX 7800 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 68390 MB

this PR:

xcl-smoke v1
commit: f1e2113a76246e766570c66dda69cf767f7b6931
gpu: AMD  Radeon RX 7800 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1545 (PresentX 1546)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 64780 MB

Not tested

  • NVIDIA / Intel GPUs.
  • The smoke run stops at the title screen, before the page moves this is about.
  • Past the loading screen, the game stops on main too (cross-queue Wait64BitValueX on values nothing writes); that is not addressed here.

AI use

  • Claude Code, Claude Opus 5.5: measured where the page mapping time goes, wrote the change and its test, ran the tests and the regression runs.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-24 06:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/849) `Sr-0w:direct-page-moves-pr` → `main` · +106 −6 · 1 files · 2 commits · merged 2026-11-24 09:31 UTC A physical page that is mapped at one address and that the title maps at another went back home first. Its home was committed again and the page copied there, then the old address was decommitted. After that, the home was copied to the new address and decommitted. In a sparse window, each of those commits and decommits is also a tile mapping (`UpdateTileMappings` + a signal), so every page move cost about four of them. A retail game, after its first movie, moves tens of thousands of pages one at a time. Measured with a counter in `MapTitlePhysicalPages` (not in this PR): - 16384 calls took 6 s; - 32768 took 23 s, the cost per call growing with the mapped tiles; - the game's watchdog then ended the process. The page is now copied from where it is to the new address, and the old address is given up; its home is not touched. A page that was never used where it was (lazy) still comes from its home, as before. **What is in it** - `crates/xcl/src/hle/kernelx.rs`: - `move_away`, called from `map_pages` for a page already mapped away; - `release_at`, the decommit that `unmap_away` already did, factored out; - the test `a_page_away_moves_on_without_going_home` and a test-only counter of pages copied home. **Tested** - AMD Radeon RX 7800 XT (driver 32.0.32029.2010), Ryzen 7 3700X, Windows 11 26300, rustc 1.100.0, release. - `cargo test --release --workspace -- --test-threads=4`: 661 passed, 3 failed, 21 ignored. - The 3 failures are `placed_title_textures_share_vram_and_preserve_pixels`, `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`. - They fail the same way on `main` (e50836b) with `--test-threads=4` and pass when run alone, on both. - No SKIPPED tests. - `a_page_away_moves_on_without_going_home` fails without the change ("the page went by way of its home") and passes with it. - `scatter_timing` (`--ignored`, `XCL_SCATTER_PAGES=4096,16384`), "reverse" being the pass that moves pages already mapped away: | pages | reverse, main | reverse, this PR | |---|---|---| | 4096 | 203 ms | 147 ms | | 16384 | 857 ms | 588 ms | - In the retail game the title screen and the loading screen after the first movie show as on `main` (below). **Regression run** main: ``` xcl-smoke v1 commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: AMD Radeon RX 7800 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1518 (PresentX 1518) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 68390 MB ``` this PR: ``` xcl-smoke v1 commit: f1e2113a76246e766570c66dda69cf767f7b6931 gpu: AMD Radeon RX 7800 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1545 (PresentX 1546) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 64780 MB ``` **Not tested** - NVIDIA / Intel GPUs. - The smoke run stops at the title screen, before the page moves this is about. - Past the loading screen, the game stops on `main` too (cross-queue `Wait64BitValueX` on values nothing writes); that is not addressed here. **AI use** - Claude Code, Claude Opus 5.5: measured where the page mapping time goes, wrote the change and its test, ran the tests and the regression runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A physical page mapped at one address that the title maps at another went
back home first: its home was committed again, the page copied there, the
old address decommitted, then the home copied to the new address and
decommitted. In a sparse window each commit and decommit is also a tile
mapping. A retail game moving pages one at a time after its first movie spent
over 20 s in them, and its watchdog ended it.

The page is now copied from where it is to the new address and the old
address is given up; its home is not touched. A page never used where it was
(lazy) still comes from its home.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
Reported in review: move_away dropped both lookups of a page before
committing its destination, so a failed commit left its bytes at the old
address with nothing pointing at them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:27 +00:00
github manually merged commit 5b693e6752 into gh-pr/849/base 2026-11-26 04:34:28 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 07:17 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head f1e2113 onto main beaa245, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 704 passed, 10 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Kernel page-move tests green in the full suite run (no new failures anywhere).

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 07:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/849#issuecomment-7124833562) Linux / AMD RDNA3 datapoint. **Merged state:** head `f1e2113` onto main `beaa245`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **704 passed, 10 failed, 41 ignored**. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Kernel page-move tests green in the full suite run (no new failures anywhere). **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠badoomtch on GitHub · 2026-11-24 07:01 UTC · original · edited 2026-11-24 07:35 UTC

The direct-move regression passed on native Windows at f1e2113a76246e766570c66dda69cf767f7b6931. The test initialised UMA, preserved the first and last words, and released the old address. Windows 11 build 26300, RTX 5080 (610.88), Core Ultra 7 265, Rust 1.96.0 MSVC, debug build.

cargo test --frozen -p xcl --lib a_page_away_moves_on_without_going_home -- --nocapture --test-threads=1 — 1 passed, 0 failed, 0 ignored.

One error path looks worth checking before merging. For an already materialised page, move_away removes old from away.at and the page from away.page before committing the new destination. If that commit fails, the function returns Err with the original bytes still at old but both lookup entries gone. Moving those removals after a successful destination commit, or restoring the entries on that error, would preserve the previous mapping for a retry. I checked the order in the source. The passing test covers successful moves only.

We also ran a longer offline retail pair on the same native Windows machine. Both used the same returning-player profile and learned memory-window setting, with a shared cache. The control was our integration build based on beaa245. The candidate added this PR's runtime change alone. The following are integration runs, separate from the exact-head test above.

Control With the direct page move
Last captured loading artwork frame 1,444 frame 1,579
First captured black frame after that artwork 1,449 1,583
Total presents 1,450 1,585
Time to the same title watchdog abort 111.469 s 120.684 s
Legacy Wait64 timeout messages 0 0

The extra 135 presents were almost entirely before the fade. Both runs stopped within two presents of the first captured black frame. Neither showed a world frame. These builds do not count direct page moves or time spent in them, so this comparison cannot attribute the extra frames to faster remapping.

On a second pair based on 1ec4c98cd (including #873), we counted move attempts and native tile-mapping calls in two-second windows. The only runtime difference between the arms was #849. Both started with separate, byte-identical copies of XCL's cache (582 compatible translations), the same profile and memory-window setting. The machine's driver cache persisted across the pair.

Control Direct moves
Away-to-away move attempts 107,773 107,017
Native tile-mapping calls (map / unmap) 28,844 / 0 29,093 / 0
First captured black frame after the artwork 1,362 1,339
Final presents 1,364 1,341
Time of the same title abort 108.910 s 107.226 s
Five-second sparse-queue warnings 0 0

Both arms peaked at 44,049 moves in a two-second window during early loading. In both, the last 14 complete windows before the abort recorded zero move attempts, tile-mapping calls and new presents. Direct moves did run, and the prolonged freeze remained. These counters measure calls, not their cost.

AI use: Codex (GPT-6) checked the source, ran the tests and summarised the local captures and logs.

**@⁠badoomtch** on GitHub · 2026-11-24 07:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/849#issuecomment-7124534638) · edited 2026-11-24 07:35 UTC The direct-move regression passed on native Windows at `f1e2113a76246e766570c66dda69cf767f7b6931`. The test initialised UMA, preserved the first and last words, and released the old address. Windows 11 build 26300, RTX 5080 (610.88), Core Ultra 7 265, Rust 1.96.0 MSVC, debug build. `cargo test --frozen -p xcl --lib a_page_away_moves_on_without_going_home -- --nocapture --test-threads=1` — 1 passed, 0 failed, 0 ignored. One error path looks worth checking before merging. For an already materialised page, `move_away` removes `old` from `away.at` and the page from `away.page` before committing the new destination. If that commit fails, the function returns `Err` with the original bytes still at `old` but both lookup entries gone. Moving those removals after a successful destination commit, or restoring the entries on that error, would preserve the previous mapping for a retry. I checked the order in the source. The passing test covers successful moves only. We also ran a longer offline retail pair on the same native Windows machine. Both used the same returning-player profile and learned memory-window setting, with a shared cache. The control was our integration build based on `beaa245`. The candidate added this PR's runtime change alone. The following are integration runs, separate from the exact-head test above. | | Control | With the direct page move | | --- | ---: | ---: | | Last captured loading artwork | frame 1,444 | frame 1,579 | | First captured black frame after that artwork | 1,449 | 1,583 | | Total presents | 1,450 | 1,585 | | Time to the same title watchdog abort | 111.469 s | 120.684 s | | Legacy Wait64 timeout messages | 0 | 0 | The extra 135 presents were almost entirely before the fade. Both runs stopped within two presents of the first captured black frame. Neither showed a world frame. These builds do not count direct page moves or time spent in them, so this comparison cannot attribute the extra frames to faster remapping. On a second pair based on `1ec4c98cd` (including #873), we counted move attempts and native tile-mapping calls in two-second windows. The only runtime difference between the arms was #849. Both started with separate, byte-identical copies of XCL's cache (582 compatible translations), the same profile and memory-window setting. The machine's driver cache persisted across the pair. | | Control | Direct moves | | --- | ---: | ---: | | Away-to-away move attempts | 107,773 | 107,017 | | Native tile-mapping calls (map / unmap) | 28,844 / 0 | 29,093 / 0 | | First captured black frame after the artwork | 1,362 | 1,339 | | Final presents | 1,364 | 1,341 | | Time of the same title abort | 108.910 s | 107.226 s | | Five-second sparse-queue warnings | 0 | 0 | Both arms peaked at 44,049 moves in a two-second window during early loading. In both, the last 14 complete windows before the abort recorded zero move attempts, tile-mapping calls and new presents. Direct moves did run, and the prolonged freeze remained. These counters measure calls, not their cost. AI use: Codex (GPT-6) checked the source, ran the tests and summarised the local captures and logs.
Author
Owner

@⁠Sr-0w on GitHub · 2026-11-24 08:10 UTC · original

Thanks @⁠badoomtch, you're right about the error path. Fixed in the latest commit on this branch: move_away now only drops the page's two lookups once the destination is committed. A lazy page is still released before the commit, as before.

New test: a_page_whose_move_fails_stays_mapped_where_it_was. It points a move at an address with nothing reserved there, then checks that the page keeps both lookups and its bytes. It fails on f1e2113 ("the page lost where it is") and passes now. The four kernelx page tests pass (release, RX 7800 XT, Windows 11 26300).

Thanks for the long paired runs too. They match what I see: direct moves run, but the freeze after the loading artwork does not come from page moves. On my side it is the title's watchdog while its threads wait in pso_async::resolve_wait on long driver compiles of compute programs (#505). #891 targets that, opt-in. @⁠SlopTart, thanks for the Linux / RDNA3 run.

AI use: Claude Code (Claude Opus 5.5) wrote the fix, the test and this reply.

**@⁠Sr-0w** on GitHub · 2026-11-24 08:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/849#issuecomment-7125816687) Thanks @⁠badoomtch, you're right about the error path. Fixed in the latest commit on this branch: `move_away` now only drops the page's two lookups once the destination is committed. A lazy page is still released before the commit, as before. New test: `a_page_whose_move_fails_stays_mapped_where_it_was`. It points a move at an address with nothing reserved there, then checks that the page keeps both lookups and its bytes. It fails on `f1e2113` ("the page lost where it is") and passes now. The four `kernelx` page tests pass (release, RX 7800 XT, Windows 11 26300). Thanks for the long paired runs too. They match what I see: direct moves run, but the freeze after the loading artwork does not come from page moves. On my side it is the title's watchdog while its threads wait in `pso_async::resolve_wait` on long driver compiles of compute programs (#505). #891 targets that, opt-in. @⁠SlopTart, thanks for the Linux / RDNA3 run. AI use: Claude Code (Claude Opus 5.5) wrote the fix, the test and this reply.
Author
Owner

@⁠eizispark on GitHub · 2026-11-24 08:56 UTC · original

Hardware check of 5b693e67524d63282911ce9cfacc7b980cbb04af (verified clean merge with main 077ce40): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 706 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none)
  • hle::kernelx unit tests (28 passed, 0 failed), including hle::kernelx::tests::a_page_away_moves_on_without_going_home and hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (5b693e6):

xcl-smoke v1
commit: 5b693e67524d63282911ce9cfacc7b980cbb04af
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1659 (PresentX 1659)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14860 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay / world-load page moves past the 60 s menu window

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.
**@⁠eizispark** on GitHub · 2026-11-24 08:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/849#issuecomment-7126751162) Hardware check of `5b693e67524d63282911ce9cfacc7b980cbb04af` (verified clean merge with `main` `077ce40`): **pass**. **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, release + test profile - `cargo test --workspace -- --test-threads=4`: `706 passed, 0 failed, 41 ignored` (GPU tests skipped on this adapter: `none`) - `hle::kernelx` unit tests (`28 passed, 0 failed`), including `hle::kernelx::tests::a_page_away_moves_on_without_going_home` and `hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was` **Regression run** `main` (`beaa245`): ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1660 (PresentX 1660) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14862 MB ``` PR (`5b693e6`): ``` xcl-smoke v1 commit: 5b693e67524d63282911ce9cfacc7b980cbb04af gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1659 (PresentX 1659) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 14860 MB ``` **Not tested** - wave32-only GPUs (NVIDIA / Intel); gameplay / world-load page moves past the 60 s menu window **AI use** - Antigravity (Gemini 4 Carbon) ran the build, test suite, and `scripts/smoke.ps1` harness on this machine and formatted this report.
Author
Owner

@⁠ivall on GitHub · 2026-11-24 09:32 UTC · original

Merged (6bac4b4). Checked on an RX 9070 (RDNA4) on main 6bac4b4 together with #923 and #849: cargo test --workspace -- --test-threads=4 - 678 unit tests passed, 0 failed; the retail game plays its intro and menus at 30 fps and starts loading the world (the run then hits this machine's commit limit, not a crash). Picked over #531 (the same move without going home); #556 will need its run-dropping added to move_away when rebased.

**@⁠ivall** on GitHub · 2026-11-24 09:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/849#issuecomment-7127544308) Merged (6bac4b4). Checked on an RX 9070 (RDNA4) on main 6bac4b4 together with #923 and #849: `cargo test --workspace -- --test-threads=4` - 678 unit tests passed, 0 failed; the retail game plays its intro and menus at 30 fps and starts loading the world (the run then hits this machine's commit limit, not a crash). Picked over #531 (the same move without going home); #556 will need its run-dropping added to `move_away` when rebased.
This discussion has been locked. Commenting is limited to contributors.
No description provided.