Memory: keep single-window sparse_reserve allocations inside one window #2886
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!2886
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2886"
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?
@Decodere on GitHub · 2026-11-26 21:25 UTC · original
Decodere:fix-sparse-reserve-single-window→nvidia-dev· +57 −6 · 1 files · 1 commits · openTargets
nvidia-dev(eae01502). Related to #2867.After
3292b096moved physical page homes out of window 0 into windows 1+ viaUma::sparse_alloc_above, Series S sparse-heap layouts place 664+ MiB of physical homes at the start of window 1 (0x11_0000_0000), leaving under 3.35 GiB in window 1 while window 2 (0x12_0000_0000) has a full 4 GiB free. BecauseUma::sparse_reservealways passedsingle_window = false, a title reservation of at most one window (for example ~3.4 GiB) straddled the window 1 / window 2 boundary (0x12_0000_0000) instead of landing wholly inside window 2. Multiple sparse-window paths (title_buffer_window,uma_window_buffer, andview_bytes) reject or truncate ranges that cross a 4 GiB window boundary.What is in it
crates/xcl/src/gpu/uma.rs(Uma::sparse_reserve):sizewith checked arithmetic (size.max(1).checked_next_multiple_of(GRAIN)?), matchingsparse_allocandsparse_alloc_above.size <= WINDOW, first attempttake_sparse_in(&mut g, above_0, end, size, GRAIN, true)so single-window title reservations stay inside one window in windows 1+ whenever one has room (placing a ~3.4 GiB Series S arena wholly in window 2 after 664+ MiB of window 1 physical homes).take_sparse_in(&mut g, above_0, end, size, GRAIN, false)and thentake_sparse_in(&mut g, lo, end, size, GRAIN, false)so window 0 stays uncluttered for 32-bit descriptor heaps and fragmented or multi-window (> WINDOW) reservations keep working unchanged.crates/xcl/src/gpu/uma.rs(gpu::uma::tests::sparse_reserve_keeps_single_window_reservations_inside_one_window):3292b096Series S startup layout (2892 MiB GPU heaps + 38 MiB view heap in window 0, 664 MiB physical homes in window 1) and asserts a 3500 MiBsparse_reservelands wholly in window 2 (b + 2 * WINDOW) instead of straddling0x12_0000_0000, smaller 256 MiB reservations reuse window 1's remaining tail, fragmented windows 1+ (2 GiB + 2 GiB across the boundary) still satisfy a 3 GiB reservation via cross-window fallback without touching window 0, andusize::MAXreturnsNone.Tested
rustc 1.100.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug and release onorigin/nvidia-dev(eae01502).eae01502sparse_reservewith only the new test added:cargo test -p xcl --lib -- sparse_reserve_keeps_single_window_reservations_inside_one_window --nocapture --test-threads=1: 0 passed, 1 failed (left: 73710698496=0x11_2980_0000straddling0x12_0000_0000,right: 77309411328=0x12_0000_0000).237b7181):cargo clippy --all-targets -- -A clippy::approx_constant: 0 new warnings and 0 errors incrates/xcl/src/gpu/uma.rs(1 pre-existingnvidia-devclippy error remains in untouchedcrates/xcl/src/hle/d3d12x/sparse.rs:6393).cargo test -p xcl --lib -- gpu::uma::tests:: --test-threads=1: 19 passed, 0 failed, 0 ignored (0 skipped);cargo test -p xcl --lib -- physical_homes_leave_window_0_to_the_title --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored (0 skipped).cargo test --release -p xcl --lib -- gpu::uma::tests:: --test-threads=1: 19 passed, 0 failed, 0 ignored (0 skipped);hle::kernelx::tests::: 59 passed, 0 failed, 1 ignored (0 skipped);hle::d3d12x::console_heap::tests::: 19 passed, 0 failed, 0 ignored (0 skipped).cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1819 passed, 5 failed, 48 ignored across 39 top-level test targets (30 expectedSKIPPEDnotices: 21 wave64, 3 per-lane refusals, 3 D3D12 debug layer, 2 opt-in/heap-window skips, 1 Windows driver-cache toggle). All 5 failures are pre-existing onorigin/nvidia-dev(eae01502) and unrelated touma.rs:gpu_compute_thread_limits_leave_the_lanes_past_them_out(#2854),split_compute_prefers_the_offline_whole_pipeline(#2854),console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(#2788),async_compute_pso_registers_real_pso_and_not_standin(#2770), andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.Regression run
Quiet 60 s release runs (
scripts/smoke.ps1 -Seconds 60,XCL_NETWORK=0, default flags, RTX 4060 8 GB, driver 621.14). Includes same-daymainancestor (e120925e) forpr_check.py, freshly measurednvidia-devtarget base (eae01502), and PR head (237b7181):mainancestor (e120925e, same-day baseline forpr_check.py):nvidia-devtarget base (eae01502):PR (
237b7181):Not tested
XCL_DEVICE_TYPE=lockhart+XCL_COHERENT_HEAPS=sparse:1024) world-load crash reproduction from #2867 on 12 GB hardware; this PR fixes the provenUma::sparse_reservewindow 1 / window 2 straddle and does not claim to close #2867 on its own.d3d12SDKLayers.dllnot installed), and Linux / Wine / vkd3d-proton.AI use
Uma::sparse_reserveand3292b096onorigin/nvidia-dev(eae01502), implemented the single-window-first placement and unit test, ran the baseline-fail check, clippy, unit/workspace tests, and paired 60 s retail smokes on the hardware above, and drafted this PR description.@joeypercia on GitHub · 2026-11-26 21:43 UTC · original
@Decodere thanks for the fix. I ran it on the 12 GB card from #2867, where
eae01502crashed 3 of 3 times. With #2886 it still ended in the same window, 2 of 2 runs, so it does not cover what happens here.Tree: #2867's (
nvidia-deveae01502+ #2794 + two local logging/input commits) with #2886237b7181merged, same settings as in #2867 (Series S profile,XCL_UMA_WINDOWS=16,XCL_COHERENT_HEAPS=sparse:1024,XCL_TWO_PASS_MB=3072), RTX 4070 Ti 12 GB, driver 621.40, warm caches.0x887a0006at 203.8 s; DRED device state 7 (page fault, no breadcrumbs); the NVIDIA driver logged event 153 and 24 × event 13 at that moment0xc0000005at 167.5 s ingame_scarlett_master.exe+0x4dd64da, read at0xffffffffffffffff(rcx=0x3f8000003f800000, two floats of 1.0 where a pointer was expected); crash 2 in #2867 was the same read at+0x4dd64ecSo with #2886 the crash in the title still comes, and the other run faults on the GPU instead, at the same stage of the world load. The one run with
3292b096reverted went to the 900 s cap. That fits your second point (themap_pageshome check that only looks at the first and last page) more than the reservation crossing the window boundary, but I have not tested that.AI use: Claude Code (Claude Opus 5.5) ran the runs on the hardware above, read the logs and wrote this.
@Decodere on GitHub · 2026-11-26 21:50 UTC · original
Thank you @joeypercia for testing #2886 on the 12 GB #2867 setup — really helpful data.
Understood and agreed: #2886 alone does not stop the #2867 crashes, especially with @grahamster2's hardware measurement on #2867 showing Window 2 left only 3,911 MB contiguous vs the title's 3,977 MB
MEM_64K_PAGESpool spilling into plain memory.Keeping #2886 scoped strictly to
Uma::sparse_reservepreventing<= 4 GiBreservations from straddling window boundaries when a clean single window exists (Related to #2867, not closing #2867), while leaving the Window 0 / top-down home placement fix to @grahamster2's #2867 PR.@LocranKing on GitHub · 2026-11-27 12:21 UTC · original
Tested PR #2886 (
237b7181) on Windows 11 (Series S /lockhartprofile) with a180 sopen-world smoke comparison against baseeae01502and its unit test.Environment
32.0.16.2140)nvidia-devDXIL cache (XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE_GRAPHICS=0,XCL_DRED=1).Unit test
cargo test --locked -p xcl --lib -- sparse_reserve_keeps_single_window --nocaptureon237b7181:gpu::uma::tests::sparse_reserve_keeps_single_window_reservations_inside_one_window— ok (1 passed, 0 failed)Paired
180 sOpen-World Smoke Comparison (lockhart)PresentX)eae015020x00 / 01764109.31 s25679 MB8285 MB4288 MB3647 MB#2886(237b7181)0x00 / 01845116.05 s26075 MB8528 MB4246 MB3752 MBBoth runs entered the open world cleanly with
0crashes and0device removals.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.