Repository navigation
Conversation
A physical page mapped at one address and then mapped at another (XMemMapPhysicalPages / MapTitlePhysicalPages, one page a call) went home first: unmap_away committed its home again (home_again) and copied the page there, then map_pages copied it from home to the new address and gave the home back at the end of the call (move_home_away). In a sparse window each of those commits and decommits is a tile mapping (UpdateTileMappings), about 0.12-0.15 ms each on an RTX 4070 Ti: two of the four a moved page cost were the home's. A retail title moves tens of thousands of pages this way after its menus, one per call, on the thread that presents. Timing probes in that phase: about 1,400 calls a second at ~0.68 ms each, 96% of the thread's time, and thread dumps put it in the driver under map_tiles / unmap_tiles. With the presents stopped for more than 30 s the title's own stall watchdog ended it. A page that is mapped somewhere (and was used there) is now copied straight to its new address, and the old address is given back as unmap_away gives it back (decommit_away). Its home stays as it was: a home given back stays given back, and one still pending in away.gone is given back at the end of the call as before. A page mapped but never used (lazy) still takes the old path, which has nothing to copy. Assisted-by: Claude Code (Claude Opus 5.5)
|
Tested
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. |
|
Test run of Tested
Review: The page is copied to its new address before its old one is decommitted, and the sparse bookkeeping ( Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
A 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=4on b545ae2: 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):Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60, no input, release builds; main at 2997c9a (this branch's base).main:
this PR:
Not tested
AI use