Memory: size the coherent window by the GPU heaps alive at once #3695

Open
Prime1997 wants to merge 2 commits from upstream-pr/3695 into main
Prime1997 commented 2026-12-02 15:14:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-12-02T15:14:33Z.


Requested by Prime

The coherent window (committed, GPU-visible system memory that stays resident) is sized from the title's GPU heaps stored by its last run, plus XCL's 512 MB. kernelx never took a heap off that count when the title released it, so the stored size was the sum of every heap the title ever asked for. A title that makes and frees heaps (streaming, level changes) grew it run after run, and it was never lowered. An oversized window is resident RAM for nothing (estimated 0.3-1.5 GB); RAM was the limit in a run on a 32 GB machine (30.9 of 31.9 GB in use).

What is in it

  • Memory: size the coherent window by the GPU heaps alive at once: kernelx keeps the heaps counted for the window alive by address, in the window or in plain memory, and takes a heap off when it is released (VirtualFree of a unified-memory block or of plain memory). uma stores the most alive at once, the peak of note_coherent_need (hle/kernelx.rs, gpu/uma.rs).
  • Memory: count the coherent window's holes in its stored size: the stored size includes the holes freed heaps leave in the window, so the next run's window still fits the same heaps (gpu/uma.rs).

Tested

  • cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu on Linux: builds, no new warnings.
  • Run in Prime's batch builds since 30 Nov on an RTX 3060 Ti 8 GB, 12 threads, 32 GB, Windows 11, release, with a retail title and XCL_COHERENT_MB=512: the title reaches its world, and the window no longer grows between runs.

Regression run

  • No smoke blocks: this branch was not built and run on its own from main (Prime's call for our PRs; they merge after community testing).

Not tested

  • The full test suite on this exact branch, AMD GPUs, and a smoke comparison against main.

AI use

  • Claude Code wrote the code, the commit messages and this description; Prime ran the builds.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5609306374 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-12-02T15:14:33Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ The coherent window (committed, GPU-visible system memory that stays resident) is sized from the title's GPU heaps stored by its last run, plus XCL's 512 MB. kernelx never took a heap off that count when the title released it, so the stored size was the sum of every heap the title ever asked for. A title that makes and frees heaps (streaming, level changes) grew it run after run, and it was never lowered. An oversized window is resident RAM for nothing (estimated 0.3-1.5 GB); RAM was the limit in a run on a 32 GB machine (30.9 of 31.9 GB in use). **What is in it** - `Memory: size the coherent window by the GPU heaps alive at once`: kernelx keeps the heaps counted for the window alive by address, in the window or in plain memory, and takes a heap off when it is released (VirtualFree of a unified-memory block or of plain memory). uma stores the most alive at once, the peak of `note_coherent_need` (`hle/kernelx.rs`, `gpu/uma.rs`). - `Memory: count the coherent window's holes in its stored size`: the stored size includes the holes freed heaps leave in the window, so the next run's window still fits the same heaps (`gpu/uma.rs`). **Tested** - `cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu` on Linux: builds, no new warnings. - Run in Prime's batch builds since 30 Nov on an RTX 3060 Ti 8 GB, 12 threads, 32 GB, Windows 11, release, with a retail title and `XCL_COHERENT_MB=512`: the title reaches its world, and the window no longer grows between runs. **Regression run** - No smoke blocks: this branch was not built and run on its own from `main` (Prime's call for our PRs; they merge after community testing). **Not tested** - The full test suite on this exact branch, AMD GPUs, and a smoke comparison against `main`. **AI use** - Claude Code wrote the code, the commit messages and this description; Prime ran the builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gut0to commented 2026-12-02 16:12:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T16:12:18Z.

Code review location: crates/xcl/src/hle/kernelx.rs; line 1035

@@ -1020,19 +1024,28 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t:
                 trace_mem("VirtualAlloc (graphics heap, sparse VRAM)", 0, rounded, t as u64, p, q);
                 // nothing of it in the coherent window, noted all the same: a run whose heaps all
                 // come here stores what it put there too (`uma::note_coherent_need`)
-                crate::gpu::uma::note_coherent_need(ASKED.load(Ordering::Relaxed));
+                crate::gpu::uma::note_coherent_need(asked_now());
                 return q as *mut c_void;
             }
         }
         let asked = ASKED.fetch_add(size, Ordering::Relaxed) + size;
-        crate::gpu::uma::note_coherent_need(asked);
+        crate::gpu::uma::note_coherent_heap(size);
+        // (counted alive until it is released, `coherent_heap_released`; one Windows refuses below
+        // is taken off again)
+        let live = COHERENT_LIVE.fetch_add(size, Ordering::Relaxed) + size;

Could this counter use the allocated footprint rather than the requested byte count? Uma::alloc_where rounds each request up to GRAIN before recording it in used (gpu/uma.rs:846), but COHERENT_LIVE adds the unrounded size here and subtracts that same amount on release. Two simultaneously live 64 KiB + 1 byte heaps therefore occupy 256 KiB while contributing only about 128 KiB to the high-water value used by the 10-minute shrink; holes() cannot account for this padding because it is part of used. That can persist a window too small for the same live heaps on the next run. Could the live accounting track the rounded UMA block length and include a regression test with multiple unaligned live heaps? AI-assisted review (model: GPT-6); I checked the allocation rounding against the shrink accounting in this diff.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772577386 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#discussion_r4772577386). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T16:12:18Z. **Code review location:** `crates/xcl/src/hle/kernelx.rs`; line 1035 ~~~~diff @@ -1020,19 +1024,28 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t: trace_mem("VirtualAlloc (graphics heap, sparse VRAM)", 0, rounded, t as u64, p, q); // nothing of it in the coherent window, noted all the same: a run whose heaps all // come here stores what it put there too (`uma::note_coherent_need`) - crate::gpu::uma::note_coherent_need(ASKED.load(Ordering::Relaxed)); + crate::gpu::uma::note_coherent_need(asked_now()); return q as *mut c_void; } } let asked = ASKED.fetch_add(size, Ordering::Relaxed) + size; - crate::gpu::uma::note_coherent_need(asked); + crate::gpu::uma::note_coherent_heap(size); + // (counted alive until it is released, `coherent_heap_released`; one Windows refuses below + // is taken off again) + let live = COHERENT_LIVE.fetch_add(size, Ordering::Relaxed) + size; ~~~~ --- Could this counter use the allocated footprint rather than the requested byte count? `Uma::alloc_where` rounds each request up to `GRAIN` before recording it in `used` (`gpu/uma.rs:846`), but `COHERENT_LIVE` adds the unrounded `size` here and subtracts that same amount on release. Two simultaneously live 64 KiB + 1 byte heaps therefore occupy 256 KiB while contributing only about 128 KiB to the high-water value used by the 10-minute shrink; `holes()` cannot account for this padding because it is part of `used`. That can persist a window too small for the same live heaps on the next run. Could the live accounting track the rounded UMA block length and include a regression test with multiple unaligned live heaps? AI-assisted review (model: GPT-6); I checked the allocation rounding against the shrink accounting in this diff.
gut0to commented 2026-12-02 16:12:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T16:12:18Z.

Review: COMMENTED


AI-assisted review (model: GPT-6). I checked the coherent allocation rounding against the shrink accounting.

<!-- greyfinch-sync:ivall/xcl:review:6154639250 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#pullrequestreview-6154639250). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T16:12:18Z. **Review:** COMMENTED --- AI-assisted review (model: GPT-6). I checked the coherent allocation rounding against the shrink accounting.
Edgaras0404 commented 2026-12-02 17:43:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Edgaras0404 on 2026-12-02T17:43:48Z.


