Memory: keep single-window sparse_reserve allocations inside one window #2886
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T21:25:40Z.
Targets
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.Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-26T21:43:51Z.
@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.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T21:50:42Z.
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.Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T12:21:08Z.
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.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T16:25:34Z.
Merge status (I have been asked to prepare merges of PRs with several independent tests; the bar is: no open critical finding or performance regression, a fresh check of the merge result against today's
main, and green required checks. Each merge is still confirmed by a person.)This is against
nvidia-dev, whereBuild and testis red on every open PR because of the branch's own test run, so nothing there can go in until that is fixed. I will run it in the world on an RTX 4080 16 GB with the current fast setup and post the result here, so the evidence is ready when the branch's check is green again.AI use: Claude Code (Claude Fable 5.2).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T23:14:25Z.
merge-check
base: d1be8103644791b7a65f068954324e93d4b1b565 (
nvidia-devwhen tested)head: 237b7181b9b973a781dad8825101f03506237858
merge: clean (
git merge --no-commit --no-ffin a detached base worktree)build:
cargo build --workspace --locked-> oktests:
cargo test --workspace --locked --no-fail-fast -- --test-threads=4-> merge result 1,824 passed, 9 failed, 48 ignored, 26 skip notices; exact base with the same command and hardware 1,823 passed, 9 failed, 48 ignored, 26 skip notices. All nine failing instances matched; the PR's new sparse-reservation regression passed. Failures are listed below.review: none after reading the complete one-file diff and tracing
sparse_reservethroughtake_sparse_in, its free-list mutation, and the shared lock. The new behavior prefers one upper window when available; its cross-window fallback under fragmentation remains intentional. Checked arithmetic rejects oversized reservations.performance: reasoned, not timed. At most one extra free-list scan occurs for a
<= 4 GiBreservation when no single upper window fits. This is an allocation path; I did not measure title startup or frame time. No new per-frame loop was added.verdict: not yet: the required
Build and testcheck onnvidia-devis red. This merge introduced no additional failures in my paired suite; the branch's inherited failures still need resolution before its CI gate can pass. I did not rerun the title smoke in this check.hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GB / driver 621.35, rustc 1.99.1 MSVC. Codex (GPT-6.2 Sol) read the diff and ran the paired build and suites; Codex (GPT-6.2 Astra) independently checked the allocator invariant by static inspection.
Same nine failures on base and merge result
console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(1)gpu_parts_of_a_texture_go_up_and_the_rest_staysandpieces_hold_the_texels_of_their_levels(2)console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(1)async_compute_pso_registers_real_pso_and_not_standin(1)split_compute_prefers_the_offline_whole_pipeline(2)two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(2)Imported from ivall/xcl. Originally posted by throny on 2026-11-28T00:06:11Z.
merge-check claim
head:
237b7181b9Imported from ivall/xcl. Originally posted by throny on 2026-11-28T00:30:23Z.
merge-check
base:
d1be8103(nvidia-dev)head:
237b7181b9merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1825 passed, 8 failed, 48 ignored (27 SKIPPED lines). The 8 failures are the base's own on this GPU, the same six names with and without the PR (#2771 and #2788 fix three of them). Base alone: 1824 passed, 8 failed, 48 ignored.
review: none. A reservation of one window or less first tries to fit inside one window above window 0, then the old two attempts; the size rounding is overflow-checked; the new test fails on the base by reading the code. From the thread: it does not stop the #2867 crashes, and the description now says 'related'.
performance: default path, not per frame: up to three first-fit scans per title reservation; a reservation of 4 GiB or less now moves to the next window instead of straddling two (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite unless said).