Repository navigation
startup: stop probing unmapped guest memory from the texture and no-op paths - #2245
Its3rr0rsWRLD wants to merge 1 commit into
Conversation
|
Local test feedback on head
AI-assisted (Claude Code); the runs above were made locally. |
e72dc34 to
aa355f6
Compare
tedin7
left a comment
There was a problem hiding this comment.
Review of head aa355f6 (comment only, code and fixtures; no merge from this side).
Scope: new xmem export x2w_xmem_mapped_bytes, readable_window in d3d12_xs asks it first, four callers moved onto readable_window, a 30-frame retry cache for unmapped by-address textures, and an IID-shape check limited to the first 32 calls per queue slot. Shared runtime plus a main-executable startup path.
What I read and found sound:
x2w_xmem_mapped_bytesonly answers inside a page-mapping reservation. It returns no answer (caller probes as before) for other addresses, a range past its reservation, a range a recorded "commit at address" may cover, and an "unmapped" answer thatVirtualQuerydoes not confirm asMEM_RESERVE. The fallback is the old behavior, which is the safe direction.- A mapped prefix is still probed with
probe_readable, so a race between the registry answer and an unmap costs a fault, not a wrong answer. - The
shape_checkscounter inqueue_dynamicsits insidetemplate <int N>, so it is per slot, likenoop_slotanddevice_noop_slot. This matches the PR text. - Fixtures:
startup_queue_probe_{reserved,xmem}_{warp,hardware}has a control (reserved address without xmem: at most 32 faults in 200 calls) and the xmem case (0 faults). That is a reasonable regression test plus negative control for the fault count.
Open points for the merger:
- The PR claims to move time-to-intro (~4000 to ~200 frames) and cites a run with 52,820 vs 125 first-chance faults on the title. Those are executable results from the author and @NiiRoZz under a debugger-based launcher. We do not have the title, so we cannot reproduce or confirm them. I report only the fixture side.
- Timing change: a by-address texture can now appear up to 30 frames later than before. It is documented; whoever verifies on the title should check that it does not hide a texture that was visible before.
x2w_xmem_mapped_bytesis a newxmem_shim.defordinal (@23). Main has moved since (52 commits); the ordinal and theCMakeLists.txthunk need a fresh conflict check against current main.tests/xmem_mapped_bytes_check.pyneeds the Windows build tree; I did not run it on Linux.
Commands run locally (worktree on this exact head): git diff --stat origin/main...HEAD, targeted rg and sed reads of the diff, git diff --check origin/main...HEAD (clean), python3 tests/bidi_controls_check.py (PASS). I did not run Win2025 for this PR.
Because the PR claims to advance startup on the real title, the merge decision stays with MasterDomino or @R0Y00, who can verify it on the game. The branch is 52 commits behind main and needs an update first.
AI-assisted; commands listed were executed locally.
…p paths Every readability probe that touches an unmapped page raises a first-chance access violation. Under the debug launcher each one stops the process for a debugger round trip. On the title tested there were about 21000-25000 of them per run, almost all before the intro: by-address (slot-70) textures whose pages were not mapped yet, and a queue no-op slot (31) called every frame with the base of a physical-page pool whose mapping had failed. Slot 31 is now handled by queue_page_mappings (R0Y00#2307); the shape-check cap below still covers the slots left to queue_dynamic. No intended behaviour change: the same addresses are found readable or unreadable as before; only how that is found changes. The one timing difference is the 30-frame retry interval for by-address texture addresses found unmapped (below). - xmem: new export x2w_xmem_mapped_bytes(address, bytes, &mapped) answers from the page registry, without touching memory, how many bytes from address are mapped. It answers only inside xmem's page-mapping reservations; for any other address, a range past the reservation, a range a commit at address may cover, or an unmapped answer Windows does not confirm as reserved, it gives no answer and the caller probes as before. - d3d12_xs: readable_window asks xmem first (unmapped: no touch; mapped prefix: probed as before). publish_tiled_texture, names_known_iid, hex_text and the ExecuteCommandLists shape test in queue_dynamic go through readable_window instead of x2w_local::readable. - A by-address texture address that a probe found unmapped is not probed again for 30 frames (unless a write to it is announced). - queue_dynamic checks only the first 32 calls of a slot for an IID, like noop_slot and device_noop_slot already do. - The 5 s report logs "x2w-d3d12 readability: unmapped by xmem's page registry N, unreadable probes skipped N". - xmem_shim.def: x2w_xmem_mapped_bytes is ordinal 23 (17-22 are taken on main). - Tests: xmem_mapped_bytes (the export's answers), startup_queue_probe_{reserved,xmem}_{warp,hardware} (200 calls of unknown queue slot 30 with a reserved, unmapped r9: at most 32 faults without xmem, 0 with it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
aa355f6 to
c0e5f06
Compare
R0Y00
left a comment
There was a problem hiding this comment.
I rebuilt c0e5f06d in Release and ran six tests for mapped bytes, mapped pages, and reserved/XMem queue probes. All passed on WARP and RTX with zero skips. The new early return in publish_tiled_texture still changes what the caller can see: it applies the frame-based unreadable cache to this path and rejects the new SRV before readable_window can see that pages have since been mapped. A guest can probe an unmapped address, map and populate it, and request the view again in the same frame. Previously the second call reached the actual check. Please retain the registry optimization, but keep the second call's result unchanged (for example, skip the timed negative cache in this path). Add a source-built unmapped → map → publish/readback in one frame with an untouched sentinel for the first call. The older executable reports used different cache/scene conditions. Please keep the timing claim scoped to those reports unless there is a matched run at the final candidate.
What it does
One commit (
aa355f63, rebased ontomainb079f84). No intended behaviour change: the same addresses are found readable or unreadable as before; only how that is found changes.x2w_xmem_mapped_bytes(address, bytes, &mapped)(src/xmem_mapped_pages.cpp,src/xmem_shim.def@23, since @17-@22 are now taken on main). It answers from xmem's page registry, without touching memory, how many bytes fromaddressare mapped. It answers only inside xmem's page-mapping reservations. In every other case it gives no answer and the caller probes as before: an address outside those reservations (including the lazy startup blocks, which are not such reservations), a range that runs past its reservation, a range that a "commit at address" may cover (now recorded), or an "unmapped" answer thatVirtualQuerydoes not confirm asMEM_RESERVE, such as a released reservation.readable_windowasks xmem first. An unmapped answer is returned without touching the page. A mapped prefix is still probed exactly as before. If xmem.dll or the export is missing, it falls back to the old probe.readable_windowinstead ofx2w_local::readable:publish_tiled_texture(slot-70 by-address textures)names_known_iidandhex_textqueue_dynamicpublish_tiled_textureand inupload_texture. It is the only timing difference: such a texture can be picked up up to 30 frames later than before.queue_dynamicchecks only the first 32 calls of a slot for an IID, likenoop_slotanddevice_noop_slotalready do.x2w-d3d12 readability: unmapped by xmem's page registry N, unreadable probes skipped N.xmem_mapped_bytes(tests/xmem_mapped_bytes_check.py) checks the export's answers for: outside memory, an unmapped page, a mapped prefix, a range past the reservation, and a released reservation.startup_queue_probe_{reserved,xmem}_{warp,hardware}(tests/startup_queue_probe.cpp) makes 200 calls of queue slot 30 (a slot still left toqueue_dynamic) withr9set to a reserved, unmapped address. Without xmem at most 32 calls may fault (the first calls are still checked). With xmem's reservation, 0 may fault. Every call must return 0.Why
Every probe that touches an unmapped page raises a first-chance access violation. Under the debug launcher, each one stops the process for a debugger round trip. On the title tested there were about 21k-25k of these per run, mostly before the intro. Almost all came from slot-70 by-address textures whose pages were not mapped yet. Another ~400 came from queue slot 31, which was called every frame with the base of a pool whose mapping had failed. Slot 31 is now handled on main by
queue_page_mappings(#2307), so that source no longer reachesqueue_dynamic; the test above uses an unknown slot instead. With this change there are only tens per run.By my testing it takes the time to the intro from ~4000 frames to ~200 frames. That measurement came from a build that also published by-address textures before their pages were mapped, which is a separate change and is not in this PR.
Independent result from @NiiRoZz (comment, on the earlier head
e72dc34d): 52,820 first-chance access violations over a ~255 s run without this change, 125 with it.Tests
Release build (
cmake --preset release, Ninja, MSVC), Windows, on the rebased head.unified_buffer_paths*andvm_page_provenance*are excluded from every run (they leak system commit on this machine).xmem_mapped_bytesstartup_queue_probe_reserved_warp/_hardwarestartup_queue_probe_xmem_warp/_hardwarestartup_address*,*memory_srv*,*xmem*, the new tests^startup_startup_view_heap_warp,startup_small_texture_4k_addrlib,startup_logical_view_warp,startup_run_sh)Fail-first. I built
d3d12_xs.dllandxmem.dllfrom unmodifiedmain(b079f84) and ran the new tests against them:startup_queue_probe warp/hardware reservedwith main's d3d12_xs.dllstartup_queue_probe warp/hardware xmemwith main's d3d12_xs.dll and the new xmem.dllstartup_queue_probe warp/hardware xmemwith main's xmem.dllxmem_mapped_bytes_check.pywith main's xmem.dllfunction 'x2w_xmem_mapped_bytes' not found(fail)There were no failures on this branch, so I did not run a separate broad baseline on unmodified main.
What's left out
publish_tiled_texturenow has three callers, each with its own outcome handling, andlog_partial_tile_viewhashes the texels right after publishing, relying on the whole range being readable.[rdx]/[r8]hex logging inqueue_dynamic.Prepared by Claude Opus 5.5 (Claude Code).
🤖 Generated with Claude Code
https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc