xmem: keep shared page runs consistent for readers, and join single-page maps into them #2905

Closed
JohnConnorNPC wants to merge 0 commits from upstream-pr/2905 into main
JohnConnorNPC commented 2026-11-26 18:32:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-26T18:32:36Z.


How to test

  1. Build xmem.dll and the stand-in DLLs as for any start-up run: cmake --preset dev and
    cmake --build --preset dev. On Linux, use the clang-cl cross build in docs/non-windows-hosts.md.
  2. Run the start-up launcher with lazy memory and shared views on, and no timeout.
    • Windows: tools/startup/run.ps1 <usual exe/data/log arguments> -Seconds 0 -MemoryGiB 40 -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory.
    • -LazyMemory sets X2W_XMEM_LAZY_COMMIT, X2W_XMEM_LAZY_STARTUP and X2W_XMEM_SHARED_VIEWS. Without
      X2W_XMEM_SHARED_VIEWS, the reader waits, wrappers and joins in group 3 stay off.
    • Linux: tools/startup/run.sh ... --seconds 0 --memory-gib 40 --fake-user --render --translate --gpu-mirror --host-cpu --startup-below-40, with X2W_XMEM_LAZY_COMMIT=1 X2W_XMEM_LAZY_STARTUP=1 X2W_XMEM_SHARED_VIEWS=1
      in the environment.
    • Both platforms: also set X2W_DEVICE_TYPE=6 X2W_PRESENT_COMPOSITE=1 X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_RELEASE_RETIRED_VIEWS=1 X2W_XAPU_TYPED_COMPLETIONS=1.
    • Our runs also set X2W_D3D12_BUDGET=1 and used an input script that answers the account prompt once.
  3. What to look for:
    • The run reaches the menus.
    • The x2w-d3d12 heartbeat: N frames presented count keeps rising past about 170 s, with no start-up hang.
    • In our like-for-like run, main stopped presenting at 16.5 s and hit the start-up watchdog at 56.3 s.
    • Known open item: after the menu, the executable shows its own "data file missing or corrupt" dialog, of
      undetermined cause (see Evidence).

XMem pages are mapped from 64 KiB sections. With X2W_XMEM_SHARED_VIEWS=1, pages that are adjacent in the
address space and adjacent slots of one section share one view, called a run. Unmapping one page of a run takes
the run apart and maps its other pages again (a run break). A console executable under test maps nearly every
page with its own call: 45595 of 45602 recorded runs had one page. Under Wine each MapViewOfFile3 is a server
round trip. In one run its cost rose from 0.04 ms to 0.92 ms per call as the view count grew, so start-up spent
most of its time mapping.

This PR has one aim: XMem page runs under Wine are cheaper to build, and code that reads those pages sees them
committed while a run changes. It has three groups of commits, in commit order.

On Windows, group 3's reader waits, its import wrappers and all joining are behind the shared-views opt-in
(X2W_XMEM_SHARED_VIEWS=1; run.ps1 -LazyMemory sets it). Without it, readers are called once and pages are
mapped as before. Groups 1 and 2, split-first and the fault-retry fixes need no switch. See Switches.

Group 1: slot 31 placeholder splits under Wine (3 commits)

  • xmem: split slot 31 placeholders when the OS hides the placeholder bit.
    • Wine reports placeholders without the 0x100 region flag. As a result, every queue slot 31 split or
      coalesce whose run was not exactly one placeholder failed with ERROR_INVALID_ADDRESS.
    • A one-time probe turns a fallback on only where the bit is missing. Where the OS reports it, nothing changes.
  • Test xmem_placeholder_split.
    • Its control, xmem_placeholder_split_control, turns the fallback off and passes only when the split step
      fails. It skips (77) where the OS reports the bit.
    • Docs: docs/experiments.md and the README row.

Group 2: DirectStorage copies under the mapping mutex (3 commits)

  • xmem: copy DirectStorage destinations under the mapping mutex, startup: copy DirectStorage data through x2w_xmem_copy_to_destination.
    • XCRDAPI's VirtualQuery pre-check could run while a break had the destination page unmapped for a moment.
      It then refused a destination that was mapped both before and after.
    • The check and the copy now both run in xmem.dll under memory.mutex, which every break also holds.
    • Without xmem.dll, XCRDAPI checks and copies as before.
    • A copy that faults on its source now fails the request ("copy faulted (source not readable)") instead of
      raising.
  • Test startup_dstorage_break_window.
    • It holds a break open and submits a request into a page that reads MEM_RESERVE inside it. The request
      must wait for the hold, then complete with every byte in place.
    • Its control, startup_dstorage_break_window_control, builds XCRDAPI without the export lookup and must
      report "refused while the run was broken".

Group 3: page runs (11 commits)

Fewer map calls:

  • xmem: split an owned placeholder before mapping a page into it.
    • A map into the middle of a larger placeholder used to fail once, then split. Now the split comes first, so a
      single-page call makes one MapViewOfFile3 attempt instead of two. If the split or the map fails, the old
      order runs.
    • Test xmem_map_split_first: 8 maps for 8 pages. Its control, xmem_map_split_first_control
      (X2W_XMEM_TEST_MAP_FIRST=1), measures 2 maps per page.

Readers outside run breaks. A touch of a page inside a break faults, and the fault handler retries it. A region
query or a kernel copy does not fault: it sees the page as reserved, or fails.

  • xmem: answer non-faulting readers outside run breaks.
    • New export x2w_xmem_stable_call(fn, context). It runs fn once when no break begins or ends around it,
      and otherwise runs it again under the mapping mutex.
    • These readers now answer through it: XMemVirtualQuery, and in the stand-ins x2w_local::writable,
      slot 133 measure_placed_buffer and snapshot_samplers.
  • xmem: answer the main module's VirtualQueryEx outside run breaks.
    • With shared views on, the main module's VirtualQueryEx import goes through a wrapper that uses
      stable_call.
    • The module is pinned only when an import was changed.
  • xmem: run readers once without shared views, and write their answers after a break.
    • Without the switch, stable_call calls fn directly.
    • Query answers go to a local copy first and are written to the caller's buffer after the call. That buffer
      may be in a lazily committed page.
  • xmem: write back only what XMemVirtualQuery's query writes, and pass lines at the end: the write-back covers
    the bytes the query writes and no more.
  • xmem: run title ReadFile/WriteFile again after a run break refused the buffer.
    • The main module's ReadFile and WriteFile imports are wrapped.
    • A synchronous call is run again, up to 4 attempts, but only when all three hold: it failed with
      ERROR_NOACCESS or ERROR_INVALID_USER_BUFFER, a break overlapped it, and its buffer lies in a run.
    • Under Wine before this change: ReadFile into the run failed with 998 and left the position as it was, and
      WriteFile from it failed with 1784. After it, the read gets all 4096 bytes.

Fault retries across breaks:

  • xmem: retry a fault in the break after the one the handler saw end. This fixes a pre-existing bug:
    • A handler that read the break generation after the break ended named the next break instead. A fault on
      the same page in that next break was then not retried.
    • The hold-ignored child of xmem_page_runs_check.py crashed in 6 of 6 runs before the fix and passed 6 of 6
      after it.
  • xmem: retry a fault from any of the last 64 breaks, not only the last: a fault whose break is among the last
    64 is retried. Once its break is older than that, the fault is passed on, like any other fault.

