Memory: bound sparse UMA first-fit searches by address #483
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!483
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/483/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?
@TG0000 on GitHub · 2026-11-24 00:56 UTC · original
TG0000:perf/sparse-uma-range-search→main· +44 −1 · 1 files · 1 commits · merged 2026-11-25 01:17 UTCSparse UMA reservations specify address bounds. The allocator now uses B-tree range queries to skip holes outside those bounds, reducing work under the mutex. It tries the first entry directly and checks the immediate predecessor of the lower bound when seeking.
What is in it
gpu/uma.rs, with tests for a free range crossing the lower bound, alignment, and allocations across a 4 GiB window boundary.Tested
cargo +stable-x86_64-pc-windows-msvc build --workspaceandcargo +stable-x86_64-pc-windows-msvc build --release -p xclpassed.cargo +stable-x86_64-pc-windows-msvc test --workspace --no-fail-fast -- --test-threads=4returned 675 passed, 3 failed, 41 ignored, and 0 emitted GPU SKIPPED lines. All 9 UMA tests passed. The 3D mip readback mismatch inplaced_title_textures_share_vram_and_preserve_pixelsalso reproduced as an isolated MSVC test on2997c9a. The two other failures followed poisoned locks in the head suite.rustc +stable-x86_64-pc-windows-msvc --edition=2021 -O. Each request was 64 KiB with 64 KiB alignment in one 4 GiB window. All synthetic holes were 64 KiB, spaced 128 KiB apart. Successful allocations restored the exact fit between iterations. Median of 15 paired samples with 20,000 requests per variant in alternating order.Regression run
The first pair showed 590 frames on main and 413 on head. The repeat below held the same lock across both 45-second runs. Both pairs used a 3.5 GiB free physical memory watchdog.
Not tested
AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@MesshM on GitHub · 2026-11-24 02:11 UTC · original
Test run and review of
3462d4045d20c597ce4952d0f843fe5e6ae9a76aon AMD RDNA4 (the PR has an RX 6800 run with 3 failures). The branch is based on2997c9a, so I merged it onto currentmain9ce2070locally (clean merge, onlyuma.rs) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debug.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4) on the merge: 686 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 646 passed, 0 failed, 21 ignoredSKIPPED; all 9gpu::uma::testspass, including the two new onesplaced_title_textures_share_vram_and_preserve_pixelspasses on this RDNA4 card (its 3D mip readback mismatch on RDNA1/RDNA2 is what #470 is about), and no test failed on a poisoned lockg.0.range(..lo_bound).next_back()) replaced byNone(not committed), both new tests fail:sparse_first_fit_keeps_the_range_crossing_the_lower_boundgetslo + 4 * GRAINinstead oflo, andsparse_first_fit_skips_a_window_boundary_only_when_requestedgetsNoneinstead ofWINDOW. So they pin the case the change is about.Review: I checked that the bounded search returns what the old
iter().find_mapdid. The free ranges in the map are disjoint, so of the ranges that start belowlo_boundonly the immediate predecessor can reach into[lo_bound, hi_bound), and none that starts at or afterhi_boundcan. The candidates are therefore the same, and they are tried in the same address order (predecessor first, then the starts inside the bounds), so the first fit is the same range. Tryingfirst_key_value()before them changes nothing: if it lies outside the boundsfirst_fitreturnsNone, and if it is the predecessor it is looked at twice, with no side effects. An empty map still givesNone. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no timing of the lock hold (the benchmark in the description was not rerun); 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; each point was checked against the code.
@H0UNDZER0 on GitHub · 2026-11-24 02:14 UTC · original · edited 2026-11-24 02:20 UTC
Tested on an RTX 5080: pass, 678 passed, 0 failed. As far as I can see, this is the first run of this PR on NVIDIA.
3462d4045d20c597ce4952d0f843fe5e6ae9a76a, this PR's head as is (on its base2997c9a), release build.XCL_*variables set.cargo build --release --workspace --locked: OK, the same singlefetch_updatewarning asmain.cargo test --workspace --release --no-fail-fast --locked -- --test-threads=4, run twice (the second with--show-output): 678 passed, 0 failed, 41 ignored both times.main2997c9agives 676 / 0 / 41 on this PC: the difference is this PR's 2 new tests.SKIPPED: the usual 2,gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).umatests pass, the 2 newsparse_first_fit_*ones included. The 3 failures of the RX 6800 run in the description do not happen here:placed_title_textures_share_vram_and_preserve_pixelspasses, as it does onmainon this GPU.Not tested
main. At the time of the run that was508a0c7;git merge-treeshowed no conflict.scripts/smoke.ps1.AI use: Claude Code (Claude Opus 5.5, Claude Fable 5.2)