kernelx: commit a mapping call's sparse pages once per run, not per page #1792

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

@⁠gavinnolan on GitHub · 2026-11-24 20:50 UTC · original
gavinnolan:kernelx-batch-sparse-commits → main · +80 −2 · 1 files · 1 commits · open

A MapTitlePhysicalPages call told sparse about every 64 KiB page it mapped in a sparse window on its own: one UpdateTileMappings and one fence Signal per page, about 0.5 ms a page on NVIDIA. In Series S mode (device_type = "lockhart") the retail title maps about 3.6 GB in one call at boot. Its main thread stayed in that call for 24 s, and the title's stall check ended it with the null write at +0x2215c35 at 34 s, before the first frame. map_pages now gathers neighbouring sparse pages into runs and commits each run with one sparse::committed call. A run is committed early whenever the same call is about to decommit one of its pages: a page moving away from an address still in the run, or homes being given back. Part of #232.

What is in it

  • crates/xcl/src/hle/kernelx.rs: SparseRun (add / holds / flush) used by map_pages, flushed before move_away / move_home_away can decommit a page in the run, on both error returns and at the end of the call. GIVE_BACK_PAGES names the existing 4096. Unit test sparse_pages_are_committed_once_per_run.

Tested

  • NVIDIA GeForce RTX 2060 Laptop (6 GB, driver 595.79, 32-lane waves), Intel i7-10750H, 16 GB RAM, Windows 11 10.0.26200, Rust 1.97.1 MSVC, debug tests / release title runs.
  • cargo test --workspace -- --test-threads=4 with DXC 1.9.2609 (XCL_DXC_DIR): 892 passed, 0 failed, 42 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (needs Developer Mode).
  • Retail title 1.0.2.1 in Series S mode, scripts/smoke.ps1 -Seconds 120, sparse pools from the XCL_ACTIVITY memory lines:
    • main 4178e88: sparse pools grow 256 MB every 2 s from 10 s to 34 s (3648 MB), no present, then 0xc0000005 at +0x2215c35 at 34.3 s.
    • this PR: 4288 MB mapped by 10 s, first presents at 20 s, frames through 88 s. It then stops at #914 (a 1920x1080 R9G9B9E5 render target / UAV refused on NVIDIA, 0x80000003 at +0xcc2834), which this PR does not touch (#242 / #605 address it).
  • Series X mode: no change expected (the title's boot maps far less there); the regression runs below are Series X.

Regression run
main (4178e88):

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 2060
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2725 (PresentX 2725)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14755 MB

this PR (f03d411):

xcl-smoke v1
commit: f03d411812577ca4334f241df3298467a89d55d8
gpu: NVIDIA GeForce RTX 2060
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2859 (PresentX 2859)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14747 MB

Both runs loaded DXC 1.6 from the Windows SDK: the DXC 1.9 folder is on D:, which the default D: console mount hides on main (#833).

Not tested

  • AMD and Intel GPUs; whether AMD's UpdateTileMappings cost per call is as high.
  • Series S past #914 (needs #242 or #605), and Series X world loading with this change.

AI use

  • Claude Code with Claude Opus 5.5: found the cause from the thread dump, wrote the change, the test and this description. I reviewed the diff and ran the tests and the title on my machine.
**@⁠gavinnolan** on GitHub · 2026-11-24 20:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1792) `gavinnolan:kernelx-batch-sparse-commits` → `main` · +80 −2 · 1 files · 1 commits · open A `MapTitlePhysicalPages` call told `sparse` about every 64 KiB page it mapped in a sparse window on its own: one `UpdateTileMappings` and one fence `Signal` per page, about 0.5 ms a page on NVIDIA. In Series S mode (`device_type = "lockhart"`) the retail title maps about 3.6 GB in one call at boot. Its main thread stayed in that call for 24 s, and the title's stall check ended it with the null write at `+0x2215c35` at 34 s, before the first frame. `map_pages` now gathers neighbouring sparse pages into runs and commits each run with one `sparse::committed` call. A run is committed early whenever the same call is about to decommit one of its pages: a page moving away from an address still in the run, or homes being given back. Part of #232. **What is in it** - `crates/xcl/src/hle/kernelx.rs`: `SparseRun` (add / holds / flush) used by `map_pages`, flushed before `move_away` / `move_home_away` can decommit a page in the run, on both error returns and at the end of the call. `GIVE_BACK_PAGES` names the existing 4096. Unit test `sparse_pages_are_committed_once_per_run`. **Tested** - NVIDIA GeForce RTX 2060 Laptop (6 GB, driver 595.79, 32-lane waves), Intel i7-10750H, 16 GB RAM, Windows 11 10.0.26200, Rust 1.97.1 MSVC, debug tests / release title runs. - `cargo test --workspace -- --test-threads=4` with DXC 1.9.2609 (`XCL_DXC_DIR`): 892 passed, 0 failed, 42 ignored. `SKIPPED`: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (needs Developer Mode). - Retail title 1.0.2.1 in Series S mode, `scripts/smoke.ps1 -Seconds 120`, sparse pools from the `XCL_ACTIVITY` memory lines: - `main` 4178e88: sparse pools grow 256 MB every 2 s from 10 s to 34 s (3648 MB), no present, then `0xc0000005` at `+0x2215c35` at 34.3 s. - this PR: 4288 MB mapped by 10 s, first presents at 20 s, frames through 88 s. It then stops at #914 (a 1920x1080 R9G9B9E5 render target / UAV refused on NVIDIA, `0x80000003` at `+0xcc2834`), which this PR does not touch (#242 / #605 address it). - Series X mode: no change expected (the title's boot maps far less there); the regression runs below are Series X. **Regression run** main (`4178e88`): ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: NVIDIA GeForce RTX 2060 title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 2725 (PresentX 2725) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14755 MB ``` this PR (`f03d411`): ``` xcl-smoke v1 commit: f03d411812577ca4334f241df3298467a89d55d8 gpu: NVIDIA GeForce RTX 2060 title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 2859 (PresentX 2859) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14747 MB ``` Both runs loaded DXC 1.6 from the Windows SDK: the DXC 1.9 folder is on `D:`, which the default `D:` console mount hides on `main` (#833). **Not tested** - AMD and Intel GPUs; whether AMD's `UpdateTileMappings` cost per call is as high. - Series S past #914 (needs #242 or #605), and Series X world loading with this change. **AI use** - Claude Code with Claude Opus 5.5: found the cause from the thread dump, wrote the change, the test and this description. I reviewed the diff and ran the tests and the title on my machine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:28 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 21:30 UTC · original · edited 2026-11-24 21:50 UTC

Full-suite run, since this PR has no test report yet. Tested exact head f03d411 (on its base 4178e88).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 890 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: sparse_pages_are_committed_once_per_run.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 892 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (#1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 21:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1792#issuecomment-7145023331) · edited 2026-11-24 21:50 UTC Full-suite run, since this PR has no test report yet. Tested exact head `f03d411` (on its base `4178e88`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record`: **890 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `sparse_pages_are_committed_once_per_run`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **892 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)). - Two tests were skipped with `--skip` on NVIDIA. Both fail on main `7f7e768` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns their skips into failures. `heap_window_out_of_memory_falls_back_to_the_switch_form` skips when `XCL_HEAP_WINDOWS` is unset (#1651), and `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set `XCL_REQUIRE_GPU`, so there both just print SKIPPED. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 23:41 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 23:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1792#issuecomment-7147694708) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠Royalflamejlh on GitHub · 2026-11-25 00:37 UTC · original

Linux (Wine + vkd3d-proton) + NVIDIA test of f03d411 in Series S mode, 2 runs of 60 s each way of a retail title on main 80f4819 + #684: with it the first present came in the 2 s activity line ending at 6 s in both runs, without it in the line ending at 8 s; the other run without it (14 s) was the first of the batch and started late throughout. The failure the description gives (24 s in one call, then the null write at game+0x2215c35 before any present) did not happen here without the change either.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch. RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 62 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), XCL_NETWORK=0, XCL_PSO_PRELOAD=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress, device_type = "lockhart" in xcl.toml (the log says console: Xbox Series S (lockhart) (title memory 8192 MiB, mode advanced)). The harness pressed A when the title presented steadily: once in two runs (18.4 s, 20.0 s), twice in one (12.4 and 20.1 s) and three times in one (18.3, 21.5 and 31.8 s). f03d411 merged onto main 80f4819 + #684 (e56dbc3) without conflicts. Order: without, with, with, without. The first run of the batch (without the change) took 3.4 s from launch to XCL's first log line against 1.2 to 1.3 s in the others, as the first Series X run did.

Tested

  • cargo test --release -p xcl --lib --target x86_64-pc-windows-gnu sparse_pages_are_committed_once_per_run -- --test-threads=4 under Wine, on the merge: 1 passed, 0 failed.
Series S, 60 s 80f4819 + #684, run 1 / 2 the same + f03d411, run 1 / 2
first 2 s activity line with a present 14.0 s / 8.0 s 6.0 s / 6.0 s
first line with 50 presents or more 16.0 s / 10.0 s 10.0 s / 8.0 s
frames presented 1305 / 1393 1466 / 1545
0x80000003 at game+0xb18de7 35.7 s / 23.9 s 23.2 s / 22.1 s
presents per 2 s line, 42 s to 58 s 60 or 61 in every line 60 in every line
first memory line with the sparse pools at 4,096 MB or more 10.0 s / 6.0 s 4.0 s / 4.0 s

Every 30th frame was dumped and all were black in all four runs (0 of 129,600 samples not black), with and without the change. In Series X mode the same dump has picture from frame 140.

From XCL's "UMA opened" line to "textures in title memory" took 6.2 s and 3.3 s without the change and 1.8 s and 1.7 s with it. Without it the pools grew by 1,152 to 2,496 MB per 2 s line once the growth was under way, against the 256 MB per 2 s in the description. At that rate the growth is over in 3 to 6 s, which I take to be why the 24 s stall does not appear here.

The breakpoint at game+0xb18de7 came 3.1 to 3.9 s after the last A press. It came in all four runs, with and without the change, so it is not this change's; the title went on presenting after it, and I have not looked into it.

In the default Series X profile (main 689f2db + #684, 2 pairs of 40 s, the run with it first in each): the second pair had its first present at 4.0 s and 50 presents or more from 14.0 s on both sides, and 939 frames with it against 940 without. With it, one tile fewer was mapped at 2,048 sparse submits in both pairs (15,224 against 15,225); I did not find which tile or why. The first run with it started 6 s later throughout (first present at 10.0 s). It was the first run of its batch, and the first run of the Series S batch was late the same way. I do not know the cause.

Read

  • kernelx.rs:990 (SparseRun) and :1359, :1418: neighbouring pages are gathered and committed once, and :1370 flushes the run before a move can decommit one of its pages, as the description says (lines as merged onto 80f4819; :934, :1297, :1356 and :1308 at the head).

Not tested: the length of the title's one call (the memory lines show only the pools' growth); why every dumped frame is black in Series S mode; Series S past 60 s; the rest of the suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the test and the eight runs and wrote this report.

Posted without review by a person: the account owner was away and reads replies later.

**@⁠Royalflamejlh** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1792#issuecomment-7148710207) Linux (Wine + vkd3d-proton) + NVIDIA test of `f03d411` in Series S mode, 2 runs of 60 s each way of a retail title on `main` `80f4819` + #684: with it the first present came in the 2 s activity line ending at 6 s in both runs, without it in the line ending at 8 s; the other run without it (14 s) was the first of the batch and started late throughout. The failure the description gives (24 s in one call, then the null write at `game+0x2215c35` before any present) did not happen here without the change either. **Setup:** Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch. RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 62 GB RAM. Release, cross-compiled to `x86_64-pc-windows-gnu` (rustc 1.98.0), `XCL_NETWORK=0`, `XCL_PSO_PRELOAD=0`. Retail title 1.0.2.1, the first-run screens completed once and no story progress, `device_type = "lockhart"` in `xcl.toml` (the log says `console: Xbox Series S (lockhart) (title memory 8192 MiB, mode advanced)`). The harness pressed A when the title presented steadily: once in two runs (18.4 s, 20.0 s), twice in one (12.4 and 20.1 s) and three times in one (18.3, 21.5 and 31.8 s). `f03d411` merged onto `main` `80f4819` + #684 (`e56dbc3`) without conflicts. Order: without, with, with, without. The first run of the batch (without the change) took 3.4 s from launch to XCL's first log line against 1.2 to 1.3 s in the others, as the first Series X run did. **Tested** - `cargo test --release -p xcl --lib --target x86_64-pc-windows-gnu sparse_pages_are_committed_once_per_run -- --test-threads=4` under Wine, on the merge: 1 passed, 0 failed. | Series S, 60 s | `80f4819` + #684, run 1 / 2 | the same + `f03d411`, run 1 / 2 | |---|---|---| | first 2 s activity line with a present | 14.0 s / 8.0 s | 6.0 s / 6.0 s | | first line with 50 presents or more | 16.0 s / 10.0 s | 10.0 s / 8.0 s | | frames presented | 1305 / 1393 | 1466 / 1545 | | `0x80000003` at `game+0xb18de7` | 35.7 s / 23.9 s | 23.2 s / 22.1 s | | presents per 2 s line, 42 s to 58 s | 60 or 61 in every line | 60 in every line | | first memory line with the sparse pools at 4,096 MB or more | 10.0 s / 6.0 s | 4.0 s / 4.0 s | Every 30th frame was dumped and all were black in all four runs (0 of 129,600 samples not black), with and without the change. In Series X mode the same dump has picture from frame 140. From XCL's "UMA opened" line to "textures in title memory" took 6.2 s and 3.3 s without the change and 1.8 s and 1.7 s with it. Without it the pools grew by 1,152 to 2,496 MB per 2 s line once the growth was under way, against the 256 MB per 2 s in the description. At that rate the growth is over in 3 to 6 s, which I take to be why the 24 s stall does not appear here. The breakpoint at `game+0xb18de7` came 3.1 to 3.9 s after the last A press. It came in all four runs, with and without the change, so it is not this change's; the title went on presenting after it, and I have not looked into it. In the default Series X profile (`main` `689f2db` + #684, 2 pairs of 40 s, the run with it first in each): the second pair had its first present at 4.0 s and 50 presents or more from 14.0 s on both sides, and 939 frames with it against 940 without. With it, one tile fewer was mapped at 2,048 sparse submits in both pairs (15,224 against 15,225); I did not find which tile or why. The first run with it started 6 s later throughout (first present at 10.0 s). It was the first run of its batch, and the first run of the Series S batch was late the same way. I do not know the cause. **Read** - `kernelx.rs:990` (`SparseRun`) and `:1359`, `:1418`: neighbouring pages are gathered and committed once, and `:1370` flushes the run before a move can decommit one of its pages, as the description says (lines as merged onto `80f4819`; `:934`, `:1297`, `:1356` and `:1308` at the head). **Not tested:** the length of the title's one call (the memory lines show only the pools' growth); why every dumped frame is black in Series S mode; Series S past 60 s; the rest of the suite; AMD and Intel. **AI use:** Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the test and the eight runs and wrote this report. Posted without review by a person: the account owner was away and reads replies later.
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/1792/head:github-bot/gh-1792'
git switch 'github-bot/gh-1792'

Merge

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