test report (not a merge-check)
base: df0cfef638 (the last main before #3655; first parent of d71578f8)
head: e665b42c4b (tested as cherry-picked onto df0cfef6; git diff base..tree is the PR's own diff, 182+/24-)
merge: clean (also clean on current main 5eaadb54, which builds; that base's suite is the #3694 breakage, so the functional run is on df0cfef6)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> base df0cfef6: lib aborted (exit 0x80004005) after 1,380 ok / 6 failed / 25 ignored, no test result:; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_f32_compares_with_nan, gpu::recomp::tests::gpu_float_compares_random, hle::d3d12x::alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads, hle::d3d12x::list_x::tests::a_put_off_call_whose_close_fails_is_not_submitted; integration 147 passed / 2 failed / 20 ignored (gpu_two_pass_cache_e2e 0/1 twice, lines 472 and 584); SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. Merge: lib aborted the same way after 1,384 ok / 4 failed / 25 ignored; the 4 are the compact-form test and the three f32 tests, all on base; the base's alloc_pool and list_x failures did not recur in either merge (list_x is the known parallel flake; alloc_pool was not run alone); integration 147/2/20 with the same two-pass failure; the three tests this PR adds/changes pass: gpu::uma::tests::holes_are_the_free_room_below_each_windows_highest_block, gpu::uma::tests::a_long_run_that_freed_heaps_lowers_the_stored_need_of_every_heap, gpu::uma::tests::only_the_sparse_heaps_settings_lower_the_stored_coherent_need (3 passed, 0 failed). Current main 5eaadb54: merges clean, build ok, but its suite is the #3694 breakage (lib aborted after 1,153 ok / 278 failed / 26 ignored; gpu_compute_e2e removed the device 0x887a0020) and was not used for functional evidence. rustc/cargo 1.100.1, debug.
review: 1) The change itself is untested: COHERENT_HEAPS/COHERENT_LIVE and coherent_heap_released have no test, and the new tests cover only holes() and settled_need(), so the claimed fix (a released heap stops counting) would regress silently. 2) XCL_COHERENT_SHRINK is a new user-facing switch, on by default, and is not in README.md; the default behaviour change (after 600 s a run may halve the stored coherent window down to its peak) should be documented. 3) The 600 s rule is a heuristic: a run that reaches 10 min but later loads a heavier level can leave the next run's window too small, and its heaps go to plain memory until the window grows back; the 60 s title run cannot measure this. The rest of the diff is small and follows the existing uma_coherent.txt pattern. No duplicate found: #632 (whole window in the first run), #3546 (commit planning), #3677 (watch ranges) and #3658 (no-buffer window address) are different changes; #3696 is stacked on this PR.
performance: 60 s smoke on df0cfef6 with the #3544 workaround XCL_DIRECT_DXIL=1 on both trees: the default (non-direct-DXIL) base run crashed at 48 s with 0xc0000005 in amdxc64.dll (the known #3544 driver crash), so the workaround isolates the memory change; the PRs do not touch shader translation. Base: 1,537 frames shown / 19,779 MB peak / 0 device removals / 0 crashes. Merge #3695: 1,584 frames / 19,550 MB / 0 removals / 0 crashes. Frames are 103.1% of base and peak 98.8% (gate: frames >=80%, peak <=125%), so the pair passes. The 600 s shrink is not reached by a 60 s run, so this checks no regression, not the lowering. Not tested: the default non-direct-DXIL path, which crashes on the base too (#3544).
verdict: test report only (not a merge-check): build and merge are clean; on df0cfef6 the merge's suite has four failures, all on the base (the base's other two did not recur), and no new one, and the three new tests pass; the 60 s pair (with the #3544 workaround) is 103.1% frames / 98.8% peak with 0 removals and 0 crashes. The missing test for the release accounting and the undocumented default-on switch are what I would ask for before merge.
hardware / tool and model: AMD Radeon RX 6700 XT 12 GB (RDNA2), driver 32.0.21045.29003; AMD Ryzen 5 5600X; Windows 10 build 19045 / OpenCode, DeepSeek V4.1 Flash 1017

Smoke blocks (60 s, XCL_DIRECT_DXIL=1, title 1778c2d9):

xcl-smoke v1
commit: df0cfef638306f325b208e5adae18d35ab4bf4ed
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1537 (PresentX 1537)
presents per 2 s (last 3): 35 59 44
device removals: 0
crashes: 0
peak commit: 19779 MB
xcl-smoke v1
commit: 1e2533ea4281c6c0b549da697b1ec5cfc16fa76a
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1584 (PresentX 1584)
presents per 2 s (last 3): 48 39 61
device removals: 0
crashes: 0
peak commit: 19550 MB
<!-- greyfinch-sync:ivall/xcl:comment:7353586525 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7353586525). Originally posted by [Edgaras0404](https://github.com/Edgaras0404) on 2026-12-02T17:43:48Z. --- test report (not a merge-check) base: df0cfef638306f325b208e5adae18d35ab4bf4ed (the last main before #3655; first parent of d71578f8) head: e665b42c4bf3fe0afa9fe170da0e22f55f73338c (tested as cherry-picked onto df0cfef6; git diff base..tree is the PR's own diff, 182+/24-) merge: clean (also clean on current main 5eaadb54, which builds; that base's suite is the #3694 breakage, so the functional run is on df0cfef6) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> base df0cfef6: lib aborted (exit 0x80004005) after 1,380 ok / 6 failed / 25 ignored, no `test result:`; failing: `gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form`, `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu`, `gpu::recomp::tests::gpu_f32_compares_with_nan`, `gpu::recomp::tests::gpu_float_compares_random`, `hle::d3d12x::alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads`, `hle::d3d12x::list_x::tests::a_put_off_call_whose_close_fails_is_not_submitted`; integration 147 passed / 2 failed / 20 ignored (`gpu_two_pass_cache_e2e` 0/1 twice, lines 472 and 584); SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`. Merge: lib aborted the same way after 1,384 ok / 4 failed / 25 ignored; the 4 are the compact-form test and the three f32 tests, all on base; the base's `alloc_pool` and `list_x` failures did not recur in either merge (`list_x` is the known parallel flake; `alloc_pool` was not run alone); integration 147/2/20 with the same two-pass failure; the three tests this PR adds/changes pass: `gpu::uma::tests::holes_are_the_free_room_below_each_windows_highest_block`, `gpu::uma::tests::a_long_run_that_freed_heaps_lowers_the_stored_need_of_every_heap`, `gpu::uma::tests::only_the_sparse_heaps_settings_lower_the_stored_coherent_need` (3 passed, 0 failed). Current main 5eaadb54: merges clean, build ok, but its suite is the #3694 breakage (lib aborted after 1,153 ok / 278 failed / 26 ignored; `gpu_compute_e2e` removed the device 0x887a0020) and was not used for functional evidence. rustc/cargo 1.100.1, debug. review: 1) The change itself is untested: `COHERENT_HEAPS`/`COHERENT_LIVE` and `coherent_heap_released` have no test, and the new tests cover only `holes()` and `settled_need()`, so the claimed fix (a released heap stops counting) would regress silently. 2) `XCL_COHERENT_SHRINK` is a new user-facing switch, on by default, and is not in `README.md`; the default behaviour change (after 600 s a run may halve the stored coherent window down to its peak) should be documented. 3) The 600 s rule is a heuristic: a run that reaches 10 min but later loads a heavier level can leave the next run's window too small, and its heaps go to plain memory until the window grows back; the 60 s title run cannot measure this. The rest of the diff is small and follows the existing `uma_coherent.txt` pattern. No duplicate found: #632 (whole window in the first run), #3546 (commit planning), #3677 (watch ranges) and #3658 (no-buffer window address) are different changes; #3696 is stacked on this PR. performance: 60 s smoke on df0cfef6 with the #3544 workaround `XCL_DIRECT_DXIL=1` on both trees: the default (non-direct-DXIL) base run crashed at 48 s with 0xc0000005 in amdxc64.dll (the known #3544 driver crash), so the workaround isolates the memory change; the PRs do not touch shader translation. Base: 1,537 frames shown / 19,779 MB peak / 0 device removals / 0 crashes. Merge #3695: 1,584 frames / 19,550 MB / 0 removals / 0 crashes. Frames are 103.1% of base and peak 98.8% (gate: frames >=80%, peak <=125%), so the pair passes. The 600 s shrink is not reached by a 60 s run, so this checks no regression, not the lowering. Not tested: the default non-direct-DXIL path, which crashes on the base too (#3544). verdict: test report only (not a merge-check): build and merge are clean; on df0cfef6 the merge's suite has four failures, all on the base (the base's other two did not recur), and no new one, and the three new tests pass; the 60 s pair (with the #3544 workaround) is 103.1% frames / 98.8% peak with 0 removals and 0 crashes. The missing test for the release accounting and the undocumented default-on switch are what I would ask for before merge. hardware / tool and model: AMD Radeon RX 6700 XT 12 GB (RDNA2), driver 32.0.21045.29003; AMD Ryzen 5 5600X; Windows 10 build 19045 / OpenCode, DeepSeek V4.1 Flash 1017 Smoke blocks (60 s, XCL_DIRECT_DXIL=1, title 1778c2d9): ```text xcl-smoke v1 commit: df0cfef638306f325b208e5adae18d35ab4bf4ed gpu: AMD Radeon RX 6700 XT title: 1778c2d9 seconds: 60 exit: 0x0 frames shown: 1537 (PresentX 1537) presents per 2 s (last 3): 35 59 44 device removals: 0 crashes: 0 peak commit: 19779 MB ``` ```text xcl-smoke v1 commit: 1e2533ea4281c6c0b549da697b1ec5cfc16fa76a gpu: AMD Radeon RX 6700 XT title: 1778c2d9 seconds: 60 exit: 0x0 frames shown: 1584 (PresentX 1584) presents per 2 s (last 3): 48 39 61 device removals: 0 crashes: 0 peak commit: 19550 MB ```
Foniass commented 2026-12-02 18:14:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:14:02Z.


Test report (not a merge-check: PR description red)
base: 5eaadb54c1
head: e665b42c4b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2976 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+182/-24). Before this PR, the coherent window's stored size was the sum of every GPU heap the title ever asked for, and on the default route it never went down. Now kernelx tracks the heaps alive at once (COHERENT_HEAPS/COHERENT_LIVE) and stores the peak alive bytes plus first-fit holes. After 600 s a run can lower the stored size by up to half. This is on by default (XCL_COHERENT_SHRINK unset = on). Findings: (1) Brings back a lowering that was removed on purpose, with no evidence. settled_need/coherent_shrink (uma.rs ~1152/~1166) lower the default route's stored size again. d75c3733c stopped exactly that, after a too-small window sent a retail title's heaps to plain memory, where its shaders read zeros (comment at kernelx.rs ~1005). After a first lowering, the asked >= before guard compares against the peak alive bytes. So a long run with less alive (a menu, a small level) can lower the size again, and the next run that loads a bigger level loses its image. The only reported run used XCL_COHERENT_MB=512, which returns early in coherent_hint_for (uma.rs ~1089) and never touches the stored size. There are no suite counts and no smoke blocks. (2) The second commit is a fixup of the first. e665b42c says it is a "Review fix for 86c5e52b", and that f4140e5b1 alone stores a size below what first-fit placement needs, so f4140e5b1 on its own is a regression and the history is not bisect-safe. Squash them. The commit bodies also cite private batch names. (3) A heap that does not fit raises the stored size less reliably than before. The size grows only when alive + holes exceeds it, but the fit check (kernelx.rs ~1041) also counts XCL's own blocks and the 96 MB KEEP. When XCL's own blocks take most of the share, a heap can be refused without raising the stored size, and it then goes to plain memory on every run. (4) Gaps and races in the live bookkeeping. On the plain-memory path, coherent_heap_released runs after Windows has freed the address (kernelx.rs ~1335), so another thread can get the same address and insert over the entry. VirtualFreeEx on fallback memory (~1369) is never counted. Both errors overcount, which is the safe side, but they defeat the shrink. COHERENT_LIVE also adds unrounded sizes while alloc_where rounds each heap up to 64 KiB (uma.rs ~846). (5) Tests cover only the pure functions. settled_need and holes() are tested. Nothing tests the kernelx accounting: create/free/reuse of an address, the fallback path, VirtualFreeEx, or that a refused heap raises the need. (6) README. XCL_COHERENT_SHRINK is not in it. Fine: holes() counts free room below each window's highest block, 2 MB alignment padding included. The sparse routes still settle at 60 s. XCL_COHERENT_SHRINK=0 keeps the old cumulative behaviour. A UMA block's release is counted before u.free.
performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (e665b42c): 1422 -> 1664 frames shown (117 %; last presents per 2 s: 61 60 60), peak commit 17184 -> 16726 MB, 0 device removals, 0 crashes.
assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: On by default it lowers the default route's coherent size again, which d75c3733c removed on purpose (a heap that no longer fits loses its image); the only run used XCL_COHERENT_MB=512, which bypasses the stored size, and there are no smoke blocks or suite counts.
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7354179026 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7354179026). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T18:14:02Z. --- Test report (not a merge-check: `PR description` red) base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: e665b42c4bf3fe0afa9fe170da0e22f55f73338c merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2976 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (+182/-24). Before this PR, the coherent window's stored size was the sum of every GPU heap the title ever asked for, and on the default route it never went down. Now kernelx tracks the heaps alive at once (`COHERENT_HEAPS`/`COHERENT_LIVE`) and stores the peak alive bytes plus first-fit holes. After 600 s a run can lower the stored size by up to half. This is on by default (`XCL_COHERENT_SHRINK` unset = on). Findings: (1) **Brings back a lowering that was removed on purpose, with no evidence.** `settled_need`/`coherent_shrink` (uma.rs ~1152/~1166) lower the default route's stored size again. d75c3733c stopped exactly that, after a too-small window sent a retail title's heaps to plain memory, where its shaders read zeros (comment at kernelx.rs ~1005). After a first lowering, the `asked >= before` guard compares against the peak alive bytes. So a long run with less alive (a menu, a small level) can lower the size again, and the next run that loads a bigger level loses its image. The only reported run used `XCL_COHERENT_MB=512`, which returns early in `coherent_hint_for` (uma.rs ~1089) and never touches the stored size. There are no suite counts and no smoke blocks. (2) **The second commit is a fixup of the first.** e665b42c says it is a "Review fix for 86c5e52b", and that f4140e5b1 alone stores a size below what first-fit placement needs, so f4140e5b1 on its own is a regression and the history is not bisect-safe. Squash them. The commit bodies also cite private batch names. (3) **A heap that does not fit raises the stored size less reliably than before.** The size grows only when alive + holes exceeds it, but the fit check (kernelx.rs ~1041) also counts XCL's own blocks and the 96 MB `KEEP`. When XCL's own blocks take most of the share, a heap can be refused without raising the stored size, and it then goes to plain memory on every run. (4) **Gaps and races in the live bookkeeping.** On the plain-memory path, `coherent_heap_released` runs after Windows has freed the address (kernelx.rs ~1335), so another thread can get the same address and `insert` over the entry. `VirtualFreeEx` on fallback memory (~1369) is never counted. Both errors overcount, which is the safe side, but they defeat the shrink. `COHERENT_LIVE` also adds unrounded sizes while `alloc_where` rounds each heap up to 64 KiB (uma.rs ~846). (5) **Tests cover only the pure functions.** `settled_need` and `holes()` are tested. Nothing tests the kernelx accounting: create/free/reuse of an address, the fallback path, `VirtualFreeEx`, or that a refused heap raises the need. (6) **README.** `XCL_COHERENT_SHRINK` is not in it. Fine: `holes()` counts free room below each window's highest block, 2 MB alignment padding included. The sparse routes still settle at 60 s. `XCL_COHERENT_SHRINK=0` keeps the old cumulative behaviour. A UMA block's release is counted before `u.free`. performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (e665b42c): 1422 -> 1664 frames shown (117 %; last presents per 2 s: 61 60 60), peak commit 17184 -> 16726 MB, 0 device removals, 0 crashes. assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: On by default it lowers the default route's coherent size again, which d75c3733c removed on purpose (a heap that no longer fits loses its image); the only run used `XCL_COHERENT_MB=512`, which bypasses the stored size, and there are no smoke blocks or suite counts. hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
throny commented 2026-12-02 18:51:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T18:51:17Z.


