kernelx: a page moving between addresses is copied there, not via home #531
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!531
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/531/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Vaximous on GitHub · 2026-11-24 01:27 UTC · original
Vaximous:kernelx-direct-page-moves→main· +91 −5 · 2 files · 1 commits · closed without mergingA physical page mapped at one address and then at another (
MapTitlePhysicalPages, one page a call) went through its home:unmap_awaycommitted the home again and copied the page there,map_pagescopied it from the home to the new address, and the home was given back at the end of the call. In a sparse window every commit and decommit is a tile mapping (UpdateTileMappings, 0.12–0.15 ms each in the NVIDIA driver here), so a moved page cost four of them, two of them for the home.The retail title moves pages this way, one per call, on the thread that presents, in the loading phase after its menus. Timing probes in that phase: about 1,400 calls a second at ~0.68 ms each, 96% of that thread's time; symbolized thread dumps put it in
nvwgf2umx→D3D12Coreundersparse::State::map_tiles/unmap_tiles. When presents stop for more than about 30 s the title's own stall watchdog ends it (#232).A page that is mapped somewhere and was used there is now copied straight from its old address to the new one; the old address is given back the way
unmap_awaygives it back (nowdecommit_away). This is a speed change: what every address holds afterwards is the same as before.atsparse andoldnot, or the reverse: each address is handled on its own.atis committed withVirtualAlloc(unless it is in a coherent UMA window) and told to the sparse windows withsparse::committedif it is sparse;oldgoes throughdecommit_away, which callssparse::decommittedonly ifoldis sparse and leaves anoldin a coherent UMA window committed, asunmap_awaydid.atfails, the call returnsERROR_INVALID_ADDRESSbeforeawayis touched: the page stays mapped atold. (What was atatbefore had already been unmapped, as on the old path.)away.gonewith the home skipped: a home still inaway.gonefrom earlier in the same call stays there and is given back at the end of the call, the same net effect as before; a home already given back stays given back (before, it was committed and given back again). A home that is not lazy is no longer written with a copy the page itself does not need.Overlaps: #254 (merged) speeds up
committed_page'sVirtualQuery; it does not touch the move path, and merged on the same tree it made no difference to this phase (pause 30, 30, 30 s, all three runs ended by the watchdog). #232 is the watchdog that ends the title in the pause. #236 (open) moves sparse commits and decommits under the sparse lock (commit_initialized/decommit); this PR only calls the existingsparse::committed/decommitted, so whichever lands second needs its calls renamed. A second PR,Memory: decommitted sparse tiles stay mapped until the next submit, removes most of the remaining tile mappings of this pattern; the two do not depend on each other.What it does not achieve: the title still does not reach gameplay. With this change (and the second PR) on a local tree the loading phase no longer stalls and the title keeps loading, but its memory keeps growing (peak commit 44 GB at 300 s, still rising; local video memory 19.4 GB on a 12 GB card): memory growth as in #248 is the next stop (that tree carries an earlier form of #288).
What is in it
kernelx: a page moving between addresses is copied there, not via home(crates/xcl/src/hle/kernelx.rs,crates/xcl/src/hle/kernelx/lazy.rs): the direct path inmap_pages,decommit_awaysplit out ofunmap_away,lazy::marked, and the testa_page_moved_between_addresses_is_copied_there. The test moves a used page from one address to another and checks that its home is not given back again by the move (that is, the home was not committed for it), that a lazy home stays uncommitted, and that the data, a lazy neighbour reading zeros, a move back and mapping the whole allocation home all still hold. It fails on main ("its home is not given back after the move").Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onb545ae2: 677 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.XCL_PRESS_A_AT=14,17,21,40,60,66,72, 150 s runs, the loading pause measured as the longest stretch with 0 presents (XCL_ACTIVITYlines, 2 s windows):2997c9a), back to back, two runs each: main and this branch never reach the phase within 150 s. In all four runs the title spends about 110 s at 7–9 presents per 2 s with no DirectStorage requests (an intro / logo screen), then loads at 60 presents per 2 s; longest gap with 0 presents 2 s (main), 4 s and 2 s (this branch); 22,701–22,708 DirectStorage requests; no crash; peak commit 16.4 GB in all four.Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60, no input, release builds; main at2997c9a(this branch's base).main:
this PR:
Not tested
AI use
@brothernog on GitHub · 2026-11-24 01:57 UTC · original
Tested
b545ae2on an RTX 3050 (driver 610.88), Windows 11 Home 26300, Rust 1.100.0, debug:cargo test -p xcl --lib hle::kernelx: 25 passed, 0 failed, 1 ignored.map_pagesdisabled (so every move takes the old unmap-and-remap route),a_page_moved_between_addresses_is_copied_therefails atkernelx.rs:2225.2997c9a;git merge-treeagainstmain508a0c7is clean.Not tested: the full suite, a GPU whose UMA window is sparse (the sparse branch of the new path doesn't run here), the performance claim.
This review was AI-assisted.
@MesshM on GitHub · 2026-11-24 03:12 UTC · original
Test run of
b545ae2debc8555bd6a9b734046ed7e9752e0019on AMD RDNA4. I merged it onto currentmaindd2ae9alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 691 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 651 passed, 0 failed, 21 ignoredSKIPPED;a_page_moved_between_addresses_is_copied_therepasses.Review: The page is copied to its new address before its old one is decommitted, and the sparse bookkeeping (
sparse::committed/decommitted) follows. I checked the case of a page mapped again at the address it already has:unmap_away(away, at, ..)runs first for eachatand sends that page home, soaway.pageno longer has it and the new branch is skipped, which is correct (the slower path, as before). I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@ivall on GitHub · 2026-11-24 09:32 UTC · original
Closing as superseded by #849 (merged in
6bac4b4), the same change (a moved page is copied to its next address, not via its home), with the error path fixed after review. Thanks for the measurements!Pull request closed