Joins:

  • xmem: join a page mapped on its own call to the view before it, with X2W_XMEM_SHARED_VIEWS=1 only.
    • A call whose pages form one run joins the recorded run that ends at its address.
    • It joins only when its first page is the next slot of the same section and both lie in one shim
      reservation.
    • The run is unmapped inside a break, the placeholders are joined, and one view is mapped over both.
    • If a step before the unmap is refused, nothing changes. If one after it is refused, the old layout is
      restored.
    • Default mode is unchanged.
  • xmem: stop a joined run at 64 pages.
    • A join that would make the run longer than 64 pages maps the new pages separately.
    • Fixture timing under Wine (median of 3 to 5 runs), unmapping the middle page of an R-page run:
      • the break costs 0.105 ms at R = 16, 0.275 ms at 64, 2.112 ms at 512 and 13.176 ms at 4096;
      • at the cap, a join costs about as much as mapping its own view (1.515 ms against 1.392 ms).
  • xmem: say the run cap bounds joined runs only, and test the break ring's edge.
    • This narrows the previous commit's message: only joined views are capped.
    • A view mapped by one call, or the surviving pages that a break maps back together, can still be longer, as
      before this PR.
    • Test: the 63rd break back is still retried, and the 64th is passed on.

Tests and changed expectations:

  • xmem_run_break_readers, with _control, _next_break_control, _default, _lazy, _two_runs, _mirror
    and _ring_edge.
    • They hold a break open in the test-controls build and check that each reader waits for it and then sees the
      page committed. The readers cover ReadFile and WriteFile too.
    • The control build calls the readers directly, and they answer inside the window.
  • xmem_cross_call_merge, with _control (one view per call under X2W_XMEM_TEST_NO_MERGE=1), _deployed
    (the deployed shim ignores that switch) and _default (default mode). Its capped case covers the 64-page cap.
  • Changed expectations (no check is weakened):
    • xmem_page_runs_check.py expected "mapping the page again does not join the pieces: three views". The page
      now joins the lower piece, which gives two views. xmem_cross_call_merge_control still asserts the
      three-view layout.
    • xmem_page_runs_device_check now maps the upper view first and the single pages in reverse slot order.
      Its view boundaries are the same as before, and its view-count assertion is unchanged.

Switches

Change Active when
Slot 31 placeholder fallback the OS hides the placeholder bit (probed at first use)
Split-first map, fault-retry fixes always
DirectStorage check and copy under the mutex always, when XCRDAPI finds xmem.dll's export
stable_call waits, the VirtualQueryEx/ReadFile/WriteFile wrappers, joins and their cap X2W_XMEM_SHARED_VIEWS=1
X2W_XMEM_TEST_* (MAP_FIRST, NO_MERGE, MERGE_CAP, HOLD_WINDOW, HOLD_RETRY, FAULT, NO_PLACEHOLDER_FALLBACK) test-controls build only

Test

Host: Linux, cross-built with clang-cl 19 and xwin, tests run under Proton Experimental (wine-11.0) in a fresh
prefix. The runner reads ctest's JSON and applies each test's ENVIRONMENT, WILL_FAIL, PASS/FAIL_REGULAR_EXPRESSION,
TIMEOUT and SKIP_RETURN_CODE. Base under the same runner: main 6ee878d8. Head under test: 4a43a173.

Build scope on this host: ninja -k 0 ends with exit 1 and the same 419 failed targets on base and on this
branch. They are the MASM fixtures and the generator-driven targets, which the cross toolchain cannot build.
Every runtime DLL and every test this PR adds or touches builds. Tests whose executable did not build are not
run here, and CI is their first run.

  • Full suite, everything that runs here:
    • Base 6ee878d8 (2441 registered): 578 passed, 1729 failed, 58 skipped (77) of 2365; nocommand 76.
    • Nearly all of those failures are the environment: D3D12, DXGI, GPU and dxc are not available under Wine here.
    • The same runner on this head (2459 registered) is still running. Its counts, and the tests whose result
      differs from base, will be added here.
  • The PR's own tests (^xmem_|^startup_dstorage_break_window|^startup_placed_buffer_range|^startup_translated_sampler_bindings|^startup_local_log):
    • On this head, these results come with the full-suite run above.
    • On the stack before the rebase, whose xmem sources and xmem tests are file-identical to this head, the
      recorded run gave 48 passed, 39 failed of 87. Five of the 39 exited 77.
    • That failure set was the same as before the round commits, and every new test and control passed.
  • Pure-Python checks, the CI python-linux command from .github/workflows/windows.yml (Python 3.13, requirements-dev):
    all 210 checks passed on base and on this head (exit 0 both).
  • Negative controls: every new check has a control that fails, or measures the old behaviour. Mutations of the
    change, each paired with its check, all fail that check:
    • drop the slot-adjacency condition, the break around the join, the restore, or the reservation bound;
    • join without shared views; drop the 64-page cap test;
    • break_id = seen | 1; a break ring of 1, or of 128 (no eviction at 64);
    • stable_call never retries; the ReadFile/WriteFile wrapper returns 0, or retries with no bound.
  • Two mutations do not fail under Wine. Wine's ReadFile and VirtualQueryEx write into an uncommitted
    mapped slot without faulting, so the lazy-slot cases of the ReadFile wrapper and of the VirtualQueryEx
    wrapper are unpinned here. Windows CI is their first real check.

Not run here (Windows only, so CI is their first run):

  • xmem_page_runs_device_warp: the edit compiles, but the test was not run.
  • linear_buffer_backing_*: not touched. Whether the joins change their layout is not measured.
  • Every _warp/_hardware D3D12 test, offscreen_*, startup_sampler_*.

Evidence from a running title

Local runs of a console executable under test on Linux under Wine/Proton. Each run had no timeout, and each
configuration was run once unless a count is given. Switches: 40 GiB, render, host CPU rewrites, GPU mirror, a
fake user, start-up blocks below 2^40, lazy commit and X2W_XMEM_SHARED_VIEWS=1.

Like for like: the same launcher, environment and arguments, with only the build different.

  • Main 6ee878d8. Main already honours all three memory switches, but its shared views are the basic version:
    • Frames: 135 at 5.0 s, 249 at 10.0 s and 331 at 16.5 s, then none.
    • After 39.8 s with no frame, start-up ended at 56.3 s on the executable's own start-up watchdog.
  • Main plus this branch, up to its third round commit (ReadFile/WriteFile):
    • Frames: 1215 at 50.5 s, 1977 at 92.0 s and 2478 at 169.0 s.
    • The run reached the menus at about 70 s with no post-load stall.
    • It ended at 208.5 s on an access violation at the debugger's configured stop address. That is the same class
      as an earlier split-first-only run, which ended the same way at 636 s.
  • The same branch build again, started from the main run's exact shader cache. The cache's name-and-size
    manifest had the same md5 across the copies, with 218001 files and none new during the run.
    • Frames: 1116 at 50.1 s and 2535 at 167.8 s.
    • It answered the account prompt at 45.5 s, wrote storage at about 70 s, and ended at the configured stop
      address at 204.5 s.
    • The main run had the same environment, cache, storage and driver state. It reached neither the prompt nor
      the storage write.
    • So neither the shader cache nor that shared state separates the two builds.
  • Hypothesis, not tested: on main, a reader faults inside a run break and nothing handles the fault there.
  • After the menu, the executable showed its own "data file missing or corrupt" dialog.
    • Every archive it opened returned success at the file layer. The cause is not determined.
    • Main never gets that far, so the dialog is not shown to be absent on main.
  • The branch run's log also has 11757 first-chance read AVs inside the D3D12 stand-in. Earlier builds on an
    older main did not show them. This PR changes no D3D12 code. Hypothesis, not tested: they come from main.