Review of e665b42c4 (read against main, not a merge check; our suite, smoke and world runs of a trial merge are queued and follow as a check).

  1. The default-on shrink can cost a run its picture (gpu/uma.rs ~1155 settled_need, the 600 s settle ~1194; XCL_COHERENT_SHRINK unset = on). The stored size is now the peak of live heaps plus holes, and a run can lower it by up to half. If a later run places its heaps differently, or reaches an area with a higher peak than the run that set the size, a heap misses the window and goes to plain memory, where shaders read zeros. It heals from the next run (the fallback note grows the file), so it costs one broken run per new peak. On main that can't happen, because the window is sized by everything ever asked. A margin on the stored size, or keeping the shrink opt-in, would close it.
  2. Bookkeeping slips that over-count (the safe direction):
    • COHERENT_HEAPS.insert ignores an old entry at a reused address (hle/kernelx.rs ~1035/1052).
    • On a plain-memory release the entry is removed after Windows frees the range (~1331), so a concurrent allocation at that address can lose its entry instead.
    • A heap that took the plain mem::VirtualAlloc fallback and is freed through VirtualFreeEx is never released.
  3. Description: the PR-description check wants the two xcl-smoke blocks. I'll post ours (main and this head, RTX 4080) here when they're done, if they help.

Fine: sparse heaps are not counted; no stored file and =0 behave as before; Series S naming is unchanged; the lock is dropped before holes().

