Repository navigation
Conversation
The coherent window is committed, GPU-visible system memory that stays resident, made as large as the stored size of the title's GPU heaps from its last run plus XCL's 512 MB. kernelx's ASKED was never decremented, 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 with every heap in the window (the default route) it was never lowered, a run that stayed in the menu being the reason. RAM was the limit in the own10 run (1f5d4d5: 30.9 of 31.9 GB in use); an oversized window is resident RAM for nothing (estimated 0.3-1.5 GB). kernelx now keeps the heaps counted for the window alive by address (in the window or, without room, in plain memory) and takes a heap off on its release (VirtualFree of a unified-memory block or of plain memory); uma stores the most alive at once (note_coherent_need's peak). settled_need lowers the size stored for every heap in the window only after a long run (600 s), and only when the run asked for at least the stored size in all yet had less alive at once (it freed heaps), by half at most and never under its largest heap; a menu-only run, which asked for less, still leaves it. The sparse routes settle at 60 s as before. Not done: an automatic cap at RAM/6 on 32 GB machines. 31.9 GB / 6 is 5.3 GB, within 4% of a measured retail title's real need (4582 MB of heaps + 512 + 96 MB), and a cap under the real need sends heaps to plain memory (no image); with the stored size now the peak alive, the cap would only add that risk. The launcher sets XCL_COHERENT_MB=512, so the own10 configuration is unaffected by either. Off: XCL_COHERENT_SHRINK=0 (the sum of all asked, never lowered with every heap in the window); XCL_COHERENT_MB still sets the size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fix for 86c5e52 (size the coherent window by the GPU heaps alive at once). The stored size became the most heap bytes alive at once, but the window is a first-fit allocator with no compaction (and 2 MB alignment for large-page heaps): after heaps are freed and made again in other sizes the same placement needs more than the bytes alive. Example: A (1 GB) and B (1 GB) made, A freed, C (1.5 GB) made: 2.5 GB alive, but C needs 3.5 GB of window. After a 600 s run lowered the stored size to 2.5 GB, the next run's C fit in neither A's 1 GB hole nor the tail, went to plain memory, and its draws had no image. It never healed: the fallback heap counts as alive, so the peak alive equalled the stored size and note_coherent_need never grew it (the old cumulative ASKED did). With XCL_COHERENT_SHRINK on, each GPU heap the title makes now also notes the bytes alive plus the window's holes: the free room below the highest block in each committed window (Uma::holes, the pure holes() with a unit test). After a heap placed in the window that is the window the same placement needs; after one that did not fit it is more than the window held (the fallback heap counts on top of the holes), so the next run's window grows to take it, as ASKED did. The 600 s settle lowers towards NOTED, the most of these, never under the run's fragmented need. Holes XCL's own frees leave count too (conservative, at most its share of the 512 MB it keeps). The measured own10 setup (XCL_COHERENT_MB=512, no title heaps) is not affected. Off: XCL_COHERENT_SHRINK=0 (all asked for, never lowered, as before own11). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review (model: GPT-6). I checked the coherent allocation rounding against the shrink accounting.
| 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; |
There was a problem hiding this comment.
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.
|
test report (not a merge-check) Smoke blocks (60 s, XCL_DIRECT_DXIL=1, title 1778c2d9): |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
|
Review of
Fine: sparse heaps are not counted; no stored file and AI use: Claude Code (Claude Opus 5.5) reviewed the diff; posted at throny's request. |
|
merge-check Smoke blocks for the description (60 s each, retail title): main: this PR's head: |
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 ofnote_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-gnuon Linux: builds, no new warnings.XCL_COHERENT_MB=512: the title reaches its world, and the window no longer grows between runs.Regression run
main(Prime's call for our PRs; they merge after community testing).Not tested
main.AI use
🤖 Generated with Claude Code