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>
… their own A retail title's world (RTX 3060 Ti 8 GB, 32 GB RAM) makes GPU heaps of 1162, 1277 and 258 MB. With XCL_COHERENT_MB=512 the coherent window has no room for them, so 2.7 GB of them is plain write-watched memory: the GPU never reads it, a buffer placed there is a resource of its own, a buffer bound by address is mirrored and copied at each draw (2 GiB of mirrors at most) and a shader's read of an address there reads zeros. One window for all of it (3,407 MB) lost the device at 127-129 s on 11-27. With XCL_COHERENT_HEAP_WINDOWS such heaps each get a committed window of their own in the slots of the 16-window aperture no other window takes (6 with one coherent window, after the view windows), made with the layout and sized to the heap (up to the next 16 MiB), the rest of the slot reserved. open_uma treats them as it treats the coherent window: on NVIDIA each is remade as a driver CUSTOM write-back L0 heap at its address before the title runs (system memory, no video memory budget; the grooming leaves a hole of the window's own size), else it is imported; the start-up check reads a word of each back. A heap goes to a window made for one like it (at least half its size), else to the coherent window as before, else to any own window with room, else plain memory. XCL's own allocations never take an own window, and the coherent window's room, holes and stored size leave them out. The layout is reserved without them when their commit is refused. Values: unset or 0: none (as before). 1 or auto: the sizes the last run with the switch stored in cache/uma_heap_windows.txt (the most heaps alive at once outside the coherent window, each place as large as the largest seen; the first run only stores them). 1277,1162,258: these sizes in MB. XCL_COHERENT_HEAP_WINDOWS_CAP_MB caps them in all (default 4096; an eighth of the RAM below 24 GB). Without XCL_COHERENT_MB the coherent window is smaller by what the own windows take, XCL's 512 MB at least. The windows are pinned system memory committed from the start, and every GPU read and write of the heaps then crosses PCIe; whether that is what lost the device with the 3,407 MB window is not known (XCL_MEM_TRACE=1 and XCL_DRED=1 tell the memory and a page fault apart from a hang). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…indows out With XCL_COHERENT_HEAP_WINDOWS the committed windows' size counts the title's heaps' own windows (up to ~2.7 GB), but only alloc_own_window hands those out. place_console_texture and has_coherent_headroom still took the room as size() - used(), so the own windows' free space counted as room in the 512 MB coherent window: COHERENT_KEPT (128 MB) and COHERENT_FLOOR no longer held, console committed textures could fill the coherent window whole (the Unicorn Overlord failure these guards are for), readback heaps then spilled to sparse video memory already over budget, and the title's heaps that used to fit the window went elsewhere. Worst before the world's heaps exist, while the own windows are empty. Both now use Uma::coherent_room() (as kernelx already does) and the new Uma::coherent_size() (the committed windows other than the own ones). With XCL_COHERENT_HEAP_WINDOWS unset or 0 both equal what size() - used() and size() were, so nothing changes there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t all of unified memory open_uma treated a heap's own window (XCL_COHERENT_HEAP_WINDOWS) as it treats the coherent window: when the driver remake failed and the import (OpenExistingHeapFromAddress) failed too, it logged "UMA not available to the GPU" and returned before sparse::init, set_window_views and set_uma_windows. One own window of the up to six (272-1280 MB, the large ones the likeliest to fail) then cost the GPU the coherent, sparse and view windows as well - an empty world or a hang - and a coherent window already remade as a driver heap was left without its UMA_HEAPS entry. Now such a window alone is given up (Uma::drop_own_window): its free runs go so nothing is handed out there, its pages are decommitted (the slot stays reserved), the write-watch looks leave it out, it binds no view (no bytes, so set_window_views stays complete), and the heaps it was made for go to the coherent window or plain memory as without the switch. An own window is also never given a copy in video memory when it cannot be imported (no host-memory heaps, or XCL_UMA_SHADOW=1): up to 1.3 GB each, which an 8 GB card does not have to spare. The coherent window keeps its old behaviour. Only with XCL_COHERENT_HEAP_WINDOWS on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… heap half its size With XCL_COHERENT_HEAP_WINDOWS a GPU heap took a window "made for one like it" before the coherent window was tried whenever the heap was at least half the window. So with XCL_COHERENT_HEAP_WINDOWS=258 (a 272 MB window) any 136-272 MB heap the title made before the 258 MB one took the window even with room in the coherent window, and the 258 MB heap then went to plain memory: where the heaps ended up hung on the order the title made them in, which a test run cannot be read against, and in auto mode the wrong heap was stored as outside the coherent window, so the stored sizes grew. A window now counts as made for a heap only when the heap is its size within the window's 16 MiB rounding (and at least half of it, for the small ones): for 1277,1162,258 that is heaps over 1264, 1152 and 256 MB. Any other heap goes to the coherent window first and takes an own window only when the coherent window has no room for it, as before. Also: when the layout with the own windows cannot be reserved, the layout without them now has the coherent window it had without the switch, not one already made smaller by what the own windows would have taken (only without XCL_COHERENT_MB). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With XCL_COHERENT_HEAP_WINDOWS the committed windows' size counts the
title's heaps' own windows, so the logs that report it as the coherent
window showed ~3.2 GB for XCL_COHERENT_MB=512 and 1277,1162,258: the
XCL_MEM_TRACE line ("coherent window ... (commit)", which then lists the
same heaps again as in windows of their own), the layout line ("4 coherent
window(s)"), "UMA opened ... MB coherent window" and the console-code
summary's "coherent used/total". Read after a lost device, that looks like
the one 3,407 MB window that lost it on 11-27.
They now give the coherent window alone (Uma::coherent_size, and for used
coherent_size - coherent_room), and "UMA opened" names the own windows apart
with their size and whether each is a driver L0 heap or imported. No switch:
with XCL_COHERENT_HEAP_WINDOWS unset or 0 the numbers are as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pvfreis
left a comment
There was a problem hiding this comment.
Preserve slot ownership when combining this with #3653. On 73a68e2e3, dedicated heaps start at heaps_at = views_at + view_wins. On #3653's 1de2334d6, that same tail becomes write-watched overflow views. A trial merge stops in gpu/uma.rs. Moving the OS reservation to rest_at alone would still leave the dedicated heap addresses in #3653's overflow free list and lookup range, so an overflow reservation could reuse a committed heap address.
Please derive the heap capacity and overflow ranges from the same layout. With 16 windows, four sparse windows, one coherent window and six primary views, five slots remain. The current own_window_slots calculation assumes three sparse windows and would admit six if carried over unchanged. A layout test can exercise one dedicated heap plus one overflow reservation, then fill the tail and verify that an extra dedicated heap gets no slot.
Switch-form access. The fallback discussed in #3517 binds four root UAVs. The dedicated heaps added here sit beyond them, so a raw load from one of those heaps returns zero after a heap-window PSO is rebuilt in switch form. Please document that limit for XCL_COHERENT_HEAP_WINDOWS until the fallback can address the dedicated heaps.
AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran the local trial merge and drafted this review. Claude Code (Claude Fable 5.2) independently checked it.
|
Test report (not a merge-check): #3696 at
Setup
Results (times from the title's start, read from the 2 s
Not tested
AI use: Claude Code (Claude Opus 5.5) built the branch, ran the title on this machine, read the logs and wrote this report; I posted it. The figures come from each run's |
|
Test report (not a merge-check: main: this merge: World runs with the switch on This is the case the PR describes:
In every run of this merge, all three heaps got their own windows at start-up, each a driver CUSTOM write-back L0 heap:
With only the 258 MB heap in a window (the recipe in the PR body)
assessment: merges, builds and passes the whole suite on current main, and the smoke run with the switch off is clean. With the switch on and 512 MB, the three heaps land in GPU-visible windows of their own and nearly all draws run (about 0.2 % skipped, against 94 % without the switch). The long 1x1x1 compute program drops out of the GPU top 60, and geometry appears in the image. The cost resembles the single 3408 MB window's: about 2.8 GB more non-local memory, longer GPU frames than the 512 MB run, and in our runs a GPU-wait watchdog stop 2 to 3 minutes into the world (three runs out of three), which the control on main did not show. No driver reset at world entry on this 16 GB card, where Prime's 8 GB card hung three times in three. With only the 258 MB heap in a window, the PR body's recipe, the runs did not hang, but the two large heaps stay outside GPU memory and the GPU work looks like the 512 MB run without the switch: most draws skipped and e2046474 at 115 ms/frame. Single runs. AI use: Claude Code (Claude Opus 5.5). |
|
test report (not a merge-check) Smoke blocks (60 s, XCL_DIRECT_DXIL=1, title 1778c2d9; the default pair is in the #3695 report): #3695 control, 16 windows and 512 MB (second run, warm): #3696 first run, XCL_COHERENT_HEAP_WINDOWS=1, no sizes stored yet: #3696 second run, three own windows: |
|
Review of the top 5 commits at
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
Stacked on #3695; only the top 5 commits belong here.
With
XCL_COHERENT_MB=512, a retail title's world on an 8 GB GPU makes GPU heaps of 1162, 1277 and 258 MB that the coherent window has no room for. They end up in plain, write-watched memory the GPU never sees directly: shaders read zeros there, and every submit copies and watches about 2.7 GB.XCL_COHERENT_HEAP_WINDOWSgives such a heap a committed window of its own, in a free slot of the 16-window aperture, at the title's own address. On NVIDIA it is a driver CUSTOM write-back L0 heap in system memory (else imported), so the GPU reads and writes the heap where the title has it. It is off by default.What is in it
UMA: XCL_COHERENT_HEAP_WINDOWS gives the title's GPU heaps windows of their own(gpu/uma.rs,hle/kernelx.rs,README.md)1orautouses the sizes the last run stored incache/uma_heap_windows.txt(the first run only stores them).1277,1162,258gives the sizes in MB.XCL_COHERENT_HEAP_WINDOWS_CAP_MBcaps the total: 4096 by default, or an eighth of the RAM below 24 GB.D3D12.X: the coherent window's headroom checks leave the heaps' own windows out(gpu/uma.rs,hle/d3d12x/real.rs)D3D12.X: a heap's own window the GPU cannot open is dropped alone, not all of unified memory(gpu/uma.rs,hle/d3d12x/real.rs)UMA: a heap's own window goes to the heap it was made for, not to any heap half its size(gpu/uma.rs,hle/kernelx.rs)D3D12.X: logs give the coherent window without the heaps' own windows(gpu/uma.rs,hle/d3d12x/bind.rs,hle/d3d12x/real.rs)Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnuon Linux: builds, no new warnings.XCL_COHERENT_MB=512andXCL_UMA_WINDOWS=16:XCL_COHERENT_HEAP_WINDOWS=258reaches the world and is stable there; it ran 925 s in one run.1277,1162,258all at once hung the GPU at world entry in 3 runs out of 3. Use only the sizes that fit your GPU's budget.Regression run
main(Prime's call for our PRs; they merge after community testing). Off by default, so nothing changes unless the variable is set.Not tested
main.AI use
🤖 Generated with Claude Code