Skip to content

UMA: XCL_COHERENT_HEAP_WINDOWS gives the title's GPU heaps windows of their own - #3696

Open
Prime1997 wants to merge 7 commits into
xcl-dev:mainfrom
Prime1997:contrib/up-coherent-heap-windows
Open

Prime1997 wants to merge 7 commits into
xcl-dev:mainfrom
Prime1997:contrib/up-coherent-heap-windows

Conversation

@Prime1997

@Prime1997 Prime1997 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

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_WINDOWS gives 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)
    • 1 or auto uses the sizes the last run stored in cache/uma_heap_windows.txt (the first run only stores them).
    • 1277,1162,258 gives the sizes in MB.
    • XCL_COHERENT_HEAP_WINDOWS_CAP_MB caps 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-gnu on Linux: builds, no new warnings.
  • Prime's batch builds since 1 Dec on an RTX 3060 Ti 8 GB, 32 GB, Windows 11, release, with a retail title, XCL_COHERENT_MB=512 and XCL_UMA_WINDOWS=16:
    • XCL_COHERENT_HEAP_WINDOWS=258 reaches the world and is stable there; it ran 925 s in one run.
    • Windows for 1277,1162,258 all 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

  • 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). Off by default, so nothing changes unless the variable is set.

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

Prime1997 and others added 7 commits December 2, 2026 15:09
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>
@Prime1997 Prime1997 self-assigned this Dec 2, 2026
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026

@pvfreis pvfreis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@IvovdBruggen

IvovdBruggen commented Dec 2, 2026 •

Copy link
Copy Markdown

Test report (not a merge-check): #3696 at 73a68e2e on an RTX 3080 10 GB. I ran a matched pair, without heap windows and with XCL_COHERENT_HEAP_WINDOWS=563, both warm and with an 80 GB commit limit and DRED.

  • The feature works as described. The 563 MB heap gets its own window: a driver CUSTOM write-back L0 heap at the title's address.
  • On this machine it does not change the outcome. Both runs get past the loading screen into the intro, but show only its credits and subtitles on a black picture.
  • Both lose the device at about the same time, 217 s and 206 s, with the same DRED page fault at GPU VA 0x0. That points to a separate bug rather than to UMA: XCL_COHERENT_HEAP_WINDOWS gives the title's GPU heaps windows of their own #3696.
  • A fixed 258 from the description doesn't apply here. This title's heaps on this machine are 2199, 1172, 596 and 563 MB.

Setup

  • RTX 3080 10 GB (10,240 MiB; DXGI budget about 9.3 GB), NVIDIA 617.42, 32-lane waves. Ryzen 5 5600 (6C/12T), 32 GB RAM, 48 GB fixed page file (commit limit 81.8 GB). Windows 11 IoT Enterprise LTSC 26100.
  • 73a68e2e3dce4eb7cfcc870924c72ea78c755f42: this PR's head, a fast-forward of main 5eaadb54c14e. Clean tree, cargo build --release --workspace, Rust 1.100.0, DXC 1.9.2602.17.
  • The large retail title from Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (1.0.2.1, TitleID 7952987A), Series X profile. Played by hand: menus, then the story start. Neither run was closed by hand.
  • Env for both: XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_COHERENT_MB=512 XCL_DRED=1 XCL_NETWORK=0 XCL_ACTIVITY=1. Run B: no XCL_COHERENT_HEAP_WINDOWS. Run A: XCL_COHERENT_HEAP_WINDOWS=563.
  • Caches warm: compute pipelines in 2–3 s, the recorded graphics pipelines (845) built before the start.