Other controls:

  • Main 6ee878d8 without shared views: no frame was presented, and start-up stopped on the same watchdog.
    • One run had lazy commit on, and its first stop came at 32.4 s.
    • The other had lazy memory off, and stopped at 32.3 s.
  • Older main (52905a32): hang at about 47 s in 2 of 2 runs.
  • The same groups before the cap (with a local counters-only layer, not in this PR): 2 of 2 runs had no
    start-up hang (1064 s and 408 s), with 54545 and 54549 joins and 0 lost.
    • After loading, frames fell to 2.4/s and 0.55/s, against 11.8/s with split-first only.
    • The cause was breaks of runs thousands of pages long, which is why the cap commit exists.
  • No run of the final head has been made. The last two round commits (query write-back, cap wording and the
    ring-edge test) are not in any title run.

Measured vs not

  • Measured: the fixture behaviour above under Wine, and the counters and frame counts of the runs listed.
  • Not measured:
    • any Windows run of these changes (CI gives the first);
    • whether the joins change the linear_buffer_backing layouts;
    • how often the executable calls VirtualQueryEx (it imports it, but the calls were not counted);
    • the cause of the data-file dialog.
  • Known limits:
    • The ReadFile/WriteFile retry assumes the failed call had no partial side effect. Only Wine's full
      failure was measured.
    • Only the main module's ReadFile and WriteFile imports are wrapped. Not wrapped: ReadFileEx/WriteFileEx,
      scatter/gather, DeviceIoControl, sockets, I/O from other modules and I/O through GetProcAddress.
    • Overlapped I/O bypasses the retry.
    • A genuine fault in a range of a finished break that was since remapped is retried at most once per later
      break before it is passed on. A range that is broken often can therefore delay a real crash report by one
      retry per break.
  • Readers not moved: test-only CPU upload helpers, the opt-in capture path, the pointer-like-qword count
    heuristic, and MEM_PRIVATE heap paths.
  • Nothing here claims that a title runs or reaches gameplay.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5515330695 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2905). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-26T18:32:36Z. --- ### How to test 1. Build xmem.dll and the stand-in DLLs as for any start-up run: `cmake --preset dev` and `cmake --build --preset dev`. On Linux, use the clang-cl cross build in `docs/non-windows-hosts.md`. 2. Run the start-up launcher with lazy memory and shared views on, and no timeout. - Windows: `tools/startup/run.ps1 <usual exe/data/log arguments> -Seconds 0 -MemoryGiB 40 -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory`. - `-LazyMemory` sets `X2W_XMEM_LAZY_COMMIT`, `X2W_XMEM_LAZY_STARTUP` and `X2W_XMEM_SHARED_VIEWS`. Without `X2W_XMEM_SHARED_VIEWS`, the reader waits, wrappers and joins in group 3 stay off. - Linux: `tools/startup/run.sh ... --seconds 0 --memory-gib 40 --fake-user --render --translate --gpu-mirror --host-cpu --startup-below-40`, with `X2W_XMEM_LAZY_COMMIT=1 X2W_XMEM_LAZY_STARTUP=1 X2W_XMEM_SHARED_VIEWS=1` in the environment. - Both platforms: also set `X2W_DEVICE_TYPE=6 X2W_PRESENT_COMPOSITE=1 X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_RELEASE_RETIRED_VIEWS=1 X2W_XAPU_TYPED_COMPLETIONS=1`. - Our runs also set `X2W_D3D12_BUDGET=1` and used an input script that answers the account prompt once. 3. What to look for: - The run reaches the menus. - The `x2w-d3d12 heartbeat: N frames presented` count keeps rising past about 170 s, with no start-up hang. - In our like-for-like run, main stopped presenting at 16.5 s and hit the start-up watchdog at 56.3 s. - Known open item: after the menu, the executable shows its own "data file missing or corrupt" dialog, of undetermined cause (see Evidence). XMem pages are mapped from 64 KiB sections. With `X2W_XMEM_SHARED_VIEWS=1`, pages that are adjacent in the address space and adjacent slots of one section share one view, called a run. Unmapping one page of a run takes the run apart and maps its other pages again (a run break). A console executable under test maps nearly every page with its own call: 45595 of 45602 recorded runs had one page. Under Wine each `MapViewOfFile3` is a server round trip. In one run its cost rose from 0.04 ms to 0.92 ms per call as the view count grew, so start-up spent most of its time mapping. This PR has one aim: XMem page runs under Wine are cheaper to build, and code that reads those pages sees them committed while a run changes. It has three groups of commits, in commit order. On Windows, group 3's reader waits, its import wrappers and all joining are behind the shared-views opt-in (`X2W_XMEM_SHARED_VIEWS=1`; `run.ps1 -LazyMemory` sets it). Without it, readers are called once and pages are mapped as before. Groups 1 and 2, split-first and the fault-retry fixes need no switch. See Switches. ### Group 1: slot 31 placeholder splits under Wine (3 commits) - `xmem: split slot 31 placeholders when the OS hides the placeholder bit`. - Wine reports placeholders without the `0x100` region flag. As a result, every queue slot 31 split or coalesce whose run was not exactly one placeholder failed with `ERROR_INVALID_ADDRESS`. - A one-time probe turns a fallback on only where the bit is missing. Where the OS reports it, nothing changes. - Test `xmem_placeholder_split`. - Its control, `xmem_placeholder_split_control`, turns the fallback off and passes only when the split step fails. It skips (77) where the OS reports the bit. - Docs: `docs/experiments.md` and the README row. ### Group 2: DirectStorage copies under the mapping mutex (3 commits) - `xmem: copy DirectStorage destinations under the mapping mutex`, `startup: copy DirectStorage data through x2w_xmem_copy_to_destination`. - XCRDAPI's `VirtualQuery` pre-check could run while a break had the destination page unmapped for a moment. It then refused a destination that was mapped both before and after. - The check and the copy now both run in xmem.dll under `memory.mutex`, which every break also holds. - Without xmem.dll, XCRDAPI checks and copies as before. - A copy that faults on its source now fails the request ("copy faulted (source not readable)") instead of raising. - Test `startup_dstorage_break_window`. - It holds a break open and submits a request into a page that reads `MEM_RESERVE` inside it. The request must wait for the hold, then complete with every byte in place. - Its control, `startup_dstorage_break_window_control`, builds XCRDAPI without the export lookup and must report "refused while the run was broken". ### Group 3: page runs (11 commits) Fewer map calls: - `xmem: split an owned placeholder before mapping a page into it`. - A map into the middle of a larger placeholder used to fail once, then split. Now the split comes first, so a single-page call makes one `MapViewOfFile3` attempt instead of two. If the split or the map fails, the old order runs. - Test `xmem_map_split_first`: 8 maps for 8 pages. Its control, `xmem_map_split_first_control` (`X2W_XMEM_TEST_MAP_FIRST=1`), measures 2 maps per page. Readers outside run breaks. A touch of a page inside a break faults, and the fault handler retries it. A region query or a kernel copy does not fault: it sees the page as reserved, or fails. - `xmem: answer non-faulting readers outside run breaks`. - New export `x2w_xmem_stable_call(fn, context)`. It runs `fn` once when no break begins or ends around it, and otherwise runs it again under the mapping mutex. - These readers now answer through it: `XMemVirtualQuery`, and in the stand-ins `x2w_local::writable`, slot 133 `measure_placed_buffer` and `snapshot_samplers`. - `xmem: answer the main module's VirtualQueryEx outside run breaks`. - With shared views on, the main module's `VirtualQueryEx` import goes through a wrapper that uses `stable_call`. - The module is pinned only when an import was changed. - `xmem: run readers once without shared views, and write their answers after a break`. - Without the switch, `stable_call` calls `fn` directly. - Query answers go to a local copy first and are written to the caller's buffer after the call. That buffer may be in a lazily committed page. - `xmem: write back only what XMemVirtualQuery's query writes, and pass lines at the end`: the write-back covers the bytes the query writes and no more. - `xmem: run title ReadFile/WriteFile again after a run break refused the buffer`. - The main module's `ReadFile` and `WriteFile` imports are wrapped. - A synchronous call is run again, up to 4 attempts, but only when all three hold: it failed with `ERROR_NOACCESS` or `ERROR_INVALID_USER_BUFFER`, a break overlapped it, and its buffer lies in a run. - Under Wine before this change: `ReadFile` into the run failed with 998 and left the position as it was, and `WriteFile` from it failed with 1784. After it, the read gets all 4096 bytes. Fault retries across breaks: - `xmem: retry a fault in the break after the one the handler saw end`. This fixes a pre-existing bug: - A handler that read the break generation after the break ended named the next break instead. A fault on the same page in that next break was then not retried. - The hold-ignored child of `xmem_page_runs_check.py` crashed in 6 of 6 runs before the fix and passed 6 of 6 after it. - `xmem: retry a fault from any of the last 64 breaks, not only the last`: a fault whose break is among the last 64 is retried. Once its break is older than that, the fault is passed on, like any other fault. Joins: - `xmem: join a page mapped on its own call to the view before it`, with `X2W_XMEM_SHARED_VIEWS=1` only. - A call whose pages form one run joins the recorded run that ends at its address. - It joins only when its first page is the next slot of the same section and both lie in one shim reservation. - The run is unmapped inside a break, the placeholders are joined, and one view is mapped over both. - If a step before the unmap is refused, nothing changes. If one after it is refused, the old layout is restored. - Default mode is unchanged. - `xmem: stop a joined run at 64 pages`. - A join that would make the run longer than 64 pages maps the new pages separately. - Fixture timing under Wine (median of 3 to 5 runs), unmapping the middle page of an R-page run: - the break costs 0.105 ms at R = 16, 0.275 ms at 64, 2.112 ms at 512 and 13.176 ms at 4096; - at the cap, a join costs about as much as mapping its own view (1.515 ms against 1.392 ms). - `xmem: say the run cap bounds joined runs only, and test the break ring's edge`. - This narrows the previous commit's message: only joined views are capped. - A view mapped by one call, or the surviving pages that a break maps back together, can still be longer, as before this PR. - Test: the 63rd break back is still retried, and the 64th is passed on. Tests and changed expectations: - `xmem_run_break_readers`, with `_control`, `_next_break_control`, `_default`, `_lazy`, `_two_runs`, `_mirror` and `_ring_edge`. - They hold a break open in the test-controls build and check that each reader waits for it and then sees the page committed. The readers cover `ReadFile` and `WriteFile` too. - The control build calls the readers directly, and they answer inside the window. - `xmem_cross_call_merge`, with `_control` (one view per call under `X2W_XMEM_TEST_NO_MERGE=1`), `_deployed` (the deployed shim ignores that switch) and `_default` (default mode). Its `capped` case covers the 64-page cap. - Changed expectations (no check is weakened): - `xmem_page_runs_check.py` expected "mapping the page again does not join the pieces: three views". The page now joins the lower piece, which gives two views. `xmem_cross_call_merge_control` still asserts the three-view layout. - `xmem_page_runs_device_check` now maps the upper view first and the single pages in reverse slot order. Its view boundaries are the same as before, and its view-count assertion is unchanged. ### Switches | Change | Active when | |---|---| | Slot 31 placeholder fallback | the OS hides the placeholder bit (probed at first use) | | Split-first map, fault-retry fixes | always | | DirectStorage check and copy under the mutex | always, when XCRDAPI finds xmem.dll's export | | `stable_call` waits, the `VirtualQueryEx`/`ReadFile`/`WriteFile` wrappers, joins and their cap | `X2W_XMEM_SHARED_VIEWS=1` | | `X2W_XMEM_TEST_*` (MAP_FIRST, NO_MERGE, MERGE_CAP, HOLD_WINDOW, HOLD_RETRY, FAULT, NO_PLACEHOLDER_FALLBACK) | test-controls build only | ### Test Host: Linux, cross-built with clang-cl 19 and xwin, tests run under Proton Experimental (wine-11.0) in a fresh prefix. The runner reads ctest's JSON and applies each test's ENVIRONMENT, WILL_FAIL, PASS/FAIL_REGULAR_EXPRESSION, TIMEOUT and SKIP_RETURN_CODE. Base under the same runner: main 6ee878d8. Head under test: 4a43a173. Build scope on this host: `ninja -k 0` ends with exit 1 and the same 419 failed targets on base and on this branch. They are the MASM fixtures and the generator-driven targets, which the cross toolchain cannot build. Every runtime DLL and every test this PR adds or touches builds. Tests whose executable did not build are not run here, and CI is their first run. - Full suite, everything that runs here: - Base 6ee878d8 (2441 registered): `578 passed, 1729 failed, 58 skipped (77) of 2365; nocommand 76`. - Nearly all of those failures are the environment: D3D12, DXGI, GPU and dxc are not available under Wine here. - The same runner on this head (2459 registered) is still running. Its counts, and the tests whose result differs from base, will be added here. - The PR's own tests (`^xmem_|^startup_dstorage_break_window|^startup_placed_buffer_range|^startup_translated_sampler_bindings|^startup_local_log`): - On this head, these results come with the full-suite run above. - On the stack before the rebase, whose xmem sources and xmem tests are file-identical to this head, the recorded run gave `48 passed, 39 failed of 87`. Five of the 39 exited 77. - That failure set was the same as before the round commits, and every new test and control passed. - Pure-Python checks, the CI `python-linux` command from `.github/workflows/windows.yml` (Python 3.13, requirements-dev): `all 210 checks passed` on base and on this head (exit 0 both). - Negative controls: every new check has a control that fails, or measures the old behaviour. Mutations of the change, each paired with its check, all fail that check: - drop the slot-adjacency condition, the break around the join, the restore, or the reservation bound; - join without shared views; drop the 64-page cap test; - `break_id = seen | 1`; a break ring of 1, or of 128 (no eviction at 64); - `stable_call` never retries; the `ReadFile`/`WriteFile` wrapper returns 0, or retries with no bound. - Two mutations do not fail under Wine. Wine's `ReadFile` and `VirtualQueryEx` write into an uncommitted mapped slot without faulting, so the lazy-slot cases of the `ReadFile` wrapper and of the `VirtualQueryEx` wrapper are unpinned here. Windows CI is their first real check. Not run here (Windows only, so CI is their first run): - `xmem_page_runs_device_warp`: the edit compiles, but the test was not run. - `linear_buffer_backing_*`: not touched. Whether the joins change their layout is not measured. - Every `_warp`/`_hardware` D3D12 test, `offscreen_*`, `startup_sampler_*`. ### Evidence from a running title Local runs of a console executable under test on Linux under Wine/Proton. Each run had no timeout, and each configuration was run once unless a count is given. Switches: 40 GiB, render, host CPU rewrites, GPU mirror, a fake user, start-up blocks below 2^40, lazy commit and `X2W_XMEM_SHARED_VIEWS=1`. Like for like: the same launcher, environment and arguments, with only the build different. - Main 6ee878d8. Main already honours all three memory switches, but its shared views are the basic version: - Frames: 135 at 5.0 s, 249 at 10.0 s and 331 at 16.5 s, then none. - After 39.8 s with no frame, start-up ended at 56.3 s on the executable's own start-up watchdog. - Main plus this branch, up to its third round commit (`ReadFile`/`WriteFile`): - Frames: 1215 at 50.5 s, 1977 at 92.0 s and 2478 at 169.0 s. - The run reached the menus at about 70 s with no post-load stall. - It ended at 208.5 s on an access violation at the debugger's configured stop address. That is the same class as an earlier split-first-only run, which ended the same way at 636 s. - The same branch build again, started from the main run's exact shader cache. The cache's name-and-size manifest had the same md5 across the copies, with 218001 files and none new during the run. - Frames: 1116 at 50.1 s and 2535 at 167.8 s. - It answered the account prompt at 45.5 s, wrote storage at about 70 s, and ended at the configured stop address at 204.5 s. - The main run had the same environment, cache, storage and driver state. It reached neither the prompt nor the storage write. - So neither the shader cache nor that shared state separates the two builds. - Hypothesis, not tested: on main, a reader faults inside a run break and nothing handles the fault there. - After the menu, the executable showed its own "data file missing or corrupt" dialog. - Every archive it opened returned success at the file layer. The cause is not determined. - Main never gets that far, so the dialog is not shown to be absent on main. - The branch run's log also has 11757 first-chance read AVs inside the D3D12 stand-in. Earlier builds on an older main did not show them. This PR changes no D3D12 code. Hypothesis, not tested: they come from main. Other controls: - Main 6ee878d8 without shared views: no frame was presented, and start-up stopped on the same watchdog. - One run had lazy commit on, and its first stop came at 32.4 s. - The other had lazy memory off, and stopped at 32.3 s. - Older main (52905a32): hang at about 47 s in 2 of 2 runs. - The same groups before the cap (with a local counters-only layer, not in this PR): 2 of 2 runs had no start-up hang (1064 s and 408 s), with 54545 and 54549 joins and 0 lost. - After loading, frames fell to 2.4/s and 0.55/s, against 11.8/s with split-first only. - The cause was breaks of runs thousands of pages long, which is why the cap commit exists. - No run of the final head has been made. The last two round commits (query write-back, cap wording and the ring-edge test) are not in any title run. ### Measured vs not - Measured: the fixture behaviour above under Wine, and the counters and frame counts of the runs listed. - Not measured: - any Windows run of these changes (CI gives the first); - whether the joins change the `linear_buffer_backing` layouts; - how often the executable calls `VirtualQueryEx` (it imports it, but the calls were not counted); - the cause of the data-file dialog. - Known limits: - The `ReadFile`/`WriteFile` retry assumes the failed call had no partial side effect. Only Wine's full failure was measured. - Only the main module's `ReadFile` and `WriteFile` imports are wrapped. Not wrapped: `ReadFileEx`/`WriteFileEx`, scatter/gather, `DeviceIoControl`, sockets, I/O from other modules and I/O through `GetProcAddress`. - Overlapped I/O bypasses the retry. - A genuine fault in a range of a finished break that was since remapped is retried at most once per later break before it is passed on. A range that is broken often can therefore delay a real crash report by one retry per break. - Readers not moved: test-only CPU upload helpers, the opt-in capture path, the pointer-like-qword count heuristic, and `MEM_PRIVATE` heap paths. - Nothing here claims that a title runs or reaches gameplay.