AI use: Claude Code (Claude Opus 5.5) reviewed the diff; posted at throny's request.

<!-- greyfinch-sync:ivall/xcl:comment:7355253529 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7355253529). Originally posted by [throny](https://github.com/throny) on 2026-12-02T18:51:17Z. --- Review of `e665b42c4` (read against main, not a merge check; our suite, smoke and world runs of a trial merge are queued and follow as a check). 1. **The default-on shrink can cost a run its picture** (`gpu/uma.rs` ~1155 `settled_need`, the 600 s settle ~1194; `XCL_COHERENT_SHRINK` unset = on). The stored size is now the peak of live heaps plus holes, and a run can lower it by up to half. If a later run places its heaps differently, or reaches an area with a higher peak than the run that set the size, a heap misses the window and goes to plain memory, where shaders read zeros. It heals from the next run (the fallback note grows the file), so it costs one broken run per new peak. On main that can't happen, because the window is sized by everything ever asked. A margin on the stored size, or keeping the shrink opt-in, would close it. 2. **Bookkeeping slips that over-count** (the safe direction): - `COHERENT_HEAPS.insert` ignores an old entry at a reused address (`hle/kernelx.rs` ~1035/1052). - On a plain-memory release the entry is removed after Windows frees the range (~1331), so a concurrent allocation at that address can lose its entry instead. - A heap that took the plain `mem::VirtualAlloc` fallback and is freed through `VirtualFreeEx` is never released. 3. **Description:** the PR-description check wants the two `xcl-smoke` blocks. I'll post ours (main and this head, RTX 4080) here when they're done, if they help. Fine: sparse heaps are not counted; no stored file and `=0` behave as before; Series S naming is unchanged; the lock is dropped before `holes()`. *AI use: Claude Code (Claude Opus 5.5) reviewed the diff; posted at throny's request.*
throny commented 2026-12-02 20:37:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T20:37:30Z.


merge-check
base: c53e969602
head: e665b42c4b
merge: trial merge 721997d52 into main c53e96960: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; 25 SKIPPED (no wave64 and similar); failing: none
title run: retail title, RTX 4080, 300 s in the world (run 493), no crash, no device removal, 2.79 presents/s
review: the review comment above (whole diff read)
performance: two 900 s warm runs each, main c53e96960 vs this trial merge: 3.00 / (495 hung, a stall seen on main too) vs 2.82 / 2.80 presents/s; video memory peak 18.9 vs 19.1-19.2 GB; peak commit 42.1 vs 42.3-42.4 GB
verdict: not yet: the default-on shrink can cost a run its picture (review above, finding 1). Also, on this machine it showed no effect: the stored window (4.9 GB) stayed the same in two 900 s runs, as on main. Our runs set XCL_UMA_DRIVER=mixed:1536:1792, so this setup may not reach the sizing. The frame rate was 2.80 and 2.82 presents/s against main's 3.00 in the same pair of runs (2 runs each, so it may be noise).
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300 / Claude Code with Claude Opus 5.5 (builds, suite, world runs, review)

Smoke blocks for the description (60 s each, retail title):

main:

xcl-smoke v1
commit: c53e96960265a82477a9c98677afb0402e98d486
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 17578 MB

this PR's head:

xcl-smoke v1
commit: e665b42c4bf3fe0afa9fe170da0e22f55f73338c
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1538 (PresentX 1538)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15974 MB
<!-- greyfinch-sync:ivall/xcl:comment:7358043656 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7358043656). Originally posted by [throny](https://github.com/throny) on 2026-12-02T20:37:30Z. --- merge-check base: c53e96960265a82477a9c98677afb0402e98d486 head: e665b42c4bf3fe0afa9fe170da0e22f55f73338c merge: trial merge `721997d52` into main `c53e96960`: clean build: cargo build --workspace -> ok tests: cargo test --workspace -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; 25 SKIPPED (no wave64 and similar); failing: none title run: retail title, RTX 4080, 300 s in the world (run 493), no crash, no device removal, 2.79 presents/s review: the review comment above (whole diff read) performance: two 900 s warm runs each, main c53e96960 vs this trial merge: 3.00 / (495 hung, a stall seen on main too) vs 2.82 / 2.80 presents/s; video memory peak 18.9 vs 19.1-19.2 GB; peak commit 42.1 vs 42.3-42.4 GB verdict: not yet: the default-on shrink can cost a run its picture (review above, finding 1). Also, on this machine it showed no effect: the stored window (4.9 GB) stayed the same in two 900 s runs, as on main. Our runs set `XCL_UMA_DRIVER=mixed:1536:1792`, so this setup may not reach the sizing. The frame rate was 2.80 and 2.82 presents/s against main's 3.00 in the same pair of runs (2 runs each, so it may be noise). hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300 / Claude Code with Claude Opus 5.5 (builds, suite, world runs, review) Smoke blocks for the description (60 s each, retail title): main: ``` xcl-smoke v1 commit: c53e96960265a82477a9c98677afb0402e98d486 gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1563 (PresentX 1563) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 17578 MB ``` this PR's head: ``` xcl-smoke v1 commit: e665b42c4bf3fe0afa9fe170da0e22f55f73338c gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1538 (PresentX 1538) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15974 MB ```
throny commented 2026-12-03 06:54:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T06:54:14Z.


Merge check: safe (head e665b42c4, merged onto main 16c2fd082)

  • RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300, release build
  • cargo test --workspace -- --test-threads=4: 3014 passed, 0 failed, 56 ignored; 25 SKIPPED lines, no test binary ended abnormally
  • retail title, 300 s world run with default settings (+ XCL_RESIDENCY_PRIORITY=1): reached the world, no device removal, no crash, first frame 11.18 s, 2.89 presents/s (main 2.88 on the same setup today), 0 Aftermath dumps
  • diff scanned, nothing of concern

Not tested: AMD/Intel cards.

AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7370366079 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7370366079). Originally posted by [throny](https://github.com/throny) on 2026-12-03T06:54:14Z. --- **Merge check: safe** (head e665b42c4, merged onto main 16c2fd082) - RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300, release build - `cargo test --workspace -- --test-threads=4`: 3014 passed, 0 failed, 56 ignored; 25 SKIPPED lines, no test binary ended abnormally - retail title, 300 s world run with default settings (+ `XCL_RESIDENCY_PRIORITY=1`): reached the world, no device removal, no crash, first frame 11.18 s, 2.89 presents/s (main 2.88 on the same setup today), 0 Aftermath dumps - diff scanned, nothing of concern Not tested: AMD/Intel cards. AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.
AAsobu commented 2026-12-03 11:41:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by AAsobu on 2026-12-03T11:41:47Z.


merge-check
base: 16c2fd082a
head: e665b42c4b
merge: clean (merged tree c1b5153f)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3014 passed, 0 failed, 56 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 3 no D3D12 debug layer); failing: none
review: read the whole diff (+182/-24, uma.rs, kernelx.rs); no finding in the code itself. On this title the window does not come down: 2 s into a run 3998 of its 4095 MB are in use and three more heaps (596, 19 and 33 MB) go to plain memory, so the heaps alive at once (~4.6 GB) are as large as what was stored (4582 MB). Two 660 s runs in the world (past SETTLED_ALL) wrote no lowering line, and the stored size rose to 4679 MB. In the world this merge ran fine: presents per 2 s 4.79 / 4.85, peak commit 39802 / 39353 MB, peak VRAM 16189 / 15870 MB, no device removal.
smoke: scripts/smoke.ps1 -Game <folder> (60 s), run in alternation at the same time: this merge 2 frames in 3 of 3 runs (peak commit 10255-10286 MB); main 16c2fd08 1571 / 1614 / 1624 frames in 3 of 3 (~30 presents per 2 s at the end, peak commit 14555-14673 MB); this merge with XCL_COHERENT_SHRINK=0 1600 frames (1 run). Two smoke runs of main earlier the same day stopped at 2 frames too, so where the title gets to in 60 s depends on some state I have not pinned down, but in the same hour the switch alone separates the two outcomes. With the switch on, the PR's smoke log has one 1000 ms wait for a graphics pipeline; I have not found why it stays at 2 frames.
performance: in-world frames and memory as above; the smoke shows this merge at 2 frames against main's ~1600 (under the 80 % CONTRIBUTING asks).
verdict: not yet: with XCL_COHERENT_SHRINK=1 (the default) the 60 s smoke stops at 2 frames where main and this merge with the switch off reach ~1600 (3 of 3 against 4 of 4); the window size itself does not change on this title.
hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300 / Claude Code (Claude Opus 5.5), results checked by me

<!-- greyfinch-sync:ivall/xcl:comment:7377055343 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7377055343). Originally posted by [AAsobu](https://github.com/AAsobu) on 2026-12-03T11:41:47Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: e665b42c4bf3fe0afa9fe170da0e22f55f73338c merge: clean (merged tree c1b5153f) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3014 passed, 0 failed, 56 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 3 no D3D12 debug layer); failing: none review: read the whole diff (+182/-24, `uma.rs`, `kernelx.rs`); no finding in the code itself. On this title the window does not come down: 2 s into a run 3998 of its 4095 MB are in use and three more heaps (596, 19 and 33 MB) go to plain memory, so the heaps alive at once (~4.6 GB) are as large as what was stored (4582 MB). Two 660 s runs in the world (past `SETTLED_ALL`) wrote no lowering line, and the stored size rose to 4679 MB. In the world this merge ran fine: presents per 2 s 4.79 / 4.85, peak commit 39802 / 39353 MB, peak VRAM 16189 / 15870 MB, no device removal. smoke: `scripts/smoke.ps1 -Game <folder>` (60 s), run in alternation at the same time: this merge 2 frames in 3 of 3 runs (peak commit 10255-10286 MB); `main` `16c2fd08` 1571 / 1614 / 1624 frames in 3 of 3 (~30 presents per 2 s at the end, peak commit 14555-14673 MB); this merge with `XCL_COHERENT_SHRINK=0` 1600 frames (1 run). Two smoke runs of `main` earlier the same day stopped at 2 frames too, so where the title gets to in 60 s depends on some state I have not pinned down, but in the same hour the switch alone separates the two outcomes. With the switch on, the PR's smoke log has one 1000 ms wait for a graphics pipeline; I have not found why it stays at 2 frames. performance: in-world frames and memory as above; the smoke shows this merge at 2 frames against `main`'s ~1600 (under the 80 % CONTRIBUTING asks). verdict: not yet: with `XCL_COHERENT_SHRINK=1` (the default) the 60 s smoke stops at 2 frames where `main` and this merge with the switch off reach ~1600 (3 of 3 against 4 of 4); the window size itself does not change on this title. hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300 / Claude Code (Claude Opus 5.5), results checked by me
Foniass commented 2026-12-03 16:41:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T16:41:27Z.


merge-check
base: 16c2fd082a
head: e665b42c4b
merge: clean
build: ok
tests: 3014 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 2 high, 4 medium, 2 nits (below)
performance: 60 s smoke run: 1683 → 1657 frames (98 % of main), peak commit 18505 → 18440 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 240 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: 2 blocking findings (critical or high, below); also PR description is red
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: kernelx now tracks the GPU heaps alive at once (COHERENT_HEAPS/COHERENT_LIVE) and stores the peak plus the window's holes. After 600 s a run can lower the stored size by up to half; this is on by default (XCL_COHERENT_SHRINK). The head is the one my earlier test report covered, and its findings are all still open. The default-on lowering and the untested kernelx bookkeeping block it.

High

  1. Lowers the default route's coherent size again, which d75c3733c removed on purpose. Still open from my earlier report. settled_need with Some(all) (uma.rs ~1152) and the 600 s settle lower the size stored for ALL_HEAPS. d75c3733c stopped exactly that, after a too-small window sent a retail title's heaps to plain memory, where its shaders read zeros. A long run in a smaller area that asked for as much as is stored, but had less alive at once, lowers the size. The next run that reaches a bigger peak then loses the image of the heaps that miss the window, until the fallback note grows the size back. The only run reported used XCL_COHERENT_MB=512, which never reads the stored size. Keep the lowering opt-in, or keep a margin on the stored size.
  2. The kernelx bookkeeping has no test. Still open from my earlier report. Only the pure helpers holes() and settled_need are tested. Nothing tests the change itself: that a released heap stops counting, that a reused address replaces its entry, the plain-memory fallback, or that a refused heap raises the stored size (kernelx.rs ~1035-1066, ~1107). A test that makes and frees heaps through VirtualAlloc/VirtualFree and checks COHERENT_LIVE and the noted need would cover it.

Medium

  1. The second commit is a fixup of the first. Still open. e665b42c describes itself as a "Review fix for 86c5e52b" and says f4140e5b1 alone stores a size below what first-fit placement needs, and that it never heals. So f4140e5b1 on its own is a regression and the history is not bisect-safe. Squash the two. The commit bodies also cite private batch names (own10, own11, 1f5d4d57).
  2. A heap the window refuses may not raise the stored size. Still open. The fit check (kernelx.rs ~1041) also counts XCL's own blocks and the 96 MB KEEP. The need noted after a refusal, alive plus holes, leaves both out. When XCL's own blocks take most of its 512 MB share, a heap can be refused while alive plus holes stays at or below the stored size. It then goes to plain memory on every run.
  3. Gaps in the live bookkeeping. Still open. On the plain-memory path coherent_heap_released runs after Windows has freed the range (~1335), so another thread can get the same address and its entry is lost. A heap freed through VirtualFreeEx is never taken off. COHERENT_LIVE adds unrounded sizes while alloc_where rounds each block up to 64 KiB, so the stored need can come out a little under what the same heaps take (noted in the inline review on ~1035). The first two overcount and defeat the lowering; the rounding undercounts.
  4. Description gaps. AI use says "Claude Code" without the exact model, there is no issue link, and Tested has no suite counts: the only run listed is a cargo check with the windows-gnu target on Linux.

Nit

  1. XCL_COHERENT_SHRINK is not in README. It is a new switch that is on by default and changes how the window is sized from run to run.
  2. Misplaced doc comment. The doc comment written for a_long_run_that_freed_heaps_lowers_the_stored_need_of_every_heap sits above holes_are_the_free_room_below_each_windows_highest_block (uma.rs ~1849).
Checked and fine
  • holes() counts only the free runs below each window's highest block, the 2 MB alignment padding included, and has its own test
  • The sparse routes still settle at 60 s, and XCL_COHERENT_SHRINK=0 keeps the old sum of everything asked for, never lowered
  • coherent_fallback is the old tail of VirtualAlloc moved into a function, unchanged; a UMA block's release is counted before u.free
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 60 61 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7385273207 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3695#issuecomment-7385273207). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T16:41:27Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: e665b42c4bf3fe0afa9fe170da0e22f55f73338c merge: clean build: ok tests: 3014 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 2 high, 4 medium, 2 nits (below) performance: 60 s smoke run: 1683 → 1657 frames (98 % of main), peak commit 18505 → 18440 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 240 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: 2 blocking findings (critical or high, below); also `PR description` is red hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** kernelx now tracks the GPU heaps alive at once (COHERENT_HEAPS/COHERENT_LIVE) and stores the peak plus the window's holes. After 600 s a run can lower the stored size by up to half; this is on by default (XCL_COHERENT_SHRINK). The head is the one my earlier test report covered, and its findings are all still open. The default-on lowering and the untested kernelx bookkeeping block it. #### High 1. **Lowers the default route's coherent size again, which d75c3733c removed on purpose.** Still open from my earlier report. settled_need with Some(all) (uma.rs ~1152) and the 600 s settle lower the size stored for ALL_HEAPS. d75c3733c stopped exactly that, after a too-small window sent a retail title's heaps to plain memory, where its shaders read zeros. A long run in a smaller area that asked for as much as is stored, but had less alive at once, lowers the size. The next run that reaches a bigger peak then loses the image of the heaps that miss the window, until the fallback note grows the size back. The only run reported used XCL_COHERENT_MB=512, which never reads the stored size. Keep the lowering opt-in, or keep a margin on the stored size. 2. **The kernelx bookkeeping has no test.** Still open from my earlier report. Only the pure helpers holes() and settled_need are tested. Nothing tests the change itself: that a released heap stops counting, that a reused address replaces its entry, the plain-memory fallback, or that a refused heap raises the stored size (kernelx.rs ~1035-1066, ~1107). A test that makes and frees heaps through VirtualAlloc/VirtualFree and checks COHERENT_LIVE and the noted need would cover it. #### Medium 3. **The second commit is a fixup of the first.** Still open. e665b42c describes itself as a "Review fix for 86c5e52b" and says f4140e5b1 alone stores a size below what first-fit placement needs, and that it never heals. So f4140e5b1 on its own is a regression and the history is not bisect-safe. Squash the two. The commit bodies also cite private batch names (own10, own11, 1f5d4d57). 4. **A heap the window refuses may not raise the stored size.** Still open. The fit check (kernelx.rs ~1041) also counts XCL's own blocks and the 96 MB KEEP. The need noted after a refusal, alive plus holes, leaves both out. When XCL's own blocks take most of its 512 MB share, a heap can be refused while alive plus holes stays at or below the stored size. It then goes to plain memory on every run. 5. **Gaps in the live bookkeeping.** Still open. On the plain-memory path coherent_heap_released runs after Windows has freed the range (~1335), so another thread can get the same address and its entry is lost. A heap freed through VirtualFreeEx is never taken off. COHERENT_LIVE adds unrounded sizes while alloc_where rounds each block up to 64 KiB, so the stored need can come out a little under what the same heaps take (noted in the inline review on ~1035). The first two overcount and defeat the lowering; the rounding undercounts. 6. **Description gaps.** AI use says "Claude Code" without the exact model, there is no issue link, and Tested has no suite counts: the only run listed is a cargo check with the windows-gnu target on Linux. #### Nit 7. **XCL_COHERENT_SHRINK is not in README.** It is a new switch that is on by default and changes how the window is sized from run to run. 8. **Misplaced doc comment.** The doc comment written for a_long_run_that_freed_heaps_lowers_the_stored_need_of_every_heap sits above holes_are_the_free_room_below_each_windows_highest_block (uma.rs ~1849). <details><summary>Checked and fine</summary> - holes() counts only the free runs below each window's highest block, the 2 MB alignment padding included, and has its own test - The sparse routes still settle at 60 s, and XCL_COHERENT_SHRINK=0 keeps the old sum of everything asked for, never lowered - coherent_fallback is the old tail of VirtualAlloc moved into a function, unchanged; a UMA block's release is counted before u.free </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 60 61 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3695:upstream-pr/3695'
git switch 'upstream-pr/3695'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3695'
git switch 'upstream-pr/3695'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3695'
git switch 'upstream-pr/3695'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3695'
git switch 'main'
git merge --squash 'upstream-pr/3695'
git switch 'main'
git merge --ff-only 'upstream-pr/3695'
git switch 'main'
git merge 'upstream-pr/3695'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3695
No description provided.