Results (times from the title's start, read from the 2 s memory: and activity lines)

run B (no heap windows) run A (563)
heaps the 512 MB coherent window has no room for 1172, 2199, 563, 596 MB, all in plain memory 1172, 2199, 596 MB in plain memory; 563 MB in window 10 (a GPU heap of 563 MB at 0x1a00000000 in a window of its own)
what was on screen menus at 30 fps, past the loading screen; intro credits and subtitles on black, in sync with audio same as B
local video memory past the budget 91 s 84 s
presents after the world load 0–3 per 2 s from ~130 s 0–3 per 2 s from ~115 s
graphics pipeline waits 3 (10 s in all) 2 (6 s in all)
draws with translated pipelines (skipped), last line 86,093 (65,536) 138,265 (136,814)
dispatches (skipped) 161,058 (0) 262,144 (0)
peak local video memory / budget 17,980 / 9,272 MB 17,757 / 9,280 MB
peak non-local 1,875 MB 2,660 MB
peak commit (process) 39,278 MB 38,238 MB
target pages (pools), peak 10,195 (10,368) MB 10,146 (10,240) MB
sparse pools, peak 3,788 MB 3,820 MB
system commit at the end 49,631 of 81,845 MB, no running out of commit warning 48,705 of 81,845 MB, no warning
device removed 217 s, 0x887a0005 206 s, 0x887a0005
DRED page fault at GPU VA 0x0 = window 10 + 0x0; allocations there: [], no breadcrumbs (no list in flight) page fault at GPU VA 0x0 = window 11 + 0x0; allocations there: [], same
  • The console code so far lines are logged at power-of-two counts, so the two skip shares (76 % and 99 %) don't come from the same moment. In both runs most of the intro's 3D draws were skipped, which fits the black picture. nvidia-smi peaked at 9,954 / 9,955 of 10,240 MiB.
  • The fault at GPU VA 0 in both runs, with and without the heap window, looks like the case D3D12.X: a memory window with no GPU buffer gives no GPU address #3658 describes ("a memory window with no GPU buffer gives no GPU address"). I haven't tested D3D12.X: a memory window with no GPU buffer gives no GPU address #3658.
  • Two earlier runs on this head had a 16–32 GB page file (commit limit ~50 GB) and no DRED, so they aren't comparable. Run 1 used 258 (no heap matched) with cold graphics pipelines: 326 waits, 834 s in all, frames stopped at ~186 s, device removed at 778 s. Run 2 used 563: device removed at 237 s. Both ran with system commit within ~1 GB of the limit and XCL's running out of commit warnings. The 80 GB pair above rules that out as the cause.
  • The description gives 1277 / 1162 / 258 MB on a 3060 Ti 8 GB. Which build, title id and profile were those sizes measured on?

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 xcl.log, report.json and an nvidia-smi trace.

@tiagonleal

tiagonleal commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Test report (not a merge-check: PR description red)
base: 5eaadb5
head: 73a68e2
merge: clean (merge commit 826ab4850b7ff57d13def0ba0fed65539aa1ab8c; the head is already on this base, so the merged tree is the head's tree)
build: cargo build --workspace -> ok. One new compiler warning against main with rustc 1.100.0: fetch_update is deprecated (renamed to try_update), from coherent_heap_released in hle/kernelx.rs
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2982 passed, 0 failed, 52 ignored; SKIPPED: 24 (22 no wave64, 2 no heap windows); failing: none
review: diff read once, not a full review. Nothing found beyond the warning above.
performance: off by default. 60 s smoke of a retail title, main 5eaadb5 vs this merge (826ab485), switch unset in both: 1683 -> 1699 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 16744 -> 16400 MB, 0 device removals, 0 crashes.
hardware / tool and model: RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26300 / Claude Code with Claude Opus 5.5

main:

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1683 (PresentX 1683)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16744 MB

this merge:

xcl-smoke v1
commit: 826ab4850b7ff57d13def0ba0fed65539aa1ab8c
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1699 (PresentX 1699)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16400 MB

World runs with the switch on

This is the case the PR describes: XCL_COHERENT_MB=512, XCL_UMA_WINDOWS=16, XCL_DEVICE_TYPE=lockhart, release, Newer Retail Game, with XCL_COHERENT_HEAP_WINDOWS=1162,1277,258 (the three heap sizes our 512 MB runs log). All runs are single runs.

  • Of this merge: W7 (XCL_GPU_TIMES=16,110, 300 s planned) and W5 (600 s planned, XCL_ACTIVITY=1).
  • Control, today: main 5eaadb5 with the same settings and no switch (300 s).
  • From earlier today on main 1c8b551 (an older main), with no switch: one run with XCL_COHERENT_MB=512 (XCL_GPU_TIMES) and one with XCL_COHERENT_MB=3408 (one window large enough for all three heaps).

In every run of this merge, all three heaps got their own windows at start-up, each a driver CUSTOM write-back L0 heap:

UMA: XCL_COHERENT_HEAP_WINDOWS: 3 window(s) of their own for the title's GPU heaps the coherent window has no room for: window 10 at 0x1a00000000 1168 MB, window 11 at 0x1b00000000 1280 MB, window 12 at 0x1c00000000 272 MB (2720 MB in all, committed now)
kernelx: a GPU heap of 1162 MB at 0x1a00000000 in a window of its own (window 10, a driver CUSTOM write-back L0 heap; XCL_COHERENT_HEAP_WINDOWS): #1, 1162 MB alive there
kernelx: a GPU heap of 1277 MB at 0x1b00000000 in a window of its own (window 11, a driver CUSTOM write-back L0 heap; XCL_COHERENT_HEAP_WINDOWS): #2, 2439 MB alive there
kernelx: a GPU heap of 258 MB at 0x1c00000000 in a window of its own (window 12, a driver CUSTOM write-back L0 heap; XCL_COHERENT_HEAP_WINDOWS): #3, 2697 MB alive there
this merge, W7 this merge, W5 main 5eaadb5, 512 MB main 1c8b551, 512 MB main 1c8b551, 3408 MB
heaps "does not fit" 0 0 3 3 0
draws skipped (last counter line) 147 of 66,208 171 of 131,072 262,144 of 280,282 454,156 of 482,113 0 of 262,144
world entry (log s) 76.3 76.3 80.3 78.3 76.3
world time 96 s 156 s 216 s 276 s 344 s
mean fps in the world 0.73 0.45 0.74 0.86 0.31
2 s windows with no present 33 % 41 % 6 % 4 % 49 %
frame time in windows with presents 914 ms 1314 ms 1263 ms 1127 ms 1657 ms
cs e2046474 (1x1x1), GPU time not in the top 60 (under 1.72 ms/frame) - - 89.5 ms/frame, longest 44.9 ms not in the top 60 (under 2.45 ms/frame)
GPU frame, first to last stamp (16 frames) 0.66-3.93 s, median 2.05 s - - 1.10-1.32 s 4.52-5.34 s
top program (ms/frame) mesh two-pass ms 1f46b8c3: 570 - - cs 745b25de: 365 mesh two-pass ms 1f46b8c3: 2380
peak local video memory / budget 14,221 / 15,054 MB 14,309 / 15,025 MB 15,313 / 15,054 MB 15,202 / 15,048 MB 14,110 / 15,047 MB
peak non-local video memory 5,568 MB 5,594 MB 2,769 MB 3,104 MB 5,779 MB
peak process commit 31,184 MB 31,594 MB 32,984 MB 33,660 MB 31,364 MB
how it ended GPU-wait watchdog at log 172.6 s, 0x80004005 GPU-wait watchdog at log 232.2 s, 0x80004005 RAM guard at 302 s (296 s in the log) RAM guard at 360 s ended by itself, 420 s
  • W7's GPU times ran over log 117-149 s, early in the world. The other two GPU-time runs were measured later (from about 200 s), so the scenes differ. e2046474's exact time is not in the data, only an upper bound. It was 89.5 ms/frame in the 512 MB run without the switch.
  • GPU-wait watchdog: with the switch on, three runs after the RGB app was closed reached the world, and all three were stopped by it. Each logged 14 to 16 GPU queue.Wait ... did not complete within 5000 ms errors with four or five queues behind ("oldest unfinished for ~7.1 s"), then "a GPU queue wait exceeded its watchdog without a graph-proven cycle". The third is W4 (XCL_GPU_TIMES=16,200), stopped at log 199.2 s just before its measurement began. All three stopped at nearly the same fence value (0x683 to 0x68d completed). The control run on main without the switch had none in 296 s. The 3408 MB single-window run had the same watchdog once in three launches earlier today.
  • Driver resets: none in this merge's runs (System log checked, no nvlddmkm entries, no STOP_ALL_RUNS). The 3408 MB setting had one TDR in three launches earlier today.
  • One more launch of this merge (W6, same settings as W7) ended at log 95.4 s, before the world, with an access violation in the title's code (read at 0xffffffffffffffff). Once, not seen in the other runs.
  • Image (W2, an earlier run of this merge with frame dumps): the first frames in the world show a textured character and some lit geometry under a heavy grey-white haze, with a striped white ellipse over the middle. This is close to the 3408 MB run's frames and unlike the flat white or black frames of the 512 MB run without the switch.
  • The first world runs of this merge (W1, W2, W3, W1b) were cut short by another application's memory leak and are not used for timings or for how a run ended. A third-party RGB lighting app grew from about 0.3 GB to 6.6 GB during them, and our RAM guard stopped all four. That app was closed before W4-W7 and the control. Its working set was logged every minute and stayed at 0.

With only the 258 MB heap in a window (the recipe in the PR body)

XCL_COHERENT_HEAP_WINDOWS=258, recipe B otherwise unchanged (512 MB, XCL_UMA_WINDOWS=16), same merge 826ab485. Two single runs: W8 (XCL_GPU_TIMES=16,110, 420 s planned) and W9 (600 s planned). The RGB app was not running (logged every minute: 0 MB).

UMA: XCL_COHERENT_HEAP_WINDOWS: 1 window(s) of their own for the title's GPU heaps the coherent window has no room for: window 10 at 0x1a00000000 272 MB (272 MB in all, committed now)
kernelx: a GPU heap of 1162 MB does not fit in the coherent window (64 MB used, 448 MB free): #1, 1162 MB in all
kernelx: a GPU heap of 1277 MB does not fit in the coherent window (64 MB used, 448 MB free): #2, 2439 MB in all
kernelx: a GPU heap of 258 MB at 0x1a00000000 in a window of its own (window 10, a driver CUSTOM write-back L0 heap; XCL_COHERENT_HEAP_WINDOWS): #1, 258 MB alive there
W8 W9
heaps "does not fit" / empty V# / "not in unified memory" 2 / 1 / 5 2 / 1 / 5
draws skipped (last counter line) 42,421 of 65,536 186,750 of 205,477
world entry (log s) 84.3 80.3
world time 78 s 180 s
mean fps in the world 0.67 0.69
2 s windows with no present 15 % 9 %
frame time in windows with presents 1269 ms 1323 ms
cs e2046474 (1x1x1), GPU time 115.0 ms/frame, longest 57.5 ms (row 4) -
GPU frame, first to last stamp (16 frames, log 113-145 s) 1.01-3.92 s, median 1.42 s -
top program (ms/frame) mesh two-pass ms 1f46b8c3: 294 -
peak local video memory / budget 15,017 / 14,834 MB 14,665 / 14,868 MB
peak non-local video memory 3,165 MB 3,091 MB
peak process commit 32,445 MB 32,346 MB
how it ended RAM guard at 168 s (free RAM under 1 GB) RAM guard at 267 s (free RAM under 1 GB)
  • The two large heaps stay in plain memory as without the switch: the same "does not fit", empty V# and "not in unified memory" lines, and most draws skipped (65 % and 91 %). e2046474 is back at the top of the GPU times.
  • No GPU-wait watchdog and no driver reset in either run (System log checked). Both ended by our RAM guard at about 32.4 GB process commit. Free RAM at the start was 20.2 and 21.4 GB, lower than the 24 GB of W4-W7, because a chat app and a browser were open.

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).
~Tiago

@Edgaras0404

Copy link
Copy Markdown

test report (not a merge-check)
base: df0cfef (the last main before #3655; first parent of d71578f)
head: 73a68e2 (tested as #3695 + #3696 cherry-picked onto df0cfef; git diff base..tree is the stack's own diff, 799+/57-)
merge: clean (also clean on current main 5eaadb5, which builds; that base's suite is the #3694 breakage, so the functional run is on df0cfef)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> base df0cfef: 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,390 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 six new gpu::uma::own_window_tests and the three #3695 tests all pass (9 passed, 0 failed; own_window_tests are also 6/6 alone). Current main 5eaadb5: 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) On AMD the feature does work, but one planned heap loses its window: with the learned sizes 2199, 1172, 596 and 563 MB and the default 4,096 MB cap, the plan made 2208, 1184 and 608 MB windows and dropped the 563 MB one; the 563 MB heap then took the 608 MB window via the made_for=false fallback (the coherent window had no room for it), so the 596 MB heap - the one the 608 MB window was made for - went to plain memory the GPU does not see. A cap large enough for all four (4,576 MB rounded; 4,608) gives both their own windows. The fallback should not let a heap whose size the cap dropped take a window made for another heap. 2) Stored coherent size vs own windows when XCL_COHERENT_MB is unset: own-window heaps return before note_coherent_heap/COHERENT_LIVE, so note_coherent_need writes only the coherent part, while get() subtracts the learned own-window total; if the coherent file is missing for the route or smaller than the own plan, the subtraction clamps the coherent window to 512 MB and keeps it there until the coherent part exceeds the own plan. This run set XCL_COHERENT_MB=512, so it did not exercise this path. 3) Plan vs slots: get() subtracts the whole plan, but for_runtime_windows_with_heaps takes only own_window_slots() entries; a plan longer than the slots would shrink the coherent window for windows never created. Four sizes fit the six slots here, so this was not exercised. 4) No HLE/integration test for the VirtualAlloc own-window path, the learned cache, the get() subtraction or the release accounting; the Uma unit tests cover layout, allocation and drop well. 5) drop_own_window's false path leaves bufs[k] = (0,0) with a nonzero window size, and set_window_views then rejects all window views; unreachable in the normal order, but the code only logs. 6) Scope: 656 changed lines in its own five commits (620+/36-), 799+/57- with #3695, over the ~400 target; one feature, could be split. README documents the switch; it says 16-window slots and omits that 8-window layouts get 4. Inherits #3695's review findings (release accounting untested, XCL_COHERENT_SHRINK undocumented, 600 s heuristic). 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; this PR is stacked on #3695.
performance: 60 s smoke on df0cfef with the #3544 workaround XCL_DIRECT_DXIL=1 on both trees. Default (switch unset): base 1,537 frames / 19,779 MB peak / 0 removals / 0 crashes; #3695 1,584 / 19,550 / 0 / 0 (103.1% frames, 98.8% peak, pass); with the switch unset this PR's frame time and memory are those of #3695. The switch, with XCL_COHERENT_MB=512 XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1: #3695 control (16 windows, 512 MB) 972 frames / 16,522 MB, then 1,037 / 15,955, 0 removals/crashes both; #3696 first run (learns) 942 / 17,729, storing 2199, 1172, 596, 563 MB; #3696 second run (windows) 1,535 / 19,947, 0 removals / 0 crashes, three own windows (2208 + 1184 + 608 = 4,000 MB imported), with the 596 MB heap left in plain memory as described above. Frames are 148-158% of the control and peak +20.7% to +25.0% (the own windows are committed at startup, so the increase is the feature's cost); the 125% edge is from the 4,000 MB of own windows. Not tested: the default coherent-size path (XCL_COHERENT_MB unset) with the switch, where review point 2 applies; 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 df0cfef the stack's suite has four failures, all on the base (the base's other two did not recur), and no new one, and the nine new/changed tests pass; the switch works on AMD (three own windows, 0 removals, 0 crashes, frames up 48-58%, peak within 125%) but the 596 MB heap that had a 608 MB window made for it went to plain memory because the 563 MB heap took it after the cap dropped the 563 MB size; the stored-size and plan-slot interactions are also unguarded. Those are what I would fix before recommending the switch; the default path is unchanged and passes.
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; the default pair is in the #3695 report):

#3695 control, 16 windows and 512 MB (second run, warm):

xcl-smoke v1
commit: 1e2533ea4281c6c0b549da697b1ec5cfc16fa76a
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1037 (PresentX 1037)
presents per 2 s (last 3): 30 31 32
device removals: 0
crashes: 0
peak commit: 15955 MB

#3696 first run, XCL_COHERENT_HEAP_WINDOWS=1, no sizes stored yet:

xcl-smoke v1
commit: 3d40c50050d9d27a1c4e610a9a36ee18335048a5
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 942 (PresentX 942)
presents per 2 s (last 3): 28 21 20
device removals: 0
crashes: 0
peak commit: 17729 MB

#3696 second run, three own windows:

xcl-smoke v1
commit: 3d40c50050d9d27a1c4e610a9a36ee18335048a5
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1535 (PresentX 1536)
presents per 2 s (last 3): 48 61 47
device removals: 0
crashes: 0
peak commit: 19947 MB

@throny

throny commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review of the top 5 commits at 73a68e2e3 (git diff pr-3695 pr-3696; read, not run; not a merge check). With XCL_COHERENT_HEAP_WINDOWS unset, the behaviour is the same as #3695 alone. coherent_room equals size()-used(), holes_outside(..,0) equals holes, alloc_own_window returns None, and the hooks return early. With the switch on:

  1. Likely shrinking loop (gpu/uma.rs ~1617-1623 with hle/kernelx.rs ~1031-1041). At startup the coherent window is cut by the total of the own windows. Heaps placed in own windows return before ASKED / note_coherent_need, so they never count toward the stored need. Once the settle lowers the stored size to what the run put in the window, each run subtracts the own windows again, down to the 512 MB floor. I didn't check whether settled_need actually lowers it in this case.
  2. Up to 4 GB committed at startup without the free-commit check (gpu/uma.rs ~387). The windows are committed outside coherent_hint_for's free_commit() gate.
  3. Inconsistent counting (hle/kernelx.rs ~1070-1075). The "fitted by bytes" fallback has already added the heap to ASKED, note_coherent_heap and note_coherent_need before it sends it to an own window; the first path doesn't.
  4. README (~410-418): the new bullet sits inside the XCL_TEXTURE_LEVEL_PAGES item, so "Zero-filled mip uploads…" now reads as part of it.
  5. Minor: own_window_heap_bytes (hle/kernelx.rs ~1109) is never called.

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

@throny

throny commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: c53e969
head: 73a68e2
merge: trial merge 338a811dd into main c53e96960: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace -- --test-threads=4 -> 3012 passed, 0 failed, 52 ignored; 25 SKIPPED; failing: none
title run: retail title, RTX 4080, 300 s in the world (run 494) with XCL_COHERENT_HEAP_WINDOWS unset, no crash, no device removal, 2.71 presents/s (the switch-on mode was not run: it hung the author's GPU)
review: the review comment above (whole diff read)
performance: switch off: same as #3695 (runs 497/498: 2.82 / 2.80 presents/s); switch on: not measured
verdict: not yet: it builds on #3695 (see there). The switch-off path is the same as #3695's, and the switch-on findings are in the review above.
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: 73a68e2e3dce4eb7cfcc870924c72ea78c755f42
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1557 (PresentX 1557)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16549 MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants