Repository navigation
Conversation
83f9c91 to
68a6640
Compare
… a list scanned per page Before the device exists, `sparse::committed` appended one entry per call to a list and `sparse::decommitted` scanned the whole list, so moving N pages away cost O(N^2). The list is now a BTreeMap of disjoint, merged page ranges: a commit or a decommit is O(log n). A range counts every page it touches, as `committed` / `decommitted` do once the state exists, and a decommit now takes out only its pages. The list dropped every entry a decommit overlapped, so after `commit_homes` (several pages in one call) and `move_home_away` (one of them), `init` left the still-committed pages as holes. Tests: random sequences against a page-set model and against the old list (one entry per page, the case it handled exactly), one page out of a multi-page range, and an ignored timing probe (`early_commit_timing`). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
68a6640 to
8f662ea
Compare
|
Rebased again, now on main eaa36b6 (8f662ea, no conflicts). Overlaps: #187 also reworks the code around the homes in |
|
Merged into main (6da33fa) as 68a6640, the head before your last rebase - the same patch (identical patch-id), so GitHub does not show it as merged; closing it by hand. Checked on an RX 9070 (RDNA4) with the 22 PRs merged together: 582 unit tests passed, 0 failed, the integration and e2e tests passed, and the retail game still reaches its first menu (646 frames in 30 s, no device removal). Thanks! |
Before the D3D12 device exists,
sparse::committedappended one(addr, len)per call toEARLY, andsparse::decommittedranEARLY.retain(..)over the whole list each time. Moving N pages away therefore cost O(N²). This was found in the #187 review: #187 and #203 put more of the retail title's memory in sparse ranges, which sends it down this path.Complementary to #203. #203 fixes the same pattern after the device exists:
decommit_tilesprunedto_zeroat every decommit, and #203 prunes it once. This PR is the pre-device path only and does not touchdecommit_tiles. gw1337x's watchdog stack on #187 (unmap_away → sparse::decommitted → Vec::retain) fits either retain, and #203 ties the same watchdog to the post-device one.Change
EARLYis now aBTreeMapof disjoint page ranges (start → end), merged with their neighbours. A commit or decommit before the device is O(log n).initcommits the ranges once the windows exist, as before.A range counts every page it touches, as
committed/decommittedalready do once the state exists. A decommit takes out only its own pages.One behaviour change. The old list dropped every entry a decommit overlapped. So after
commit_homescommitted several pages in one call andmove_home_awaygave one of them back,initleft the pages that were still committed as holes. They are now kept.Timing
Release build, Ryzen 9 9950X, CPU only (no device, so the early path), one run each.
early_commit_timing(new, ignored) commits 64 KiB pages one at a time, then decommits them one at a time in reverse:mainXMemMapPhysicalPagesScatterin reverse, then unmap, throughkernelx. The sparse and plain targets differ only incommitted/decommitted. The probe is the one from the #187 review and is not in this PR.mainmainWith this PR the sparse cost matches the plain one.
This does not remove the whole stall, and probably isn't its main cause. In a release build the old early path would cost only about 1 s even at 100,000 pages, so the debug-build numbers in the #187 review overstated it, and the after-device retain that #203 fixes is the likelier culprit. The scatter itself costs about 0.27 ms per page on plain memory too, linear in the page count (about 27 s at 100,000 pages if that holds). I have not found where that goes. Hoisting
page_homeout ofunmap_away'saway.gone.retainsaved only about 7%, so it is not in this PR.Tests
early_commits_are_the_pages_a_page_set_holds: 8 seeds × 4,000 random commits and decommits, unaligned ones included. After each step, the pages match a page-set model, and the ranges are page-aligned, disjoint and merged.early_commits_match_the_old_list_for_page_entries: 20,000 random steps against the old list, for what it handled exactly (single-page commits, page-aligned decommits of any length). The resulting pages are the same.early_decommit_of_one_page_keeps_the_rest: the case the old list got wrong.early_removefails the first two tests.cargo test --release -p xcl --lib -- --test-threads=4on Windows 11 with an RTX 5070 Ti (NVIDIA 610.74):83f9c91on956a476)main, the control (plus 3 ignored local probes)8c0346d), clean merge7cbd008), clean mergeThe 3 extra passes on this branch are its new tests. The extra ignored test is
early_commit_timing.Not tested:
AI-assisted (Claude Code); synthetic memory only, no game files.
🤖 Generated with Claude Code