Repository navigation
d3d12, xmem: remap release and console heap mirror only on request (RT-GEOMETRY-REMAP-AND-HEAP-MIRROR-OPT-IN) - #2356
Merged
aslan2142 merged 3 commits intoNov 26, 2026
Conversation
…P_RELEASE=1 Since ProjectLeonida#2350 a remap of physical pages that gives a page another frame retired the geometry copies over it, on by default. In the first world run of that main on an RX 7900 XTX (RADV) the copies were retired by the thousand (evicted 15010 in about 40 s) and the run ended in a GPUVM page fault (TCP read) and a lost device; the same build settings without it ran eight minutes with evicted 0 and no fault. A remap leaves the address valid on the console, so the title keeps using what names it, and not everything that names a copy's address is rewritten when the copy goes: - a root view is resolved while its list is recorded (d3d12_com.cpp, GraphicsCommandList::address); a list recorded before the retirement and executed in an ExecuteCommandLists begun after it is not among the replays the retirement waits for (kAfterExecutes covers only those in progress), so it reads the freed copy; - a placed buffer view written outside a console heap carries the copy's address for as long as the descriptor lives. The remap release is now off unless the variable is 1, read at every remap; the copies follow the new pages through the refresh, as before ProjectLeonida#2350. Freeing, decommitting and unmapping still retire copies. Tests: xmem_test test_remap_releases checks that a remap releases nothing by default and with 0, then the existing checks with 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ead it again
GetEnvironmentVariableA at every remap ran under g_phys_mutex in every scatter call; with it, xmem_test's split race
("the reader of the views' last pages never faults or misreads") failed in two full Wine runs in a row, where main
passed it twice. The value is cached as before ProjectLeonida#2350's default changed; rt::xmem::reload_remap_release_setting lets
test_remap_releases switch it. Two full runs since: no change against main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…OR=1 The mirror (7460590, in ProjectLeonida#2350) was on by default. World runs on merged main on an RX 7900 XTX (RADV), the same settings otherwise: - remap release on, mirror on: GPU page fault and a lost device about 40 s into the world; - remap release off, mirror on: no evictions and no page fault, but a hang in a library compute program on the direct queue about a minute in, a ring timeout and a lost device; - both off: past five minutes in the world with no fault or hang, ending where the build before ProjectLeonida#2350 ended, on the title's own breakpoint. Why the mirror hangs the GPU is not known. It is off unless the variable is 1; the release sweep then reads the copy, as before the mirror. Tests: d3d12_console_heap_mirror sets LEONIDA_HEAP_MIRROR=1; a new ctest entry, d3d12_console_heap_mirror_default, runs the same program without the variable and expects no mirror (it fails on main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 26, 2026
aslan2142
added a commit
that referenced
this pull request
Nov 26, 2026
Both came in with #2350 as additions on top of stopgap mechanisms, broke world runs (remap release: a GPUVM page fault and a lost device; the mirror: a GPU hang) and were made opt-in by #2356. They go completely; with both variables unset, main behaves as before. Remap release (LEONIDA_GEOMETRY_REMAP_RELEASE, from 36771ec): - xmem.cpp: RemapReleases, remap_releases_enabled() and the page recording in unmap_range_locked; the four call sites (XMemMapPhysicalPages, the scatter call, both copy_page_mappings). - xmem.h/xmem.cpp: the test seam rt::xmem::reload_remap_release_setting(). - xmem_test: test_remap_releases (and the title_geometry_watch.h include only it used). - README row, the docs/d3d12_vulkan.md paragraph; comments that named it. Console heap mirror (LEONIDA_HEAP_MIRROR, LEONIDA_HEAP_MIRROR_CHECK, from 7460590): - src/console_heap_copy.h goes. ConsoleHeap::copy is a plain std::uint8_t* again, written with memcpy/memset as before the mirror, including the zeroing site that #2350's merge of #2162 resolved as heap.copy.zero(); the compute-input probe reads it directly again. Without the mirror, view() was the copy itself, so nothing changes. - heap_mirror_enabled(), heap_mirror_check_enabled(), check_console_heap_mirror(), the per-heap check counters and log line, and the test API console_heap_mirror_mismatches() (d3d12_com.h). - Tests console_heap_copy, d3d12_console_heap_mirror, _off and _default with their CMake entries; README rows and the docs/d3d12_vulkan.md sentences. Kept, because other paths use them or main's behaviour with the variable unset depends on them: - LEONIDA_GEOMETRY_HOST and its DeviceState memory-type assert (dc9ef1a). - The final copy at retirement (GeometryViews::retire_range's final_copy, "copied at retirement" in the geometry buffers line): XMemFree of a title heap block (free_title_block) reports a release while the block's memory stays committed and readable, so that copy is still made without remap release. Comments now say that instead of naming remaps; geometry_views_test case 15 stays. - forget_pool_span and "retired with their copy" in the title memory line: any retirement (free, decommit, unmap) feeds it. - The release queue's joining of touching ranges (title_geometry_watch.h): unmaps report page runs too; geometry_views_test case 16 stays. - LEONIDA_CONSOLE_RELEASE_FILTER, which predates the mirror; its sweep reads the copy again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Measured on NVIDIA after this merged: with both switches unset (the new defaults), the title crashes on the CPU at 80-160 s on an RTX 2070 SUPER (616.56), in 4 of 5 boots. With |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two regressions that #2350 brought in. Since then, a world run loses the device within about a minute. Both features responsible are now off unless asked for:
LEONIDA_GEOMETRY_REMAP_RELEASE=1turns on retiring geometry copies when pages are remapped.LEONIDA_HEAP_MIRROR=1turns on the host-RAM mirror of a console heap's copy.Claimed in the coordination issue as: RT-GEOMETRY-REMAP-AND-HEAP-MIRROR-OPT-IN
What regressed
World runs on merged
main(RX 7900 XTX, RADV, Wine, the same settings otherwise):evicted 0and no fault.Why: remap release
36771ec53) made a remap of physical pages (XMemMapPhysicalPageswith pages, the scatter call,CopyPageMappingsBatchX) retire the geometry copies over every page that gets another frame.d3d12_com.cpp,GraphicsCommandList::address). A list recorded before the retirement but executed in anExecuteCommandListsthat starts after it is not one of the replayskAfterExecuteswaits for, so it reads the freed copy.Why: heap mirror
746059011) is what the filtered release sweep (LEONIDA_CONSOLE_RELEASE_FILTER=1) reads to decide which V# slots still name a released buffer.write()andzero(). I found no write that bypasses them.LEONIDA_HEAP_MIRROR=1 LEONIDA_HEAP_MIRROR_CHECK=1, which logs every slot where the mirror and the copy differ.The fix
remap_releases_enabled()inxmem.cppreturns true only whenLEONIDA_GEOMETRY_REMAP_RELEASEis1. The value is read once, and a test seam,rt::xmem::reload_remap_release_setting(), reads it again. With it off, copies follow the new pages through the refresh, as they did before [integration] RT-LINUX-AMD-WORLD: what drew the world on Linux/AMD, with eleven runtime PRs, docs for running per GPU #2350. Freeing, decommitting and unmapping pages still retire copies.heap_mirror_enabled()ind3d12_vulkan_device.cppreturns true only whenLEONIDA_HEAP_MIRRORis1. With it off, the sweep reads the copy itself, as it did before the mirror.runtime/README.md,docs/d3d12_vulkan.mdandsrc/console_heap_copy.hgive both defaults and why.Tests
xmem_test(test_remap_releases): a remap releases nothing when the variable is unset or0; the existing checks run with1.d3d12_console_heap_mirror_testexpects a mirror only withLEONIDA_HEAP_MIRROR=1:d3d12_console_heap_mirrorsets1, withLEONIDA_HEAP_MIRROR_CHECK=1.d3d12_console_heap_mirror_offsets0.d3d12_console_heap_mirror_default, with the variable unset.main's runtime, the new default checks in both tests fail.cteston llvmpipe: 112/112 pass.main:d3d12_console_heap_mirror_default, which passes.xmem_test, whichmainpassed twice. Reading the value once fixed that: two full runs since with no change.tests/test_docs_env_vars.py,tests/test_ci_registration.pyandscripts/check_no_game_data.pyon the changed files: pass.Not tested
main, which is equivalent.AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)