Recompiler: an access may take its base address's window (XCL_WINDOW_NO_CARRY) #2496
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2496
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2496"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@S1m0ne1997 on GitHub · 2026-11-25 20:35 UTC · original
S1m0ne1997:window-no-carry→main· +157 −5 · 5 files · 1 commits · openThe direct DXIL translator selects the memory window of every access from its 64-bit address, with the offsets added and carried into the high dword (
window_at). Each access then gets its own window index, range check and heap handle, and accesses off the same base share none of them. XCL's allocations never straddle windows (gpu::uma), and with the switch the title's reservations do not either. So an access inside the allocation its base points into never carries or borrows: its window is its base's. WithXCL_WINDOW_NO_CARRY=1and heap windows (XCL_HEAP_WINDOWS=1) the window is taken from the base address, which makes the driver's code for big compute programs smaller. Root-UAV windows keep the carry: they have no bounds, so an access that leaves its allocation and wraps inside its base's window could hang the GPU (a window test did on an RTX 3090, below); heap views read 0 past the window's end. Off by default.Part of #2403: on NVIDIA the code of the pipelines in use is limited, and the retail title's world needs more than that.
What is in it
crates/xcl/src/gpu/dxil/lower_window.rs:no_carry()(XCL_WINDOW_NO_CARRY=1, orwith_no_carryfor a thread); with it and heap windows,window_atselects the window from the base's high dword.crates/xcl/src/gpu/dxil/kernel.rs:window_no_carry(); the translator thread takes its caller's setting.crates/xcl/src/gpu/recomp/pso.rs: the setting is part of the translation cache's identity, asXCL_DIRECT_COMPACTis, and of the direct translator's output identity (programs that go direct asenormouswithoutXCL_DIRECT_DXIL).crates/xcl/src/gpu/uma.rs: with the switch, a title reservation (sparse_reserve) of 4 GiB or less that would cross a window boundary starts at the next window, so nothing the title places in it spans two windows (pointed out by @Kalmarv below). A larger reservation cannot stay in one window and is logged. Testtitle_reservations_stay_in_one_window_without_the_carry.crates/xcl/src/gpu/recomp/tests.rs: the two carry tests pin the switch off (with_no_carry(false)).gpu_window_no_carry_reads_inside_allocations_alike. Accesses inside an allocation (global loads with positive and negative offsets, ans_loadwith an offset) read the same words with and without the switch, with the windows in root UAVs and in the descriptor heap, the DXIL is smaller with it with heap windows and unchanged with root UAVs. A 32-bit (hi == 0) pointer still reads window 0, and a base outside the UMA still reads 0.Tested
rustc 1.100.0, debug for the tests, release for the runs.cargo build --workspace, thencargo test --workspace -- --test-threads=4at the head: 1437 passed, 0 failed, 47 ignored. SKIPPED: the wave64 cases (no wave64 on this card),pso_measurement_compiles_an_exact_synthetic_record(no Developer Mode), the D3D12 debug layer tests (nod3d12SDKLayers.dll),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_DIRECT_DXIL=1 XCL_WINDOW_NO_CARRY=1, the whole suite again: 1437 passed, 0 failed, 47 ignored. The two existing tests that check the 64-bit sum on purpose (gpu_window_at_32bit_carry_edge_cases,memory_windows_reject_out_of_uma_aliasing) now pin the switch off for their translations, so they test the carry path whatever the environment; the new test covers the path without it.GetCachedBlob) of the retail title's compute programs, as the runtime translates them (direct DXIL, heap windows), 12 programs of each family:XCL_WINDOW_NO_CARRY=1CS_RaytracingResolveCS_IrradianceCache_ShadeCS_ShadowRenderTiledmain(0829441) with #2057 and the same change (direct DXIL, heap windows, warm caches): the world-load removal of #2403 came 72 s after the start of the world load, against 8–9 s in two runs without it. Bound at the removal: 1295 pipelines, against 1145–1172. It is still removed: this makes the limit come later, it does not avoid it.Regression run (the switch is off by default, so this run is the default path)
main:
PR:
PR with
XCL_WINDOW_NO_CARRY=1 XCL_HEAP_WINDOWS=1(the switch on; same head, same script):Not tested
AI use
🤖 Generated with Claude Code
xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590@Kalmarv on GitHub · 2026-11-25 21:00 UTC · original
@S1m0ne1997 one point on the premise "Allocations never straddle windows (
gpu::uma)", from readingmain6d12f58a. XCL's own allocations hold to it. The title's own reservations may not:Uma::sparse_reserve(gpu/uma.rs:390) callstake_sparse_in(..., single_window: false)both times. Onlysingle_window: truekeeps a block inside one 4 GiB window (uma.rs:154), so a sparse reservation is first fit at 64 KiB grain and can cross a boundary.hle/kernelx.rs,VirtualAllocof 64 KiB pages lands at line 271, and graphics reservations without the top type bit at line 307. Titles reserve a range, then commit or map pages and place resources inside it, so a buffer the title places in such a range can span two windows.For an access whose base is in window k and whose final address is in k + 1,
window_atwith carry picks k + 1, while no-carry picks k. We have not seen such an access in the retail title. We only checked the allocator, so this is a possibility, not an observed failure. One way to keep the saving would besingle_window: truefor title reservations of 4 GiB or less, or a carry only where the base is in sparse title space. Either would need a run to see what it costs in address space.AI use: Claude Code (Claude Opus 5.5) read the allocator and the reservation paths on
mainand wrote this comment.@SlopTart on GitHub · 2026-11-25 21:00 UTC · original
gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.@DavidM1911 on GitHub · 2026-11-25 21:03 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@S1m0ne1997 on GitHub · 2026-11-25 21:08 UTC · original
@SlopTart Thanks for the run on your machine.
@S1m0ne1997 on GitHub · 2026-11-25 21:08 UTC · original · edited 2026-11-25 21:14 UTC
@Kalmarv Thanks, you're right. I checked
sparse_reserveand the twokernelx.rspaths: title reservations were first fit across window boundaries, so the premise held for XCL's own allocations only.The change now makes it hold for the title's too, the way you suggested: with
XCL_WINDOW_NO_CARRY=1, a title reservation of 4 GiB or less that would cross a boundary starts at the next window instead. Without the switch nothing changes. Test:title_reservations_stay_in_one_window_without_the_carry(with the switch the second reservation starts in the next window; without it, it crosses as before).The PR is now one commit,
78bba5c(the code is the same as the two commits it replaced). Results at it (RTX 4090, driver 621.40):cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignored (on the same tree before the squash).scripts/smoke.ps1 -Seconds 60on the retail title, switch off (the default path): 1615 frames, 0 removals, 0 crashes. Block in the description.XCL_WINDOW_NO_CARRY=1: 1661 frames, 0 removals, 0 crashes, and no title reservation failed in the log.What these runs don't show: that run covers the start and the menus, not a session in the world. The log does not record each reservation, so I can't put a number on the address space the skipped window tails cost.
AI use: Claude Code (Claude Opus 5.5) checked the allocator, wrote the change and the test, ran the suite and the smoke runs, and drafted this reply.
@Eterst on GitHub · 2026-11-25 22:12 UTC · original
A run on NVIDIA as asked on #2403, with one caveat: it has this PR and #2427 (
XCL_HEAP_FLAT=1) together, so the two are not separated.Setup: RTX 4070 SUPER 12 GB, driver 616.92, Windows 10 19045, release. A local test tree (#2057 and a few other open PRs on
main), before:main06055a7; after:main6d12f58+78bba5c(this PR) +d356a74(#2427). The retail title withXCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, split programs off (XCL_DIRECT_SPLIT_INSTRUCTIONS=0), caches rebuilt by a full precompile (xcl shaders --precompile --only cs --pipelines, thenxcl pipelines) with the same switches as the run.Where the device is removed
0x887a0005at 261–303 s, always at the same point of the title (last frame before it 2,300–2,480); DRED page fault VA 0, no eventXCL_WINDOW_NO_CARRY=1 XCL_HEAP_FLAT=1Driver code of the compute programs the precompile rebuilt (
.psofiles, theGetCachedBlobbytes):The two rows are not the same set of programs (each counts what that precompile built anew), so read them as distributions, not as a per-program saving.
Not tested: this PR without #2427 and the other way round; more than one run; AMD / Intel; a bound-code counter in the title (the sizes above are of what was built, not of what was in use at once).
AI use: Claude Code (Claude Opus 5.5) merged the PRs into the test tree, ran the precompiles and the runs, and wrote this; posted with my OK.
@pvfreis on GitHub · 2026-11-25 22:23 UTC · original
By reading only, at
78bba5c:direct_output_identity(pso.rs:503) lacks the switch, andidentity()adds it only when the backend is not HLSL. WithXCL_DIRECT_DXILunset, compute programs over 8 MiB of HLSL still go direct (enormous), without the carry when the switch is set, and are stored underrerouted_identity. A later run without the switch loads that DXIL while its reservations cross windows again; the other way round, the switch does nothing for those programs. I have not seen a crossing access. #2257 fixed the same gap for the nesting tag.uma.rs:332describes one of 8 GiB + 4 MiB); that case is missing under Not tested.AI use: Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.
@Oliwettoo on GitHub · 2026-11-25 22:28 UTC · original
Review on
78bba5c(read from the diff, not run), following up @Kalmarv's point: the fix keeps title reservations of ≤ 4 GiB in one window, but one case of the "allocations never straddle windows" premise is still open.take_sparse_inlets a reservation larger than a window (size > WINDOW) cross a boundary even withsingle_window: true(uma.rs:154). A buffer the title places across that boundary inside such a reservation is within its allocation, yet withXCL_WINDOW_NO_CARRY=1its accesses wrap into the base's window and touch the wrong memory, with no warning.Since the switch is opt-in, a log line when a reservation over 4 GiB is made with
no_carryon (or a note in the README entry) would make such runs easy to spot.@KDenKC on GitHub · 2026-11-25 22:27 UTC · original · edited 2026-11-25 22:33 UTC
@S1m0ne1997 the NVIDIA in-title A/B you asked for, RTX 5090.
XCL_WINDOW_NO_CARRY=1makes the driver code smaller (about −5 to −6 % of the code bound in the title, −10 % per split piece), but both arms lost the device at the same point in the title. One run per arm.Tested
main2898511+ #2404 (5ca9c23) + this PR (78bba5c, cherry-picked), plus a local diagnostic not in any PR:XCL_LOCAL_CODE_SUM=1callsGetCachedBlobon each PC pipeline at its first bind (the PC list'sSetPipelineStatehook) and logs the running sum.XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0, defaultXCL_PSO_WAIT_MS. Each started from its own copy of the same warm cache, ranxcl shaders --precompile --only cs --pipelineswith its switches, then the retail title for 600 s.XCL_WINDOW_NO_CARRY=1.chain.psoblob (driver code per split piece)0x887a0005nvlddmkm/ Display events at the removal.Not tested / caveats
GetCachedBlobcalls add CPU time at each first bind). An earlier run on the same cache lineage without the diagnostic or this PR was removed at 123.8 s, right at world start, so the run-to-run spread is large.SetPipelineStateslot in place, so its own calls go through the hook (checked in the code). Only pipelines set atCreateCommandList/Reset/ClearStateand never set again are missed.So on this card the saving is real but not enough to move the #2403 removal. With ~400 MB logged at the end, a 6 % cut buys tens of MB against a cliff the title crosses anyway at this scene.
AI use: Claude Code (Claude Opus 5.5) built and ran both arms and wrote this; Antigravity CLI (Gemini 4 Neon) analysed the logs and cache.
@pvfreis on GitHub · 2026-11-25 23:25 UTC · original
Test report for
78bba5cwith #2428ab2855f(#2427d356a74in it) onmaine1d84b7d(tree76fc443d): outputs and driver code size withXCL_WINDOW_NO_CARRY=1.Tested
--test-threads=4, NVIDIA 32-lane waves only. One run each.maine1d84b7d: 1422 / 1 / 46, 25. The failure on both is e2epresents.GetCachedBlobbytes, 60 compute programs (30 largest, 30 sampled, chosen first), unsplit, built at opt-level 3 without debug assertions; plain debug gives the same DXIL and root signatures (60/60, every arm).Not tested: outputs in release, split chains, GS, mesh, graphics; reservations over 4 GiB; code in use in a title; timing; other GPUs.
AI use: Claude Code. Claude Opus 5.5 wrote the test, ran it and wrote this; Claude Fable 5.2 rechecked it.
@DavidM1911 on GitHub · 2026-11-26 01:49 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@bielfreedom on GitHub · 2026-11-26 01:55 UTC · original
AMD Windows driver timing for #2496: on the RX 9070 XT,
XCL_WINDOW_NO_CARRY=1makes AMD'sCreateComputePipelineStateabout 13 % faster over 26 large retail compute programs, with 11 % less direct DXIL over all 2,689. Nothing failed in either arm. This measures cost only, not whether the window premise holds (the thread above).Setup
78bba5cmerged ontomain08db802, plus a local timing patch inxcl shadersthat writes each program's DXIL size and eachCreateComputePipelineStatetime to a file. One binary for both arms; only the switch differs.xcl shaders <retail shaders.rpf> --precompile --only cs --pipelineswithXCL_DIRECT_DXIL=1,XCL_PSO_DISK_CACHE=0, one driver thread, a fresh translation cache and a fresh executable name for every run (the AMD driver keys its own cache on the exe name, so every build is cold).DXIL size, all 2,689 compute programs (translation only)
XCL_WINDOW_NO_CARRY=1XCL_HEAP_WINDOWS=1)With the switch off the output matches
mainbyte for byte.Driver time, 26 large programs (switch windows), 2 interleaved rounds (off, on, then on, off)
XCL_WINDOW_NO_CARRY=1Mean 81.0 → 70.4 s (−13 %). Every one of the 20 unsplit programs in the set was faster with the switch, by 3–24 %. The largest ones:
620491641aa9bad66d1e4583f81297716fd9a5ebc95aee46d2d3c6c5d8463f50The pieces also change: with the switch, the six programs that are split produce 46 pieces instead of 56.
Not tested: heap windows in the driver, GPU output, and a title run.
AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.
@CharlyRien on GitHub · 2026-11-26 04:02 UTC · original
Test report, RTX 3090 (616.56), one run per arm. With
XCL_WINDOW_NO_CARRY=1the title ran 187 s into the world, through the heavy scene where our earlier run without the switch lost the device, and the run ended on its time limit with no removal. The witness, same settings without the switch, lost the device (0x887a0005) earlier than that: at world + 44 s. The code we count as bound was lower with the switch: 406 MB at most, against 420 MB at the witness's removal. Two more things measured:In the title, same settings, only the switch differs
XCL_WINDOW_NO_CARRY=10x887a0005at 164.4 s, world + 44 s, in busy world rendering (1,100-2,400 draws per 2 s)GetCachedBlobsize of each pipeline XCL built for a stand-in, from its first bind to its release.0x887a00050.2 s into the heavy scene, world + 158 s, at 437.1 MB with compute 273.6 MB;CreatePlacedResourceX).Window tests in our tree (
cargo test --release -p xcl --lib -- window, 42 tests)gpu_window_no_carry_reads_inside_allocations_alike(it runs both arms itself, root and heap windows) andtitle_reservations_stay_in_one_window_without_the_carry.XCL_DIRECT_DXIL=1 XCL_WINDOW_NO_CARRY=1for the whole process, all tests at once: 12 failed. 10 of them failed with "GPU fence still pending after 10000 ms", then0x887a0006: one test hung the GPU and the others followed, the HLSL arms included.--exact --test-threads=1): 37 passed, 5 failed. All 5 pass with the switch unset, run the same way. Each one crosses a window on purpose:window_at_lowers_to_32bit_carry_without_int64raw_loads_in_root_windows_respect_exec_and_boundsglobal_load_dwordx2gpu_heap_windows_reject_out_of_uma_aliasing(w0 + 0xFFFF_FFF0) + 0x20: it readsw0 + 0x10gpu_memory_windows_reject_out_of_uma_aliasinggpu_window_at_32bit_carry_edge_casesw0 + 0 - 16; the edge-case test does a store at(w0 + 0x30) - 0x30 - 16.0xFFFF_FFF0. The test arena backs 1 MB per window and a root UAV has no bounds, so we take it to be a page fault.Setup
RTX 3090 24 GB, driver 616.56, Windows 11 22631, release build; the tests in release too.
Tree:
maine1d84b7d, merged into our integrated tree:XCL_LOCAL_PSO_BUDGET_MB=380): it releases idle pipelines and rebuilds them on demand; our own command-list segments drop their pipeline references when the title's recording ends;Witness: that tree at
2a9f3638.Switch arm:
734e12f7= #2496 cherry-picked at78bba5ca, plus178052a3.direct_output_identity(@pvfreis's point);178052a3: a log of placed title buffers that cross a window boundary.Env, both arms:
XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_LOCAL_SKIP_CS_KB=4096 XCL_RUN_SECONDS=330 XCL_UMA_SHADOW=1 XCL_GPU_WAIT_TIMEOUT_MS=250 XCL_LOCAL_NO_WATCHDOG=1 XCL_LOCAL_RTSUM=1 XCL_LOCAL_RTSUM_AFTER_S=100 XCL_LOCAL_RTSUM_PCT=1 XCL_FRAME_DUMP=100000 XCL_LOCAL_FRAME_DUMP_AFTER_S=9999 XCL_LOCAL_FRAME_DUMP_WAIT_MS=20000 XCL_LOCAL_RTSUM_DUMP_MAX=12 XCL_LOCAL_RODATA_GETPC_ONLY=1 XCL_LOCAL_OOW_COPY=0 XCL_GPU_VIEW_BUFFERS=1 XCL_LOCAL_GPU_VIEW_ROOT_KB=512 XCL_LOCAL_TEX_OVERLAP=1 XCL_DIRECT_DXIL=1 XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_LOCAL_CODE_IN_USE=1 XCL_LOCAL_PSO_BUDGET_MB=380 XCL_LOCAL_ASIDE_EAGER=1 XCL_LOCAL_MEM_CENSUS=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_LOCAL_FAST_SAFE_READ=1 XCL_PAGE_BUDGET_MB=1024 XCL_GPU_VIEW_MB=1024XCL_WINDOW_NO_CARRY=1.XCL_LOCAL_NO_WATCHDOG=1keeps the title's stall watchdog from aborting.XCL_PAGE_BUDGET_MB=2048 XCL_GPU_VIEW_MB=1536and frame dumps from world + 20 s.Caches:
xcl shaders --precompile --only cs --pipelines, then--only ms);Not measured
AI use: Claude Code with Claude Opus 5.5, as the coordinating session and as its agents. The agents ported the PR, resolved the conflicts, wrote the diagnostic and the test and run jobs, read the logs and drafted this report. The coordinating session ran the builds, the tests and the runs, and checked the numbers quoted here.
78bba5ca22toae5650217a@S1m0ne1997 on GitHub · 2026-11-26 06:37 UTC · original
Updated to
ae56502(rebased ontomainb49be18, still one commit). What changed, from the review points above:direct_output_identitytoo, so theenormousprograms that go direct withoutXCL_DIRECT_DXILare kept apart as well.Tests at
ae56502(RTX 4090, driver 621.40):cargo test --workspace -- --test-threads=4: 1437 passed, 0 failed, 47 ignored.XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1(--no-fail-fast): 1436 passed, 1 failed, 47 ignored. The failure isgpu_heap_windows_reject_out_of_uma_aliasing, on the case it builds on purpose (an address that crosses into another window). No GPU hang.main1318 frames; this PR 1662 frames with the switch off and 1531 with it on; 0 removals and 0 crashes in all three. Blocks in the description.Results so far, from the reports above:
AI use: Claude Code (Claude Opus 5.5) made the changes, ran the suite and the smoke runs, and drafted this.
ae5650217ato2e8ff6b6ce@S1m0ne1997 on GitHub · 2026-11-26 06:44 UTC · original
Follow-up to the summary above:
2e8ff6bmakes the two existing carry tests pin the switch off for their own translations, so they always test the 64-bit sum. With the switch set for the whole process (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1), the suite is now 1437 passed, 0 failed, 47 ignored, the same as without it. Smoke blocks for2e8ff6bare in the description.xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.