MasterDomino commented 2026-11-26 18:58:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T18:58:57Z.


First Windows run of #2905 at 4a43a173, against its base main 6ee878d8.

Environment: Windows 11 build 26300.9974, AMD Radeon RX 9070 XT, driver 32.0.32029.2010, MSVC 19.44.35221, release preset, D3D12 debug layer not enabled. Clean configure and build.

Fixtures

ctest --preset release --no-tests=error -j 6 -R '^xmem_|^startup_dstorage_break_window|^startup_placed_buffer_range|^startup_translated_sampler_bindings|^startup_local_log|^linear_buffer_backing'

109 tests: 104 passed, 1 skipped (77, xmem_placeholder_split_control, because Windows reports the placeholder bit), 4 failed. All 4 pass on main 6ee878d8 with the same command:

  • xmem_page_runs_device_{warp,hardware}: FAIL across two single-page views: the buffer touches 1 view(s), expected 2.
  • linear_buffer_backing_share_{warp,hardware}: the split case fails with slot 133 -> 0x00000000, copied (share 0x80070032, feature 0x00000000, 131072 bytes in 1 refreshes, staging 1). a2 and b still pass.

Both tests print shared views are on (X2W_XMEM_SHARED_VIEWS). This looks like the join of single-page maps merging views that these tests expect to stay separate. These are the two tests the description listed as not yet run.

Startup runs: back to back, 600 s limit, with the switches the description asks for: -MemoryGiB 40 -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory, X2W_DEVICE_TYPE=6 X2W_PRESENT_COMPOSITE=1 X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_RELEASE_RETIRED_VIEWS=1 X2W_XAPU_TYPED_COMPLETIONS=1 X2W_D3D12_BUDGET=1, -ContinueAsserts 100000 and an input script that answers the prompts. Each arm started from its own copy of the same shader cache.

build -LazyMemory end frames textures uploaded translated draws (not drawn) pipelines translated / missing
this PR 4a43a173 on second-chance write AV in the executable at 288 s 8,049 1,390 231,802 (0) 17 / 0
main 6ee878d8 on same AV, same offset, at 287 s 8,162 1,390 230,751 (0) 17 / 0
main 6ee878d8 off timeout at 420 s 10,147 2,929 375,326 (135,156) 61 / 385

On Windows the crash is not caused by this PR: main crashes at the same executable offset with the same switches. In both crashes the faulting write address is the base of a 0x50000 XMemVirtualAlloc reserve (type=0x20402000 attr=0x21, logged as placeholder reserve). Turning -LazyMemory off on main removes the crash, and the run gets further in less than 1.5 times the time: twice the textures and 61 pipelines instead of 17. Hypothesis, not tested: under lazy commit, a write to that kind of placeholder reserve is not committed by the fault handler. The same run without lazy commit maps it as before. The Windows main control does not show the early stall that the description reports for main under Wine.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7201066358 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2905#issuecomment-7201066358). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T18:58:57Z. --- First Windows run of #2905 at `4a43a173`, against its base `main` `6ee878d8`. **Environment:** Windows 11 build 26300.9974, AMD Radeon RX 9070 XT, driver 32.0.32029.2010, MSVC 19.44.35221, `release` preset, D3D12 debug layer not enabled. Clean configure and build. **Fixtures** ```powershell ctest --preset release --no-tests=error -j 6 -R '^xmem_|^startup_dstorage_break_window|^startup_placed_buffer_range|^startup_translated_sampler_bindings|^startup_local_log|^linear_buffer_backing' ``` 109 tests: 104 passed, 1 skipped (77, `xmem_placeholder_split_control`, because Windows reports the placeholder bit), 4 failed. All 4 pass on `main` `6ee878d8` with the same command: - `xmem_page_runs_device_{warp,hardware}`: `FAIL across two single-page views: the buffer touches 1 view(s), expected 2`. - `linear_buffer_backing_share_{warp,hardware}`: the `split` case fails with `slot 133 -> 0x00000000, copied (share 0x80070032, feature 0x00000000, 131072 bytes in 1 refreshes, staging 1)`. `a2` and `b` still pass. Both tests print `shared views are on (X2W_XMEM_SHARED_VIEWS)`. This looks like the join of single-page maps merging views that these tests expect to stay separate. These are the two tests the description listed as not yet run. **Startup runs:** back to back, 600 s limit, with the switches the description asks for: `-MemoryGiB 40 -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory`, `X2W_DEVICE_TYPE=6 X2W_PRESENT_COMPOSITE=1 X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_RELEASE_RETIRED_VIEWS=1 X2W_XAPU_TYPED_COMPLETIONS=1 X2W_D3D12_BUDGET=1`, `-ContinueAsserts 100000` and an input script that answers the prompts. Each arm started from its own copy of the same shader cache. | build | `-LazyMemory` | end | frames | textures uploaded | translated draws (not drawn) | pipelines translated / missing | |---|---|---|---|---|---|---| | this PR `4a43a173` | on | second-chance write AV in the executable at 288 s | 8,049 | 1,390 | 231,802 (0) | 17 / 0 | | `main` `6ee878d8` | on | same AV, same offset, at 287 s | 8,162 | 1,390 | 230,751 (0) | 17 / 0 | | `main` `6ee878d8` | off | timeout at 420 s | 10,147 | 2,929 | 375,326 (135,156) | 61 / 385 | On Windows the crash is not caused by this PR: `main` crashes at the same executable offset with the same switches. In both crashes the faulting write address is the base of a 0x50000 `XMemVirtualAlloc` reserve (`type=0x20402000 attr=0x21`, logged as `placeholder reserve`). Turning `-LazyMemory` off on `main` removes the crash, and the run gets further in less than 1.5 times the time: twice the textures and 61 pipelines instead of 17. Hypothesis, not tested: under lazy commit, a write to that kind of placeholder reserve is not committed by the fault handler. The same run without lazy commit maps it as before. The Windows main control does not show the early stall that the description reports for `main` under Wine. AI-assisted; the commands above were run locally.
Not-Saii commented 2026-11-26 19:11:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T19:11:23Z.


Tested on Windows: the head 4a43a173, and main 6ee878d8 as the control.

Summary

  • xmem_page_runs_device_warp fails on this head and passes on main on the same machine. In its last case, the buffer placed across the boundary between the single-page maps touches 1 view instead of 2. That is the test the PR lists as not run here.
  • Start-up runs: three on the PR head and two on main.
    • Every run answered the player-selection prompt and entered loading.
    • Every run then stopped at the same instruction with a second-chance write access violation: at 172.0, 177.8 and 204.1 s on the PR head, and at 166.7 and 199.1 s on main. The PR does not cause it.
    • No run hit the start-up watchdog. On this machine, main does not show the stall at 16.5 s seen under Wine.
    • One PR-head run logged no heartbeat for 47.9 s early in start-up. Its repeat did not, and the other PR-head runs' longest gaps were 6.7–10.1 s, against 11.5–12.4 s on main.
    • In every run, the PR head peaked lower than main: title private commit 7.6–8.1 GiB against 11.4–13.0 GiB, and local VRAM 3.6–5.6 GiB against 6.4–7.0 GiB. With 3 and 2 runs, that may still be variance.

Environment

  • Windows 11 Pro build 26300.9974, x64.
  • NVIDIA GeForce RTX 4090, driver 32.0.16.1088.
  • 32 GB RAM; commit limit 48.7 GiB with a system-managed page file.
  • MSVC 19.44, dev preset (a Debug build). Both commits were built the same way, and every run used these builds.
  • D3D12 debug layer off (X2W_D3D12_DEBUG not set).
  • Commits: head 4a43a173, main 6ee878d8, each built in its own worktree.

Build and tests

cmake --preset dev -DINTAKE_PYTHON=<venv>\Scripts\python.exe
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(xmem_|startup_dstorage_break_window|upload_reservation|startup_address_console|startup_list_resubmit)' -E '_hardware$' --output-on-failure
  • The build passed: 3230/3230 targets, no errors.
  • ctest: 70 passed, 1 failed, 1 skipped (77), of 72.
  • Failed: xmem_page_runs_device_warp. It failed 4 of 4 times on this head (the run above, plus --repeat until-pass:3). On main 6ee878d8, built the same way on this machine, it passed. The first three cases pass; the last one fails:
    inside one view: 1 view(s), slot 133 -> 0x00000000, object created, memory unchanged
    across two mapping calls: 2 view(s), slot 133 -> 0x00000000, object created, memory unchanged
    across two backing sections: 2 view(s), slot 133 -> 0x00000000, object created, memory unchanged
    FAIL across two single-page views: the buffer touches 1 view(s), expected 2
    xmem_page_runs_device: 1 FAILED
    
    • So the single pages on either side of that boundary share one view, although the test maps them in reverse slot order so that they would not join.
    • Hypothesis, not tested: on Windows, the slots that XMemAllocatePhysicalPages hands out come in an order that reversing makes consecutive.
  • Skipped (77): xmem_placeholder_split_control, as expected. The OS reports the placeholder bit, and the start-up log agrees: placeholder bit reported=1.
  • Passed, among others:
    • every xmem_run_break_readers* case, including _lazy and _ring_edge;
    • every xmem_cross_call_merge* case;
    • xmem_map_split_first and its _control;
    • xmem_placeholder_split;
    • startup_dstorage_break_window and its _control;
    • xmem_shim_page_runs, xmem_shim_mapped_pages and upload_reservation;
    • the startup_address_console*_warp and startup_list_resubmit*_warp tests.
  • Not run:
    • the 14 _hardware tests that the regex also matches;
    • linear_buffer_backing_*.

Start-up runs

Every run used the same command, with only -BuildDir and -LogDir changed between them.

$env:X2W_DEVICE_TYPE='6'; $env:X2W_PRESENT_COMPOSITE='1'; $env:X2W_D3D12_RELEASE_RETIRED='1'
$env:X2W_D3D12_RELEASE_RETIRED_VIEWS='1'; $env:X2W_XAPU_TYPED_COMPLETIONS='1'; $env:X2W_D3D12_BUDGET='1'
.\tools\startup\run.ps1 -Exe <stage>\<title>.exe -DataDir <package> -LogDir <logs> -BuildDir <repo>\out\build\dev `
    -Seconds 900 -MemoryGiB 40 -ContinueAsserts 1000 -StoragePath <storage> -ShaderCache <cache> `
    -InputScript "base=start,4@85+0.5,4@90+0.5,4@95+0.5,4@100+0.5,4@105+0.5,4@110+0.5,4@115+0.5,4@120+0.5,4@125+0.5,4@130+0.5,4@135+0.5,4@140+0.5" `
    -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory

Deviations from "How to test":

  • -Seconds 900 instead of -Seconds 0, so every run is bounded.
  • -ContinueAsserts 1000. Without it, runs on this machine stop at a soft assert at 130–170 s. None of the runs below logged a continued assert.
  • The input script presses A every 5 s from 85 s to 140 s.
    • The time of the player-selection prompt varies from run to run, and one press at 87 s went unread.
    • The title read between 4 and 10 presses per run. The first answered the prompt; the rest landed on the loading screen.
  • The local storage holds a save state. A at player selection goes straight to the loading screen, so the menus are never shown, and "reaches the menus" cannot be checked here.
  • All runs shared one shader cache. Only the first main run added files (249).

Results.

  • Runs in order: PR head by hand, PR head 1, main 1, PR head 2, main 2.
  • "By hand" is an earlier PR-head run with the same command, except that A was pressed by hand and the commit sampler was not running.
PR head 1 PR head 2 PR head, by hand main 1 main 2
Prompt answered (A read by the title) 124.9 s 94.9 s 87.4 s 95.1 s 105.1 s
End: second-chance write AV, same instruction 177.8 s 172.0 s 204.1 s 199.1 s 166.7 s
Time in loading before the stop 53 s 77 s 117 s 104 s 62 s
Last heartbeat 2467 frames at 165.4 s 3042 at 162.2 s 4472 at 189.3 s 3470 at 181.3 s 2545 at 152.7 s
Lowest and last FPS window (about 25 s each) 1.4 (0–58 s), 29.7 8.3 (108–137 s), 28.8 13.1 (25–53 s), 29.8 9.1 (0–25 s), 14.7 3.3 (0–29 s), 26.3
Longest gap between heartbeats 47.9 s (10.1–58.0 s, 19 frames) 10.1 s 6.7 s 11.5 s 12.4 s (17.0–29.4 s, 1 frame)
Watchdog none none none none none
Storage written during the run no no no player save, at about 183 s no
Textures uploaded 1357 (5.34 GiB) 1364 (5.35 GiB) 1364 (5.35 GiB) 1364 (5.35 GiB) 1358 (5.34 GiB)
Translated draws (not drawn) 6109 (0) 8299 (0) 12726 (0) 12070 (6) 6439 (0)
Pipelines translated / missing 10 / 0 10 / 0 10 / 0 11 / 3 9 / 0
Null bindings 0 0 0 0 0
Upload ring refusals 0 0 0 8 (176–181 s) 0
Out-of-memory, mapping-failure, device-removed lines none none none none none
VRAM peak, local / non-local (GiB) 3.56 / 3.15 5.59 / 3.28 4.03 / 3.26 7.00 / 3.91 6.40 / 2.20
Title private commit peak 8.08 GiB 7.64 GiB not sampled 12.98 GiB 11.42 GiB
System commit peak / limit (GiB) 41.9 / 48.7 41.6 / 48.7 not sampled 45.8 / 49.7 (the page file grew) 41.2 / 48.7
DirectStorage commit peak 8034 MiB 8234 MiB 8243 MiB 13286 MiB 8009 MiB
First-chance AVs in the D3D12 stand-in 2838 5044 7611 13747 7456

"None" in the out-of-memory, mapping-failure and device-removed row means that no line matched, and that no x2w-xmem line reports a non-zero error.

XMem lines

  • On the PR head:
    • Shared views installed their wrappers: 1 VirtualQueryEx import, and 2 ReadFile/WriteFile imports.
    • No run-break or reader-wait line is logged; the PR adds no counter for them.
  • DirectStorage copies under the mapping mutex:
    • The largest copy, 32 MiB, took 12–16 ms.
    • The longest hold was 24.8 ms and 26.5 ms in the two scripted runs and 102.3 ms in the hand-pressed run, for copies of 16 bytes to 450 KiB.
    • In a stopped run (see below), a 16-byte copy held the mutex for 69.7 ms.
    • So most of a long hold is not spent copying. Whether breaks waited on these holds is not measured.
  • main has none of these lines.

The stop. All five runs end at the same instruction in the executable.

  • It is a write fault into a 64 KiB mapped page. When the debugger reports it, that page reads as committed read-write, and the page below it is reserved.
  • main stops the same way, so the PR does not cause it. It may be the same as the stop at the configured address in your Wine runs, but I have not checked that.
  • A PR-head run whose single press went unread stayed at the player-selection prompt at 30 fps until I stopped it at 213 s, with no fault. The stop came only after the prompt was answered.
  • The "data file missing or corrupt" dialog was not reached.

Measured vs not

  • PR head: 3 runs, main: 2. Single differences between the columns, such as main 1's ring refusals and save write, did not repeat.
  • The 47.9 s heartbeat gap was seen in 1 of 3 PR-head runs, and its cause is not determined. That run started about a minute after I force-stopped the run whose press went unread, and its repeat did not show it.
  • The lower commit and VRAM peaks on the PR head held in every run. They are reported, not explained: the runs spent different times in loading before the stop.
  • Not measured: a run with -Seconds 0, a -LazyMemory run that gets past loading, and any _hardware test.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7201291606 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2905#issuecomment-7201291606). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T19:11:23Z. --- Tested on Windows: the head `4a43a173`, and `main` `6ee878d8` as the control. **Summary** - `xmem_page_runs_device_warp` fails on this head and passes on `main` on the same machine. In its last case, the buffer placed across the boundary between the single-page maps touches 1 view instead of 2. That is the test the PR lists as not run here. - Start-up runs: three on the PR head and two on `main`. - Every run answered the player-selection prompt and entered loading. - Every run then stopped at the same instruction with a second-chance write access violation: at 172.0, 177.8 and 204.1 s on the PR head, and at 166.7 and 199.1 s on `main`. The PR does not cause it. - No run hit the start-up watchdog. On this machine, `main` does not show the stall at 16.5 s seen under Wine. - One PR-head run logged no heartbeat for 47.9 s early in start-up. Its repeat did not, and the other PR-head runs' longest gaps were 6.7–10.1 s, against 11.5–12.4 s on `main`. - In every run, the PR head peaked lower than `main`: title private commit 7.6–8.1 GiB against 11.4–13.0 GiB, and local VRAM 3.6–5.6 GiB against 6.4–7.0 GiB. With 3 and 2 runs, that may still be variance. ### Environment - Windows 11 Pro build 26300.9974, x64. - NVIDIA GeForce RTX 4090, driver 32.0.16.1088. - 32 GB RAM; commit limit 48.7 GiB with a system-managed page file. - MSVC 19.44, `dev` preset (a Debug build). Both commits were built the same way, and every run used these builds. - D3D12 debug layer off (`X2W_D3D12_DEBUG` not set). - Commits: head `4a43a173`, `main` `6ee878d8`, each built in its own worktree. ### Build and tests ```powershell cmake --preset dev -DINTAKE_PYTHON=<venv>\Scripts\python.exe cmake --build --preset dev ctest --preset dev --no-tests=error -R '^(xmem_|startup_dstorage_break_window|upload_reservation|startup_address_console|startup_list_resubmit)' -E '_hardware$' --output-on-failure ``` - The build passed: 3230/3230 targets, no errors. - ctest: 70 passed, 1 failed, 1 skipped (77), of 72. - **Failed: `xmem_page_runs_device_warp`.** It failed 4 of 4 times on this head (the run above, plus `--repeat until-pass:3`). On `main` `6ee878d8`, built the same way on this machine, it passed. The first three cases pass; the last one fails: ```text inside one view: 1 view(s), slot 133 -> 0x00000000, object created, memory unchanged across two mapping calls: 2 view(s), slot 133 -> 0x00000000, object created, memory unchanged across two backing sections: 2 view(s), slot 133 -> 0x00000000, object created, memory unchanged FAIL across two single-page views: the buffer touches 1 view(s), expected 2 xmem_page_runs_device: 1 FAILED ``` - So the single pages on either side of that boundary share one view, although the test maps them in reverse slot order so that they would not join. - Hypothesis, not tested: on Windows, the slots that `XMemAllocatePhysicalPages` hands out come in an order that reversing makes consecutive. - **Skipped (77): `xmem_placeholder_split_control`**, as expected. The OS reports the placeholder bit, and the start-up log agrees: `placeholder bit reported=1`. - Passed, among others: - every `xmem_run_break_readers*` case, including `_lazy` and `_ring_edge`; - every `xmem_cross_call_merge*` case; - `xmem_map_split_first` and its `_control`; - `xmem_placeholder_split`; - `startup_dstorage_break_window` and its `_control`; - `xmem_shim_page_runs`, `xmem_shim_mapped_pages` and `upload_reservation`; - the `startup_address_console*_warp` and `startup_list_resubmit*_warp` tests. - Not run: - the 14 `_hardware` tests that the regex also matches; - `linear_buffer_backing_*`. ### Start-up runs Every run used the same command, with only `-BuildDir` and `-LogDir` changed between them. ```powershell $env:X2W_DEVICE_TYPE='6'; $env:X2W_PRESENT_COMPOSITE='1'; $env:X2W_D3D12_RELEASE_RETIRED='1' $env:X2W_D3D12_RELEASE_RETIRED_VIEWS='1'; $env:X2W_XAPU_TYPED_COMPLETIONS='1'; $env:X2W_D3D12_BUDGET='1' .\tools\startup\run.ps1 -Exe <stage>\<title>.exe -DataDir <package> -LogDir <logs> -BuildDir <repo>\out\build\dev ` -Seconds 900 -MemoryGiB 40 -ContinueAsserts 1000 -StoragePath <storage> -ShaderCache <cache> ` -InputScript "base=start,4@85+0.5,4@90+0.5,4@95+0.5,4@100+0.5,4@105+0.5,4@110+0.5,4@115+0.5,4@120+0.5,4@125+0.5,4@130+0.5,4@135+0.5,4@140+0.5" ` -FakeUser -Render -Translate -GpuMirror -HostCpu -StartupBelow40 -LazyMemory ``` **Deviations from "How to test":** - `-Seconds 900` instead of `-Seconds 0`, so every run is bounded. - `-ContinueAsserts 1000`. Without it, runs on this machine stop at a soft assert at 130–170 s. None of the runs below logged a continued assert. - The input script presses A every 5 s from 85 s to 140 s. - The time of the player-selection prompt varies from run to run, and one press at 87 s went unread. - The title read between 4 and 10 presses per run. The first answered the prompt; the rest landed on the loading screen. - The local storage holds a save state. A at player selection goes straight to the loading screen, so the menus are never shown, and "reaches the menus" cannot be checked here. - All runs shared one shader cache. Only the first `main` run added files (249). **Results.** - Runs in order: PR head by hand, PR head 1, `main` 1, PR head 2, `main` 2. - "By hand" is an earlier PR-head run with the same command, except that A was pressed by hand and the commit sampler was not running. | | PR head 1 | PR head 2 | PR head, by hand | `main` 1 | `main` 2 | |---|---|---|---|---|---| | Prompt answered (A read by the title) | 124.9 s | 94.9 s | 87.4 s | 95.1 s | 105.1 s | | End: second-chance write AV, same instruction | 177.8 s | 172.0 s | 204.1 s | 199.1 s | 166.7 s | | Time in loading before the stop | 53 s | 77 s | 117 s | 104 s | 62 s | | Last heartbeat | 2467 frames at 165.4 s | 3042 at 162.2 s | 4472 at 189.3 s | 3470 at 181.3 s | 2545 at 152.7 s | | Lowest and last FPS window (about 25 s each) | 1.4 (0–58 s), 29.7 | 8.3 (108–137 s), 28.8 | 13.1 (25–53 s), 29.8 | 9.1 (0–25 s), 14.7 | 3.3 (0–29 s), 26.3 | | Longest gap between heartbeats | **47.9 s** (10.1–58.0 s, 19 frames) | 10.1 s | 6.7 s | 11.5 s | 12.4 s (17.0–29.4 s, 1 frame) | | Watchdog | none | none | none | none | none | | Storage written during the run | no | no | no | player save, at about 183 s | no | | Textures uploaded | 1357 (5.34 GiB) | 1364 (5.35 GiB) | 1364 (5.35 GiB) | 1364 (5.35 GiB) | 1358 (5.34 GiB) | | Translated draws (not drawn) | 6109 (0) | 8299 (0) | 12726 (0) | 12070 (6) | 6439 (0) | | Pipelines translated / missing | 10 / 0 | 10 / 0 | 10 / 0 | 11 / 3 | 9 / 0 | | Null bindings | 0 | 0 | 0 | 0 | 0 | | Upload ring refusals | 0 | 0 | 0 | 8 (176–181 s) | 0 | | Out-of-memory, mapping-failure, device-removed lines | none | none | none | none | none | | VRAM peak, local / non-local (GiB) | 3.56 / 3.15 | 5.59 / 3.28 | 4.03 / 3.26 | 7.00 / 3.91 | 6.40 / 2.20 | | Title private commit peak | 8.08 GiB | 7.64 GiB | not sampled | 12.98 GiB | 11.42 GiB | | System commit peak / limit (GiB) | 41.9 / 48.7 | 41.6 / 48.7 | not sampled | 45.8 / 49.7 (the page file grew) | 41.2 / 48.7 | | DirectStorage commit peak | 8034 MiB | 8234 MiB | 8243 MiB | 13286 MiB | 8009 MiB | | First-chance AVs in the D3D12 stand-in | 2838 | 5044 | 7611 | 13747 | 7456 | "None" in the out-of-memory, mapping-failure and device-removed row means that no line matched, and that no `x2w-xmem` line reports a non-zero error. **XMem lines** - On the PR head: - Shared views installed their wrappers: 1 `VirtualQueryEx` import, and 2 `ReadFile`/`WriteFile` imports. - No run-break or reader-wait line is logged; the PR adds no counter for them. - DirectStorage copies under the mapping mutex: - The largest copy, 32 MiB, took 12–16 ms. - The longest hold was 24.8 ms and 26.5 ms in the two scripted runs and 102.3 ms in the hand-pressed run, for copies of 16 bytes to 450 KiB. - In a stopped run (see below), a 16-byte copy held the mutex for 69.7 ms. - So most of a long hold is not spent copying. Whether breaks waited on these holds is not measured. - `main` has none of these lines. **The stop.** All five runs end at the same instruction in the executable. - It is a write fault into a 64 KiB mapped page. When the debugger reports it, that page reads as committed read-write, and the page below it is reserved. - `main` stops the same way, so the PR does not cause it. It may be the same as the stop at the configured address in your Wine runs, but I have not checked that. - A PR-head run whose single press went unread stayed at the player-selection prompt at 30 fps until I stopped it at 213 s, with no fault. The stop came only after the prompt was answered. - The "data file missing or corrupt" dialog was not reached. **Measured vs not** - PR head: 3 runs, `main`: 2. Single differences between the columns, such as `main` 1's ring refusals and save write, did not repeat. - The 47.9 s heartbeat gap was seen in 1 of 3 PR-head runs, and its cause is not determined. That run started about a minute after I force-stopped the run whose press went unread, and its repeat did not show it. - The lower commit and VRAM peaks on the PR head held in every run. They are reported, not explained: the runs spent different times in loading before the stop. - Not measured: a run with `-Seconds 0`, a `-LazyMemory` run that gets past loading, and any `_hardware` test. AI-assisted (Claude Code).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2905
No description provided.