xmem: make page runs cheaper under Wine #2911

Merged
JohnConnorNPC merged 35 commits from upstream-pr/2911 into main 2026-11-27 17:03:14 +00:00
JohnConnorNPC commented 2026-11-26 19:23:45 +00:00 (Migrated from github.com)

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


How to test

Fixtures, on Windows with the dev preset:

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)' -V
  • This selects 31 tests in our configure. xmem_page_runs_device_hardware and linear_buffer_backing_share_hardware
    need a physical GPU. The three _warp tests need WARP.
  • xmem_placeholder_split_control, _deployed and _partial skip (77) where the OS reports the placeholder bit.
  • The pr preset now builds these programs and runs 28 of these tests that it did not run before: the five fixture
    families and the three _warp tests. The _hardware tests stay out of it.

Start-up run:

  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. It does not set
      X2W_XMEM_JOIN_CALLS, so joins across mapping calls stay off unless you set it yourself.
    • 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 in the environment.
      run.sh sets X2W_XMEM_SHARED_VIEWS=1 and X2W_XMEM_JOIN_CALLS=1 unless they are already set.
    • 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. In the
      branch runs in Evidence, the menus also appear to have been driven by hand with a controller (see Evidence).
  3. What our Wine runs of an earlier head showed (see Evidence). No start-up run of the final head has been made.
    • The run reached the menus, and the x2w-d3d12 heartbeat: N frames presented count kept rising past about
      170 s. In our like-for-like runs, main stopped presenting at 15-16.5 s and hit the executable's start-up
      watchdog at 52-56 s.
    • Known open item: after the menu, the executable showed its own "data file missing or corrupt" dialog, of
      undetermined cause.
    • On Windows, @pigalot's runs of 4a43a173 with the lazy and shared-views switches on ended in a write access
      violation in the executable, with and without this PR (Evidence). With the switches off, the run with this PR
      reached the 900 s cap.

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. Groups 1 to 3 are the first 17 commits, in commit order. The 17 review commits after
them are listed under "Review changes". Each group below describes the final head and names the review commit that
changed it.

Switches on the final head:

  • Shared views (X2W_XMEM_SHARED_VIEWS=1) gate group 3's reader waits and its import wrappers. run.ps1 -LazyMemory
    sets it.
  • Joins across mapping calls also need X2W_XMEM_JOIN_CALLS=1. run.sh sets it and run.ps1 does not.
  • Without shared views, readers are called once and pages are mapped as on main.
  • Groups 1 and 2, split-first and the fault retries 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.
    • The fallback now checks every region a view covers (1615efc5), and its known limit is in Known limits
      (f9391cca).
  • Test xmem_placeholder_split.
    • Its control, xmem_placeholder_split_control, turns the fallback off in the test-controls build and passes
      only when the split step fails. _deployed sets the same switch for the deployed DLL, which ignores it
      (cb8cc808). _partial was added in 1615efc5. All three skip (77) where the OS reports the bit.
    • Docs: docs/experiments/xmem-page-runs.md and the README row (0cfdd607).

Group 2: DirectStorage copies through xmem.dll (3 commits)

  • xmem: copy DirectStorage destinations under the mapping mutex and 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 run in xmem.dll. Since f19890e4, they run under memory.mutex only when shared
      views are on and the destination or the source overlaps a recorded run. Otherwise, and always with shared views
      off, they run without the mutex.
    • Both paths check resident read-write pages first, as XCRDAPI does without xmem.dll (#2685), and then fall back
      to the region walk.
    • Without xmem.dll, XCRDAPI checks and copies as before.
    • A copy that fails now fails the request. Since 302618bd, XCRDAPI logs the outcome by error code.
  • 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".
    • _plain, _views_off (f19890e4) and _outcomes (302618bd) are described under Review changes.

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, test-controls build since cb8cc808), 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, only when it failed with ERROR_NOACCESS or
      ERROR_INVALID_USER_BUFFER, a break overlapped it, its buffer lies in a run and, since 4f7d47de, the
      handle is a disk file.
    • 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 fixed 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 added a 64-break history.
    c8391709 replaces both mechanisms. Each run now keeps the id of the break inside which it was mapped, and
    the handler retries a fault on such a page once per break and thread, however many breaks follow on other runs.

Joins:

  • xmem: join a page mapped on its own call to the view before it. Since d4f1344e this needs
    X2W_XMEM_JOIN_CALLS=1 as well as shared views.
    • 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.
    • Without the join switch, every call keeps its own view, as on main.
  • 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.
    • 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.
    • Its ring-edge test became xmem_run_break_readers_stamps in c8391709.

Tests and changed expectations:

  • xmem_run_break_readers, with _control, _next_break_control, _default, _lazy, _two_runs, _mirror
    and _stamps.
    • 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. A pipe ReadFile must fail inside the
      window without being run again.
    • 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), _default (no shared views) and _no_join (shared views without the
    join switch: one view per call). Its capped case covers the 64-page cap.
  • Changed expectations (no check is weakened):
    • xmem_page_runs_check.py is main's again (three views), because joins are off by default.
    • xmem_page_runs_device_check. ad1980cb (#2918's f6020249, same patch-id) maps the single pages from high
      to low addresses. d4f1344e maps the upper 8-page call first. No call then has a view that ends at its
      address, so with the join switch every call still keeps its own view. New xmem_page_runs_device_join_warp
      runs it with X2W_XMEM_JOIN_CALLS=1. The earlier description said this test's view boundaries were the same
      as before. That was wrong at 4a43a173, as @Not-Saii's Windows run showed.
    • linear_buffer_backing_check. 238ed78a (#2918's 27778f4f, same patch-id) maps the upper page of the
      split buffer first. The fixture also clears the join switch.

Review changes (17 commits)

These answer @Not-Saii's review of 4a43a173 and our own audit, in commit order:

  • ad1980cb, 238ed78a: the two fixture fixes above.
  • 14a9589f: the page-run test registrations move verbatim to tests/cmake/xmem_page_runs.cmake.
    CMakeLists.txt is main's again.
  • e9e0b441: the slab accounting comment is back above x2w_xmem_slab_stats, and the fixture comments no longer
    point at notes outside the repository.
  • d4f1344e: joins across mapping calls need X2W_XMEM_JOIN_CALLS=1 (review point 3).
    • New xmem_cross_call_merge_no_join and xmem_page_runs_device_join_warp.
    • Every mode of the branch's fixtures sets or clears the switch itself.
  • cb8cc808: X2W_XMEM_TEST_MAP_FIRST and X2W_XMEM_TEST_NO_PLACEHOLDER_FALLBACK are read only in the
    test-controls build. The deployed xmem.dll contains neither name. New _deployed rows.
  • 1615efc5: the placeholder fallback checks every region a view covers, not only the first of each allocation
    (review point 4).
    • New xmem_placeholder_split_partial.
    • Under Wine with the old walk, the batch succeeded and the view replaced the committed page (byte 0x53
      instead of the 0x7a tag). With the new walk it is refused and the page keeps its tag.
  • c8391709: each run carries the break that mapped it, which replaces the 64-break history (review point 2).
    • xmem_run_break_readers_stamps: a fault held through 63, 64 and 200 later breaks is retried each time (under
      Wine the later breaks took 3, 4 and 10 ms).
    • A page made no-access faults once where no break mapped it, and twice after a break did.
    • A fault that cannot be the transient one is passed on without taking the mutex.
  • 4f7d47de: the ReadFile/WriteFile retry applies to disk files only.
    • New window case ReadFile_pipe. Under Wine the pipe read fails with ERROR_NOACCESS and both messages stay
      queued.
  • f19890e4: a DirectStorage copy takes the mapping mutex only when it touches a run, and checks resident pages
    first (review point 1).
    • New x2w_xmem_copy_counts export, test-controls build only.
    • New startup_dstorage_break_window_plain: a VirtualAlloc destination copies without the mutex, and a run
      destination copies with it.
    • New startup_dstorage_break_window_views_off: with shared views off, an XMem page destination copies without
      the mutex.
  • 302618bd: XCRDAPI logs each copy outcome by its error code: "destination not writable", "copy faulted (part of
    the destination may be written)", "invalid copy request", or "copy failed (error N)".
    • New startup_dstorage_break_window_outcomes, which uses the test-controls build's X2W_XMEM_TEST_COPY_ERROR.
  • 0cfdd607: the note moves to docs/experiments/xmem-page-runs.md, and docs/experiments.md is main's again.
    • The pr preset builds the fixture programs and runs 28 of these tests that it did not run before.
    • startup_run_sh stays out of it: it skips on Windows, and the Linux Python job runs its check.
  • Round 1 of our audit:
    • f9391cca: states the placeholder fallback's limit (Known limits).
    • f4cc2900: says which half of the pipe retry reason is measured.
    • 863c0459, bf9e448f: comments only.
    • 0c6be971: README link layout.

Switches

Change Active when
Slot 31 placeholder fallback the OS hides the placeholder bit (probed at first use)
Split-first map, fault retries always
DirectStorage check and copy in xmem.dll when XCRDAPI finds xmem.dll's export; under the mapping mutex only with shared views on and a range that overlaps a run
stable_call waits, the VirtualQueryEx/ReadFile/WriteFile wrappers X2W_XMEM_SHARED_VIEWS=1 (run.ps1 -LazyMemory and run.sh set it)
Joins across mapping calls and their 64-page cap X2W_XMEM_SHARED_VIEWS=1 and X2W_XMEM_JOIN_CALLS=1 (run.sh sets it, run.ps1 does not)
X2W_XMEM_TEST_* (MAP_FIRST, NO_MERGE, MERGE_CAP, HOLD_WINDOW, HOLD_RETRY, FAULT, NO_PLACEHOLDER_FALLBACK, COPY_ERROR) test-controls build only. The deployed xmem.dll has no X2W_XMEM_TEST_ string.

Test

Host: Linux, cross-built with clang-cl 19 and xwin. Tests ran under Proton Experimental (wine-11.0) with a runner
that applies each test's ctest properties.

Check Base 6ee878d8 Earlier head 4a43a173 Final head 0c6be971
Every test that runs on this host, first runner and prefix: passed / failed / skipped (77) 578 / 1729 / 58 of 2365 596 / 1729 / 58 of 2383 not run
The same, fixed runner and second prefix not run not run 614 / 1668 / 109 of 2391
Pure-Python checks (the CI python-linux command) all 210 pass all 210 pass all 210 pass
  • The final head was run with a fixed runner in a second prefix.
    • The runner counts a test that cannot start (exit 53 or 126) as not started, whatever WILL_FAIL says. There
      were 0 such tests.
    • In the second prefix, tests that import d3d12.dll start.
    • Base was not run that way, so the final head has no like-for-like base count.
  • By row against the 4a43a173 run, 79 rows changed:
    • 51 moved to a skip (77). These are D3D12 tests that now start and skip without WARP. The first runner counted
      3 of them (unified_buffer_paths_*_control) as passes.
    • 16 rows went from fail to pass.
      • 13 of them could not start or could not load a DLL in the first prefix (exit 53 or 126, or a missing DLL).
      • compute_heap_view_controls failed there with a Wine client error. It was the earlier description's flake.
      • startup_storage_directory_batch failed there with an AssertionError, which was not investigated.
      • The last one is startup_local_log_reopen_control (below).
    • 8 rows are new and pass. xmem_page_runs_device_join_warp is new and fails: there is no WARP here.
      _ring_edge became _stamps.
    • 2 rows went from pass to fail:
      • xmem_startup_below_40_mutant_no_limit timed out (60 s) in the full run and passes alone.
      • xmem_lazy_commit_off is unmeasured under Wine. Its commit-charge reading moves with host load, and it
        already failed at 238ed78a, before any review commit. Its earlier passes are not results.
    • startup_local_log_reopen_control passed once in the full run. It fails alone and in every other run (base,
      4a43a173, the review head), so the pass is not a change.
  • Build scope: ninja -k 0 ends with the same 419 failed targets on base and on this head: the MASM fixtures and
    the generator-driven targets, which the cross toolchain cannot build. Those tests did not run here.
  • A pass supports only the behaviour that test checks. It does not show that anything starts up.
  • Negative controls and mutations:
    • Every new check has a control that fails, or measures the old behaviour.
    • Each review commit's mutations were run once on the final tree under Wine. Each one fails its paired check:
      • join switch forced on (_no_join, xmem_shim_page_runs);
      • no join switch in the merge fixture (xmem_cross_call_merge), and the run.sh check's "no join calls" mutant;
      • either test switch read in the deployed build (_deployed);
      • placeholder walk of the first region only (_partial);
      • rollback unmap without MEM_PRESERVE_PLACEHOLDER (_partial);
      • stamp honoured only within 64 breaks (later_breaks_64/_200);
      • stamp ignored (persistent_fault);
      • pre-check without its mapped-view test (xmem_run_break_readers, _stamps);
      • retry on any handle type (ReadFile_pipe);
      • DirectStorage copy always under the mutex (_plain, _views_off), and run lookup without the shared-views
        gate (_views_off);
      • the old two-way outcome text (_outcomes).
    • The first 17 commits' mutations each failed their check at 4a43a173:
      • drop the slot-adjacency condition, the break around the join, the restore or the reservation bound;
      • join without shared views, or drop the 64-page cap test;
      • stable_call never retries;
      • the ReadFile/WriteFile wrapper returns 0, or retries with no bound.
        They were not run again on the final head. The ring mutations no longer apply, because the ring is gone.
  • Not pinned by any mutation here:
    • The new AllocationBase/RegionSize clauses of xmem_placeholder_split_partial. The unmap mutation fails
      that check, but it also changes the page state. No mutation was found that changes only the base or the size.
    • The lock skip in the c8391709 pre-check, which is a performance change only.
    • The lazy-slot cases of the ReadFile and VirtualQueryEx wrappers. Wine writes into an uncommitted mapped slot
      without faulting, so their mutations do not fail here. They are unmeasured on Windows as well.

Windows CI on this head:

  • The Build and test on Windows job ran the pr preset on 0c6be971 (run 45921712354, image
    windows-2025-vs2026). It ran 68 tests, and all of them passed.
    • Of the 28 page-run tests, 25 passed and 3 skipped (77): xmem_placeholder_split_control, _deployed and
      _partial, because Windows reports the placeholder bit.
    • The 25 include xmem_page_runs_device_warp, xmem_page_runs_device_join_warp and
      linear_buffer_backing_share_warp.
  • Those three need WARP and fail under Wine here ("WARP device not created"). CI is their only result on this head.
  • The _hardware variants have no result on this head. #2918 reported f6020249 passing on WARP and on a GTX 1080 Ti.

Evidence from a running title

Local runs of a console executable under test on Linux under Wine/Proton. These runs are of the branch up to its
third round commit (ReadFile/WriteFile), not of the final head. 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. Joins were on, because that branch had no
join switch.

Like for like: the same launcher, environment and arguments, with only the build different. Main already
honours all three memory switches, but its shared views are the basic version.

Build Runs Frames presented until First archive that loading opens after the menus (after apparent hand input; see below) Start-up watchdog fired at
Main 6ee878d8 2 15.1 and 16.5 s never opened 52.2 and 56.3 s
Main + groups 1 and 2 + split-first (no readers, no joins) 1 15.1 s never opened 53.5 s
Branch 2 167.8 and 169.0 s 69.8 and 71.5 s 204.5 and 208.5 s
Branch with the ReadFile/WriteFile retry turned off 1 173.5 s 79.3 s 213.8 s
Branch + the local menu-skipping change 1 242.6 s 53.3 s 282.4 s
  • "Frames presented until" is the last frame heartbeat. Main and the split-first build stop presenting at about
    15 s, and no frame follows in the 37-40 s before the watchdog fires.
  • Every run above ends at the same start-up watchdog, on the same thread stack. The branch builds keep
    presenting until 168-243 s before it fires. What the watchdog waits for in the branch runs is not determined.
  • In the branch run watched on screen, the menus appeared at about 70 s. The input script pressed A once, at about 50 s.
    The branch runs' menus appear to have been driven by hand as well: each run read an A 12-21 s before the script's,
    the runs without the menu-skipping change read 4-6 direction-pad presses before loading began, and a controller is
    visible to the executable. So the archive times likely show when someone picked a menu item, not how fast start-up
    ran, and they are not comparable between rows. Main never reached a point that reads input.
  • The local menu-skipping change is a runtime-proxy change that is not in this PR. With it, a run reads a save
    and skips the menus:
    • One of the two main runs had it. It did not get main past the stop: presents stopped at 15.1 s and the
      watchdog fired at 52.2 s.
  • One branch run started from the main run's exact shader cache, with the same name-and-size manifest and no new
    file during the run. It behaved like the other branch run, and main had the same environment, storage and
    driver state. 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.
  • Open item: in the branch run watched on screen, the executable showed its own "data file missing or corrupt"
    dialog after the menu.
    • Every archive it opened returned success at the file layer. The cause is undetermined.
    • Main never gets that far, so it is not shown that main would avoid the dialog.
  • The first 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.

Windows runs by reviewers. These are the first Windows measurements of this work, and all of them are of earlier
heads:

  • @Not-Saii, fixtures at 4a43a173.
    • Setup: Windows 11 build 26300.9974, dev preset (Debug). WARP and an RTX 4090 (driver 32.0.16.1088), with
      the debug layer off.
    • 46 tests: 43 passed, 2 failed and 1 skipped (77). 9 _hardware tests: 7 passed and 2 failed.
    • The failures were xmem_page_runs_device and linear_buffer_backing_share, in both variants. All of them pass
      at 6ee878d8. ad1980cb and 238ed78a address them.
    • On this head, the _warp variants pass in CI (Test). The _hardware variants have not been run.
  • @pigalot, start-up at 4a43a173, Windows 11 with the D3D12 hardware backend, 900 s cap.
    • Lazy and shared-views switches on: a second-chance write access violation in the executable at 191.7 s
      (4706 frames). Main without this PR, same switches: the same kind of fault at 250.0 s (5410 frames), at a
      different address.
    • Switches off: the run reached the 900 s cap, with 16381 frames and no fault.
    • DirectStorage: each run had the same single failure, "destination capacity exceeded".
  • @MasterDomino, start-up with lazy memory off.
    • Setup: two matched pairs of 420 s runs on Windows 11 build 26300.9974, an RX 9070 XT (driver 32.0.32029.2010),
      release, debug layer off. Builds: #2918's head 27778f4f, which carries the same change as this PR at
      238ed78a, against cpp-migration 40365770.
    • All four runs ended on the timeout. Frames, storage requests, textures, pipelines and exceptions matched within
      noise.
    • Token null bindings were about 1.6 times the base in both pairs, which he marked as a hint, not a result.
    • With shared views off, f19890e4 takes no mutex and no run lookup for a DirectStorage copy, which is the path
      he named. That has not been measured.

Measured vs not

  • Measured:
    • the fixture behaviour above under Wine;
    • the counters and frame counts of the runs listed;
    • the reviewers' Windows runs of earlier heads;
    • CI's pr preset run of the final head.
  • Not measured:
    • any Windows run of the final head outside CI's pr preset, including the _hardware variants;
    • any start-up run of the final head;
    • whether xmem_lazy_commit_off passes on this head under Wine. Host noise decides it here;
    • whether f19890e4 changes the token null count in lazy-off runs;
    • how often the executable calls VirtualQueryEx (it imports it, but the calls were not counted);
    • what the start-up watchdog waits for in the branch runs;
    • the cause of the data-file dialog.
  • Known limits:
    • Placeholder fallback (Wine only).
      • It cannot tell a reserved page of a private allocation made with VirtualAlloc2(MEM_REPLACE_PLACEHOLDER)
        from a placeholder, because Wine does not refuse the release for that kind of allocation.
      • After a refused view, the batch retries each page on its own. That cut such a page out of the caller's
        allocation: the committed page's allocation then started one page later.
      • Where the OS reports the placeholder bit, the fallback is not used.
    • ReadFile/WriteFile retry.
      • It assumes that the failed call had no partial side effect. Only Wine's full failure was measured.
      • On a pipe, Wine keeps the data queued. Whether Windows consumes it is unmeasured, which is why only disk
        files are retried.
      • 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 on a page whose run a break mapped is retried once per thread before it is passed on, and again
      after each later break that maps the page again.
  • 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:5515947319 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-26T19:23:45Z. --- ### How to test Fixtures, on Windows with the `dev` preset: ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)' -V ``` - This selects 31 tests in our configure. `xmem_page_runs_device_hardware` and `linear_buffer_backing_share_hardware` need a physical GPU. The three `_warp` tests need WARP. - `xmem_placeholder_split_control`, `_deployed` and `_partial` skip (77) where the OS reports the placeholder bit. - The `pr` preset now builds these programs and runs 28 of these tests that it did not run before: the five fixture families and the three `_warp` tests. The `_hardware` tests stay out of it. Start-up run: 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`. It does not set `X2W_XMEM_JOIN_CALLS`, so joins across mapping calls stay off unless you set it yourself. - 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` in the environment. `run.sh` sets `X2W_XMEM_SHARED_VIEWS=1` and `X2W_XMEM_JOIN_CALLS=1` unless they are already set. - 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. In the branch runs in Evidence, the menus also appear to have been driven by hand with a controller (see Evidence). 3. What our Wine runs of an earlier head showed (see Evidence). No start-up run of the final head has been made. - The run reached the menus, and the `x2w-d3d12 heartbeat: N frames presented` count kept rising past about 170 s. In our like-for-like runs, main stopped presenting at 15-16.5 s and hit the executable's start-up watchdog at 52-56 s. - Known open item: after the menu, the executable showed its own "data file missing or corrupt" dialog, of undetermined cause. - On Windows, @pigalot's runs of `4a43a173` with the lazy and shared-views switches on ended in a write access violation in the executable, with and without this PR (Evidence). With the switches off, the run with this PR reached the 900 s cap. 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. Groups 1 to 3 are the first 17 commits, in commit order. The 17 review commits after them are listed under "Review changes". Each group below describes the final head and names the review commit that changed it. Switches on the final head: - Shared views (`X2W_XMEM_SHARED_VIEWS=1`) gate group 3's reader waits and its import wrappers. `run.ps1 -LazyMemory` sets it. - Joins across mapping calls also need `X2W_XMEM_JOIN_CALLS=1`. `run.sh` sets it and `run.ps1` does not. - Without shared views, readers are called once and pages are mapped as on main. - Groups 1 and 2, split-first and the fault retries 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. - The fallback now checks every region a view covers (`1615efc5`), and its known limit is in Known limits (`f9391cca`). - Test `xmem_placeholder_split`. - Its control, `xmem_placeholder_split_control`, turns the fallback off in the test-controls build and passes only when the split step fails. `_deployed` sets the same switch for the deployed DLL, which ignores it (`cb8cc808`). `_partial` was added in `1615efc5`. All three skip (77) where the OS reports the bit. - Docs: `docs/experiments/xmem-page-runs.md` and the README row (`0cfdd607`). ### Group 2: DirectStorage copies through xmem.dll (3 commits) - `xmem: copy DirectStorage destinations under the mapping mutex` and `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 run in xmem.dll. Since `f19890e4`, they run under `memory.mutex` only when shared views are on and the destination or the source overlaps a recorded run. Otherwise, and always with shared views off, they run without the mutex. - Both paths check resident read-write pages first, as XCRDAPI does without xmem.dll (#2685), and then fall back to the region walk. - Without xmem.dll, XCRDAPI checks and copies as before. - A copy that fails now fails the request. Since `302618bd`, XCRDAPI logs the outcome by error code. - 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". - `_plain`, `_views_off` (`f19890e4`) and `_outcomes` (`302618bd`) are described under Review changes. ### 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`, test-controls build since `cb8cc808`), 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, only when it failed with `ERROR_NOACCESS` or `ERROR_INVALID_USER_BUFFER`, a break overlapped it, its buffer lies in a run and, since `4f7d47de`, the handle is a disk file. - 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` fixed 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` added a 64-break history. `c8391709` replaces both mechanisms. Each run now keeps the id of the break inside which it was mapped, and the handler retries a fault on such a page once per break and thread, however many breaks follow on other runs. Joins: - `xmem: join a page mapped on its own call to the view before it`. Since `d4f1344e` this needs `X2W_XMEM_JOIN_CALLS=1` as well as shared views. - 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. - Without the join switch, every call keeps its own view, as on main. - `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`. - 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. - Its ring-edge test became `xmem_run_break_readers_stamps` in `c8391709`. Tests and changed expectations: - `xmem_run_break_readers`, with `_control`, `_next_break_control`, `_default`, `_lazy`, `_two_runs`, `_mirror` and `_stamps`. - 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. A pipe `ReadFile` must fail inside the window without being run again. - 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), `_default` (no shared views) and `_no_join` (shared views without the join switch: one view per call). Its `capped` case covers the 64-page cap. - Changed expectations (no check is weakened): - `xmem_page_runs_check.py` is main's again (three views), because joins are off by default. - `xmem_page_runs_device_check`. `ad1980cb` (#2918's `f6020249`, same patch-id) maps the single pages from high to low addresses. `d4f1344e` maps the upper 8-page call first. No call then has a view that ends at its address, so with the join switch every call still keeps its own view. New `xmem_page_runs_device_join_warp` runs it with `X2W_XMEM_JOIN_CALLS=1`. The earlier description said this test's view boundaries were the same as before. That was wrong at `4a43a173`, as @Not-Saii's Windows run showed. - `linear_buffer_backing_check`. `238ed78a` (#2918's `27778f4f`, same patch-id) maps the upper page of the `split` buffer first. The fixture also clears the join switch. ### Review changes (17 commits) These answer @Not-Saii's review of `4a43a173` and our own audit, in commit order: - `ad1980cb`, `238ed78a`: the two fixture fixes above. - `14a9589f`: the page-run test registrations move verbatim to `tests/cmake/xmem_page_runs.cmake`. `CMakeLists.txt` is main's again. - `e9e0b441`: the slab accounting comment is back above `x2w_xmem_slab_stats`, and the fixture comments no longer point at notes outside the repository. - `d4f1344e`: joins across mapping calls need `X2W_XMEM_JOIN_CALLS=1` (review point 3). - New `xmem_cross_call_merge_no_join` and `xmem_page_runs_device_join_warp`. - Every mode of the branch's fixtures sets or clears the switch itself. - `cb8cc808`: `X2W_XMEM_TEST_MAP_FIRST` and `X2W_XMEM_TEST_NO_PLACEHOLDER_FALLBACK` are read only in the test-controls build. The deployed xmem.dll contains neither name. New `_deployed` rows. - `1615efc5`: the placeholder fallback checks every region a view covers, not only the first of each allocation (review point 4). - New `xmem_placeholder_split_partial`. - Under Wine with the old walk, the batch succeeded and the view replaced the committed page (byte `0x53` instead of the `0x7a` tag). With the new walk it is refused and the page keeps its tag. - `c8391709`: each run carries the break that mapped it, which replaces the 64-break history (review point 2). - `xmem_run_break_readers_stamps`: a fault held through 63, 64 and 200 later breaks is retried each time (under Wine the later breaks took 3, 4 and 10 ms). - A page made no-access faults once where no break mapped it, and twice after a break did. - A fault that cannot be the transient one is passed on without taking the mutex. - `4f7d47de`: the `ReadFile`/`WriteFile` retry applies to disk files only. - New window case `ReadFile_pipe`. Under Wine the pipe read fails with `ERROR_NOACCESS` and both messages stay queued. - `f19890e4`: a DirectStorage copy takes the mapping mutex only when it touches a run, and checks resident pages first (review point 1). - New `x2w_xmem_copy_counts` export, test-controls build only. - New `startup_dstorage_break_window_plain`: a `VirtualAlloc` destination copies without the mutex, and a run destination copies with it. - New `startup_dstorage_break_window_views_off`: with shared views off, an XMem page destination copies without the mutex. - `302618bd`: XCRDAPI logs each copy outcome by its error code: "destination not writable", "copy faulted (part of the destination may be written)", "invalid copy request", or "copy failed (error N)". - New `startup_dstorage_break_window_outcomes`, which uses the test-controls build's `X2W_XMEM_TEST_COPY_ERROR`. - `0cfdd607`: the note moves to `docs/experiments/xmem-page-runs.md`, and `docs/experiments.md` is main's again. - The `pr` preset builds the fixture programs and runs 28 of these tests that it did not run before. - `startup_run_sh` stays out of it: it skips on Windows, and the Linux Python job runs its check. - Round 1 of our audit: - `f9391cca`: states the placeholder fallback's limit (Known limits). - `f4cc2900`: says which half of the pipe retry reason is measured. - `863c0459`, `bf9e448f`: comments only. - `0c6be971`: README link layout. ### Switches | Change | Active when | |---|---| | Slot 31 placeholder fallback | the OS hides the placeholder bit (probed at first use) | | Split-first map, fault retries | always | | DirectStorage check and copy in xmem.dll | when XCRDAPI finds xmem.dll's export; under the mapping mutex only with shared views on and a range that overlaps a run | | `stable_call` waits, the `VirtualQueryEx`/`ReadFile`/`WriteFile` wrappers | `X2W_XMEM_SHARED_VIEWS=1` (`run.ps1 -LazyMemory` and `run.sh` set it) | | Joins across mapping calls and their 64-page cap | `X2W_XMEM_SHARED_VIEWS=1` and `X2W_XMEM_JOIN_CALLS=1` (`run.sh` sets it, `run.ps1` does not) | | `X2W_XMEM_TEST_*` (MAP_FIRST, NO_MERGE, MERGE_CAP, HOLD_WINDOW, HOLD_RETRY, FAULT, NO_PLACEHOLDER_FALLBACK, COPY_ERROR) | test-controls build only. The deployed xmem.dll has no `X2W_XMEM_TEST_` string. | ### Test Host: Linux, cross-built with clang-cl 19 and xwin. Tests ran under Proton Experimental (wine-11.0) with a runner that applies each test's ctest properties. | Check | Base 6ee878d8 | Earlier head 4a43a173 | Final head 0c6be971 | |---|---|---|---| | Every test that runs on this host, first runner and prefix: passed / failed / skipped (77) | 578 / 1729 / 58 of 2365 | 596 / 1729 / 58 of 2383 | not run | | The same, fixed runner and second prefix | not run | not run | 614 / 1668 / 109 of 2391 | | Pure-Python checks (the CI `python-linux` command) | all 210 pass | all 210 pass | all 210 pass | - The final head was run with a fixed runner in a second prefix. - The runner counts a test that cannot start (exit 53 or 126) as not started, whatever `WILL_FAIL` says. There were 0 such tests. - In the second prefix, tests that import `d3d12.dll` start. - Base was not run that way, so the final head has no like-for-like base count. - By row against the `4a43a173` run, 79 rows changed: - 51 moved to a skip (77). These are D3D12 tests that now start and skip without WARP. The first runner counted 3 of them (`unified_buffer_paths_*_control`) as passes. - 16 rows went from fail to pass. - 13 of them could not start or could not load a DLL in the first prefix (exit 53 or 126, or a missing DLL). - `compute_heap_view_controls` failed there with a Wine client error. It was the earlier description's flake. - `startup_storage_directory_batch` failed there with an `AssertionError`, which was not investigated. - The last one is `startup_local_log_reopen_control` (below). - 8 rows are new and pass. `xmem_page_runs_device_join_warp` is new and fails: there is no WARP here. `_ring_edge` became `_stamps`. - 2 rows went from pass to fail: - `xmem_startup_below_40_mutant_no_limit` timed out (60 s) in the full run and passes alone. - `xmem_lazy_commit_off` is unmeasured under Wine. Its commit-charge reading moves with host load, and it already failed at `238ed78a`, before any review commit. Its earlier passes are not results. - `startup_local_log_reopen_control` passed once in the full run. It fails alone and in every other run (base, `4a43a173`, the review head), so the pass is not a change. - Build scope: `ninja -k 0` ends with the same 419 failed targets on base and on this head: the MASM fixtures and the generator-driven targets, which the cross toolchain cannot build. Those tests did not run here. - A pass supports only the behaviour that test checks. It does not show that anything starts up. - Negative controls and mutations: - Every new check has a control that fails, or measures the old behaviour. - Each review commit's mutations were run once on the final tree under Wine. Each one fails its paired check: - join switch forced on (`_no_join`, `xmem_shim_page_runs`); - no join switch in the merge fixture (`xmem_cross_call_merge`), and the `run.sh` check's "no join calls" mutant; - either test switch read in the deployed build (`_deployed`); - placeholder walk of the first region only (`_partial`); - rollback unmap without `MEM_PRESERVE_PLACEHOLDER` (`_partial`); - stamp honoured only within 64 breaks (`later_breaks_64`/`_200`); - stamp ignored (`persistent_fault`); - pre-check without its mapped-view test (`xmem_run_break_readers`, `_stamps`); - retry on any handle type (`ReadFile_pipe`); - DirectStorage copy always under the mutex (`_plain`, `_views_off`), and run lookup without the shared-views gate (`_views_off`); - the old two-way outcome text (`_outcomes`). - The first 17 commits' mutations each failed their check at `4a43a173`: - drop the slot-adjacency condition, the break around the join, the restore or the reservation bound; - join without shared views, or drop the 64-page cap test; - `stable_call` never retries; - the `ReadFile`/`WriteFile` wrapper returns 0, or retries with no bound. They were not run again on the final head. The ring mutations no longer apply, because the ring is gone. - Not pinned by any mutation here: - The new `AllocationBase`/`RegionSize` clauses of `xmem_placeholder_split_partial`. The unmap mutation fails that check, but it also changes the page state. No mutation was found that changes only the base or the size. - The lock skip in the `c8391709` pre-check, which is a performance change only. - The lazy-slot cases of the `ReadFile` and `VirtualQueryEx` wrappers. Wine writes into an uncommitted mapped slot without faulting, so their mutations do not fail here. They are unmeasured on Windows as well. Windows CI on this head: - The `Build and test on Windows` job ran the `pr` preset on `0c6be971` (run 45921712354, image `windows-2025-vs2026`). It ran 68 tests, and all of them passed. - Of the 28 page-run tests, 25 passed and 3 skipped (77): `xmem_placeholder_split_control`, `_deployed` and `_partial`, because Windows reports the placeholder bit. - The 25 include `xmem_page_runs_device_warp`, `xmem_page_runs_device_join_warp` and `linear_buffer_backing_share_warp`. - Those three need WARP and fail under Wine here ("WARP device not created"). CI is their only result on this head. - The `_hardware` variants have no result on this head. #2918 reported `f6020249` passing on WARP and on a GTX 1080 Ti. ### Evidence from a running title Local runs of a console executable under test on Linux under Wine/Proton. These runs are of the branch up to its third round commit (`ReadFile`/`WriteFile`), not of the final head. 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`. Joins were on, because that branch had no join switch. Like for like: the same launcher, environment and arguments, with only the build different. Main already honours all three memory switches, but its shared views are the basic version. | Build | Runs | Frames presented until | First archive that loading opens after the menus (after apparent hand input; see below) | Start-up watchdog fired at | |---|---|---|---|---| | Main 6ee878d8 | 2 | 15.1 and 16.5 s | never opened | 52.2 and 56.3 s | | Main + groups 1 and 2 + split-first (no readers, no joins) | 1 | 15.1 s | never opened | 53.5 s | | Branch | 2 | 167.8 and 169.0 s | 69.8 and 71.5 s | 204.5 and 208.5 s | | Branch with the `ReadFile`/`WriteFile` retry turned off | 1 | 173.5 s | 79.3 s | 213.8 s | | Branch + the local menu-skipping change | 1 | 242.6 s | 53.3 s | 282.4 s | - "Frames presented until" is the last frame heartbeat. Main and the split-first build stop presenting at about 15 s, and no frame follows in the 37-40 s before the watchdog fires. - Every run above ends at the same start-up watchdog, on the same thread stack. The branch builds keep presenting until 168-243 s before it fires. What the watchdog waits for in the branch runs is not determined. - In the branch run watched on screen, the menus appeared at about 70 s. The input script pressed A once, at about 50 s. The branch runs' menus appear to have been driven by hand as well: each run read an A 12-21 s before the script's, the runs without the menu-skipping change read 4-6 direction-pad presses before loading began, and a controller is visible to the executable. So the archive times likely show when someone picked a menu item, not how fast start-up ran, and they are not comparable between rows. Main never reached a point that reads input. - The local menu-skipping change is a runtime-proxy change that is not in this PR. With it, a run reads a save and skips the menus: - One of the two main runs had it. It did not get main past the stop: presents stopped at 15.1 s and the watchdog fired at 52.2 s. - One branch run started from the main run's exact shader cache, with the same name-and-size manifest and no new file during the run. It behaved like the other branch run, and main had the same environment, storage and driver state. 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. - Open item: in the branch run watched on screen, the executable showed its own "data file missing or corrupt" dialog after the menu. - Every archive it opened returned success at the file layer. The cause is undetermined. - Main never gets that far, so it is not shown that main would avoid the dialog. - The first 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. Windows runs by reviewers. These are the first Windows measurements of this work, and all of them are of earlier heads: - @Not-Saii, fixtures at `4a43a173`. - Setup: Windows 11 build 26300.9974, `dev` preset (Debug). WARP and an RTX 4090 (driver 32.0.16.1088), with the debug layer off. - 46 tests: 43 passed, 2 failed and 1 skipped (77). 9 `_hardware` tests: 7 passed and 2 failed. - The failures were `xmem_page_runs_device` and `linear_buffer_backing_share`, in both variants. All of them pass at `6ee878d8`. `ad1980cb` and `238ed78a` address them. - On this head, the `_warp` variants pass in CI (Test). The `_hardware` variants have not been run. - @pigalot, start-up at `4a43a173`, Windows 11 with the D3D12 hardware backend, 900 s cap. - Lazy and shared-views switches on: a second-chance write access violation in the executable at 191.7 s (4706 frames). Main without this PR, same switches: the same kind of fault at 250.0 s (5410 frames), at a different address. - Switches off: the run reached the 900 s cap, with 16381 frames and no fault. - DirectStorage: each run had the same single failure, "destination capacity exceeded". - @MasterDomino, start-up with lazy memory off. - Setup: two matched pairs of 420 s runs on Windows 11 build 26300.9974, an RX 9070 XT (driver 32.0.32029.2010), `release`, debug layer off. Builds: #2918's head `27778f4f`, which carries the same change as this PR at `238ed78a`, against `cpp-migration` `40365770`. - All four runs ended on the timeout. Frames, storage requests, textures, pipelines and exceptions matched within noise. - Token null bindings were about 1.6 times the base in both pairs, which he marked as a hint, not a result. - With shared views off, `f19890e4` takes no mutex and no run lookup for a DirectStorage copy, which is the path he named. That has not been measured. ### Measured vs not - Measured: - the fixture behaviour above under Wine; - the counters and frame counts of the runs listed; - the reviewers' Windows runs of earlier heads; - CI's `pr` preset run of the final head. - Not measured: - any Windows run of the final head outside CI's `pr` preset, including the `_hardware` variants; - any start-up run of the final head; - whether `xmem_lazy_commit_off` passes on this head under Wine. Host noise decides it here; - whether `f19890e4` changes the token null count in lazy-off runs; - how often the executable calls `VirtualQueryEx` (it imports it, but the calls were not counted); - what the start-up watchdog waits for in the branch runs; - the cause of the data-file dialog. - Known limits: - Placeholder fallback (Wine only). - It cannot tell a reserved page of a private allocation made with `VirtualAlloc2(MEM_REPLACE_PLACEHOLDER)` from a placeholder, because Wine does not refuse the release for that kind of allocation. - After a refused view, the batch retries each page on its own. That cut such a page out of the caller's allocation: the committed page's allocation then started one page later. - Where the OS reports the placeholder bit, the fallback is not used. - `ReadFile`/`WriteFile` retry. - It assumes that the failed call had no partial side effect. Only Wine's full failure was measured. - On a pipe, Wine keeps the data queued. Whether Windows consumes it is unmeasured, which is why only disk files are retried. - 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 on a page whose run a break mapped is retried once per thread before it is passed on, and again after each later break that maps the page again. - 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.
pigalot commented 2026-11-26 20:22:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T20:22:24Z.


Tested on Windows 11 (D3D12 hardware backend) with the switches from "How to test", plus X2W_D3D12_BUDGET=1 and fresh storage for each run. Each run was capped at 900 s. In all three runs the executable got past the account prompt the same way.

Build X2W_XMEM_LAZY_COMMIT / LAZY_STARTUP / SHARED_VIEWS End Frames presented Peak commit
main 6ee878d8 + this PR (4a43a173) on second-chance write access violation in the executable at 191.7 s 4706 (to 183 s) 8.0 GiB
main 6ee878d8 + this PR (4a43a173) off timeout at 900 s, no fault 16381 (to 894 s) 23.0 GiB
main 6ee878d8, without this PR on second-chance write access violation in the executable at 250.0 s 5410 (to 239 s) 8.0 GiB
  • On Windows the lazy/shared-views mode ends the run with a write fault in the executable's own code, with or without this PR. The two faults are at different addresses. So this PR does not seem to cause it. It is not the main 15-16 s present stall described above either.
  • With the switches off, this PR runs the full 900 s and keeps presenting.
  • DirectStorage: each run has the same single failure, destination capacity exceeded. The new copy faulted (source not readable) message never appeared.

All three builds also carried local diagnostics and input automation that are not part of this PR.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7202598177 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7202598177). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-26T20:22:24Z. --- Tested on Windows 11 (D3D12 hardware backend) with the switches from "How to test", plus `X2W_D3D12_BUDGET=1` and fresh storage for each run. Each run was capped at 900 s. In all three runs the executable got past the account prompt the same way. | Build | `X2W_XMEM_LAZY_COMMIT` / `LAZY_STARTUP` / `SHARED_VIEWS` | End | Frames presented | Peak commit | | --- | --- | --- | --- | --- | | main 6ee878d8 + this PR (4a43a173) | on | second-chance write access violation in the executable at 191.7 s | 4706 (to 183 s) | 8.0 GiB | | main 6ee878d8 + this PR (4a43a173) | off | timeout at 900 s, no fault | 16381 (to 894 s) | 23.0 GiB | | main 6ee878d8, without this PR | on | second-chance write access violation in the executable at 250.0 s | 5410 (to 239 s) | 8.0 GiB | - On Windows the lazy/shared-views mode ends the run with a write fault in the executable's own code, with or without this PR. The two faults are at different addresses. So this PR does not seem to cause it. It is not the main 15-16 s present stall described above either. - With the switches off, this PR runs the full 900 s and keeps presenting. - DirectStorage: each run has the same single failure, `destination capacity exceeded`. The new `copy faulted (source not readable)` message never appeared. All three builds also carried local diagnostics and input automation that are not part of this PR. This comment was AI-assisted.
Not-Saii commented 2026-11-26 20:29:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T20:29:32Z.


Review of the head 4a43a173, with a Windows run of the tests this PR adds or touches.

Two existing tests fail on this head and pass on main on the same machine, in their WARP and their hardware variants, both because single-page calls now join. Every new test passes on Windows. After the test report there are four review points and some smaller ones.

Windows test run

Windows 11 build 26300.9974, x64. MSVC 19.44.35230, dev preset (a Debug build). The WARP tests ran on Microsoft Basic Render Driver 10.0.26100.9818 with the D3D12 debug layer off. The _hardware tests ran on an NVIDIA GeForce RTX 4090 (10de:2684), driver 32.0.16.1088, also with the debug layer off. Head 4a43a173, control main 6ee878d8, both built in the same build directory.

cmake --preset dev
cmake --build --preset dev --target xmem_shim xmem_shim_test_controls startup_stub_xcrdapi startup_stub_xcrdapi_break_window_control xmem_run_break_readers_check xmem_run_break_readers_control xmem_cross_call_merge_check xmem_placeholder_split_check xmem_map_split_first_check startup_dstorage_break_window_check startup_dstorage_destination_check startup_dstorage_file_read_check xmem_page_runs_device_check linear_buffer_backing_check
ctest --preset dev --no-tests=error -R '^xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs)|^xmem_shim_(page_runs|mapped_pages)$|^startup_dstorage_|^linear_buffer_backing_' -E '_hardware$' -V
ctest --preset dev --no-tests=error -R '^(xmem_page_runs_device|linear_buffer_backing_.*)_hardware$' -V

The build had no errors or warnings. The first ctest line selects 46 tests: 43 passed, 2 failed and 1 skipped (77). The second selects the 9 _hardware variants: 7 passed, 2 failed and none skipped.

  • Failed: xmem_page_runs_device_warp, linear_buffer_backing_share_warp, and the _hardware variant of each. All four pass at 6ee878d8: the two WARP tests with -R '^(xmem_page_runs_device_warp|linear_buffer_backing_share_warp)$' (2 of 2), and the whole second ctest line (9 of 9).
  • Skipped (77): xmem_placeholder_split_control, as expected, because Windows reports the placeholder bit.
  • Passed: the eight xmem_run_break_readers* tests, the four xmem_cross_call_merge* tests, xmem_placeholder_split, xmem_map_split_first and its control, startup_dstorage_break_window and its control, startup_dstorage_destination, the two startup_dstorage_file_read* tests, xmem_shim_page_runs, xmem_shim_mapped_pages, and the other 21 linear_buffer_backing_* tests of the first line. On hardware, the other seven linear_buffer_backing_*_hardware tests.

Pull-request CI covers almost none of this. On a pull request the Windows job builds and runs the pr preset only. That preset builds xmem_shim but none of the new test programs, and of the tests above its filter matches only xmem_shim_mapped_pages. So where the description says Windows CI is the first real check, that check only happens on main after a merge.

The two failures

xmem_page_runs_device_warp, which I also reported on #2905:

FAIL across two single-page views: the buffer touches 1 view(s), expected 2

A page gets its section slot when it is first mapped (section_for, called from map_pages_locked), not when XMemAllocatePhysicalPages returns its token. Mapping single[7 - i] therefore still takes consecutive slots in call order, and each call joins the one before it. The reversed case of tests/xmem_cross_call_merge_check.cpp handles this by mapping all the pages through one view first. This test needs the same step. xmem_page_runs_device_hardware fails with the same line.

linear_buffer_backing_share_warp, in its split case:

share    xmem     split  FAIL: slot 133 -> 0x00000000, copied (share 0x80070032, feature 0x00000000, 131072 bytes in 1 refreshes, staging 1); GPU read B=1024/1024

At 6ee878d8 the same row passes with share 0x80070057. allocate_split maps alloc_pages - 1 pages and then one more page with a second call, and expects a view boundary inside the buffer. The second call now joins the first, so sharing is no longer refused with E_INVALIDARG. linear_buffer_backing_share_hardware fails on the same row with the same values. The description lists this family as not measured.

The pin row of the same test changes too. It is measured, not asserted. OpenExistingHeapFromAddress at the address of a mapping call returns 0x80070057 on this head and 0x00000000 at 6ee878d8. The likely reason is that the address is no longer the base of a view once the call has joined its neighbour, but I have not confirmed that.

Review points

  1. With xmem.dll loaded, a DirectStorage copy skips the check from #2685 and holds the mapping mutex during the region walk. x2w_xmem_copy_to_destination (src/xmem_mapped_pages.cpp:1864) judges the destination with x2w_local::committed_writable alone, which is the VirtualQuery walk. #2685 added resident_read_write, a QueryWorkingSetEx check, because that walk cost about 10 ms per request. It is now reached only without xmem.dll. The walk and the copy both run under memory.mutex, so mapping calls, lazy-commit faults and break retries wait behind them. The start-up runs in my comment on #2905 fit this: one 16-byte copy held the mutex for 69.7 ms, and the longest holds (24.8 to 102.3 ms) belonged to copies of 16 bytes to 450 KiB. Could the resident check run first, and the mutex be taken only when the destination or the source overlaps a run?

  2. Is a history of 64 breaks enough now that a joining call is a break? retry_remapped_page retries a fault only while its break is still in RemapWindow::recent. Before this PR breaks were rare. Now every single-page call that joins is one, or two with a GPU mirror, so the history spans 32 to 64 map calls. Take a thread that faults during the join that fills a run. If its handler only runs after 64 later joins on the next run, the access violation is passed on although the page is mapped. xmem_run_break_readers_ring_edge asserts that outcome. With lazy commit on, lazy_commit_fault retries once per page and hides the first miss. With shared views alone, nothing does. I have not reproduced this. Stamping each run with the generation that last remapped it, and comparing that under memory.mutex, would give a test that does not expire.

  3. Joins are active on native Windows too, because run.ps1 -LazyMemory sets X2W_XMEM_SHARED_VIEWS. Every single-page call that continues a run now unmaps and remaps up to 63 live pages. The description's own timing puts a join at the cap at about the cost of a separate map under Wine (1.515 ms against 1.392 ms), so the gain there comes from having fewer views. Nothing measures a gain on Windows, and the two failures above show that the layout change reaches code outside xmem. The Windows start-up runs so far, the one reported above by pigalot and mine on #2905, got as far as main did with the switches on. So I see no breakage from the joins on Windows, and no measured benefit either. Would a separate switch for joins make sense, so that -LazyMemory on Windows keeps the layout it had?

  4. Under Wine, the placeholder fallback checks one page per allocation. I read this from the code and did not reproduce it. In alias_placeholders (src/xmem_mapped_pages.cpp:1365) the fallback accepts an allocation when the page at address reads MEM_RESERVE, then skips the whole allocation. The probe shows that the OS refuses a reservation that was never a placeholder. A block that replaced a placeholder is a different case, since VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) is the documented way to free one back to a placeholder. Suppose the title commits a block at an address inside an XMem reservation and later decommits part of it. Is a slot 31 batch that names that part refused under Wine? On Windows the bit check refuses it.

Smaller things

  • X2W_XMEM_TEST_MAP_FIRST (src/xmem_mapped_pages.cpp:395) and X2W_XMEM_TEST_NO_PLACEHOLDER_FALLBACK (line 1332) are read by the deployed xmem.dll, and their controls run against xmem_shim. The Switches table lists both as test-controls build only. X2W_XMEM_TEST_NO_MERGE is guarded and has a _deployed test.
  • The ReadFile/WriteFile retry does not look at the handle type. On a pipe or an append handle the failed call may already have consumed or written bytes. Limiting the retry to FILE_TYPE_DISK would keep it to the case that was measured.
  • src/startup_stubs/xcrdapi.cpp:954 logs every error except ERROR_NOACCESS as "copy faulted (source not readable)". That includes ERROR_INVALID_PARAMETER and a fault on the destination.
  • x2w_xmem_map_counts was inserted between the slab-accounting comment and x2w_xmem_slab_stats, so that comment now sits on the wrong export (src/xmem_mapped_pages.cpp:1767).
  • tests/xmem_cross_call_merge_check.cpp refers to "ready.md's table" (line 329) and "the review notes" (line 13). Neither is in the repository.
  • Repository conventions. The new registrations are in CMakeLists.txt, where tests/cmake/README.md asks for a tests/cmake/<family>.cmake fragment. The xmem_placeholder_split note went into docs/experiments.md, where AGENTS.md says new notes go in docs/experiments/<topic>.md. AGENTS.md also asks for one reviewable behavior per pull request, and the description names three groups. The slot 31 fallback and the fault-retry fix look independent of the joins and could land on their own.

Measured here: the test results above, on one machine and one GPU. Not measured: points 2 and 4, which come from reading the code, and any start-up run in this pass.

Edited once, to add the _hardware variants.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7202745871 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7202745871). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T20:29:32Z. --- Review of the head `4a43a173`, with a Windows run of the tests this PR adds or touches. Two existing tests fail on this head and pass on `main` on the same machine, in their WARP and their hardware variants, both because single-page calls now join. Every new test passes on Windows. After the test report there are four review points and some smaller ones. ### Windows test run Windows 11 build 26300.9974, x64. MSVC 19.44.35230, `dev` preset (a Debug build). The WARP tests ran on Microsoft Basic Render Driver 10.0.26100.9818 with the D3D12 debug layer off. The `_hardware` tests ran on an NVIDIA GeForce RTX 4090 (10de:2684), driver 32.0.16.1088, also with the debug layer off. Head `4a43a173`, control `main` `6ee878d8`, both built in the same build directory. ```powershell cmake --preset dev cmake --build --preset dev --target xmem_shim xmem_shim_test_controls startup_stub_xcrdapi startup_stub_xcrdapi_break_window_control xmem_run_break_readers_check xmem_run_break_readers_control xmem_cross_call_merge_check xmem_placeholder_split_check xmem_map_split_first_check startup_dstorage_break_window_check startup_dstorage_destination_check startup_dstorage_file_read_check xmem_page_runs_device_check linear_buffer_backing_check ctest --preset dev --no-tests=error -R '^xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs)|^xmem_shim_(page_runs|mapped_pages)$|^startup_dstorage_|^linear_buffer_backing_' -E '_hardware$' -V ctest --preset dev --no-tests=error -R '^(xmem_page_runs_device|linear_buffer_backing_.*)_hardware$' -V ``` The build had no errors or warnings. The first `ctest` line selects 46 tests: 43 passed, 2 failed and 1 skipped (77). The second selects the 9 `_hardware` variants: 7 passed, 2 failed and none skipped. - Failed: `xmem_page_runs_device_warp`, `linear_buffer_backing_share_warp`, and the `_hardware` variant of each. All four pass at `6ee878d8`: the two WARP tests with `-R '^(xmem_page_runs_device_warp|linear_buffer_backing_share_warp)$'` (2 of 2), and the whole second `ctest` line (9 of 9). - Skipped (77): `xmem_placeholder_split_control`, as expected, because Windows reports the placeholder bit. - Passed: the eight `xmem_run_break_readers*` tests, the four `xmem_cross_call_merge*` tests, `xmem_placeholder_split`, `xmem_map_split_first` and its control, `startup_dstorage_break_window` and its control, `startup_dstorage_destination`, the two `startup_dstorage_file_read*` tests, `xmem_shim_page_runs`, `xmem_shim_mapped_pages`, and the other 21 `linear_buffer_backing_*` tests of the first line. On hardware, the other seven `linear_buffer_backing_*_hardware` tests. Pull-request CI covers almost none of this. On a pull request the Windows job builds and runs the `pr` preset only. That preset builds `xmem_shim` but none of the new test programs, and of the tests above its filter matches only `xmem_shim_mapped_pages`. So where the description says Windows CI is the first real check, that check only happens on `main` after a merge. ### The two failures `xmem_page_runs_device_warp`, which I also reported on #2905: ```text FAIL across two single-page views: the buffer touches 1 view(s), expected 2 ``` A page gets its section slot when it is first mapped (`section_for`, called from `map_pages_locked`), not when `XMemAllocatePhysicalPages` returns its token. Mapping `single[7 - i]` therefore still takes consecutive slots in call order, and each call joins the one before it. The `reversed` case of `tests/xmem_cross_call_merge_check.cpp` handles this by mapping all the pages through one view first. This test needs the same step. `xmem_page_runs_device_hardware` fails with the same line. `linear_buffer_backing_share_warp`, in its `split` case: ```text share xmem split FAIL: slot 133 -> 0x00000000, copied (share 0x80070032, feature 0x00000000, 131072 bytes in 1 refreshes, staging 1); GPU read B=1024/1024 ``` At `6ee878d8` the same row passes with `share 0x80070057`. `allocate_split` maps `alloc_pages - 1` pages and then one more page with a second call, and expects a view boundary inside the buffer. The second call now joins the first, so sharing is no longer refused with `E_INVALIDARG`. `linear_buffer_backing_share_hardware` fails on the same row with the same values. The description lists this family as not measured. The `pin` row of the same test changes too. It is measured, not asserted. `OpenExistingHeapFromAddress` at the address of a mapping call returns `0x80070057` on this head and `0x00000000` at `6ee878d8`. The likely reason is that the address is no longer the base of a view once the call has joined its neighbour, but I have not confirmed that. ### Review points 1. With xmem.dll loaded, a DirectStorage copy skips the check from #2685 and holds the mapping mutex during the region walk. `x2w_xmem_copy_to_destination` (`src/xmem_mapped_pages.cpp:1864`) judges the destination with `x2w_local::committed_writable` alone, which is the `VirtualQuery` walk. #2685 added `resident_read_write`, a `QueryWorkingSetEx` check, because that walk cost about 10 ms per request. It is now reached only without xmem.dll. The walk and the copy both run under `memory.mutex`, so mapping calls, lazy-commit faults and break retries wait behind them. The start-up runs in [my comment on #2905](https://github.com/R0Y00/Xbox2Windows/pull/2905#issuecomment-7201291606) fit this: one 16-byte copy held the mutex for 69.7 ms, and the longest holds (24.8 to 102.3 ms) belonged to copies of 16 bytes to 450 KiB. Could the resident check run first, and the mutex be taken only when the destination or the source overlaps a run? 2. Is a history of 64 breaks enough now that a joining call is a break? `retry_remapped_page` retries a fault only while its break is still in `RemapWindow::recent`. Before this PR breaks were rare. Now every single-page call that joins is one, or two with a GPU mirror, so the history spans 32 to 64 map calls. Take a thread that faults during the join that fills a run. If its handler only runs after 64 later joins on the next run, the access violation is passed on although the page is mapped. `xmem_run_break_readers_ring_edge` asserts that outcome. With lazy commit on, `lazy_commit_fault` retries once per page and hides the first miss. With shared views alone, nothing does. I have not reproduced this. Stamping each run with the generation that last remapped it, and comparing that under `memory.mutex`, would give a test that does not expire. 3. Joins are active on native Windows too, because `run.ps1 -LazyMemory` sets `X2W_XMEM_SHARED_VIEWS`. Every single-page call that continues a run now unmaps and remaps up to 63 live pages. The description's own timing puts a join at the cap at about the cost of a separate map under Wine (1.515 ms against 1.392 ms), so the gain there comes from having fewer views. Nothing measures a gain on Windows, and the two failures above show that the layout change reaches code outside xmem. The Windows start-up runs so far, the one reported above by pigalot and mine on #2905, got as far as `main` did with the switches on. So I see no breakage from the joins on Windows, and no measured benefit either. Would a separate switch for joins make sense, so that `-LazyMemory` on Windows keeps the layout it had? 4. Under Wine, the placeholder fallback checks one page per allocation. I read this from the code and did not reproduce it. In `alias_placeholders` (`src/xmem_mapped_pages.cpp:1365`) the fallback accepts an allocation when the page at `address` reads `MEM_RESERVE`, then skips the whole allocation. The probe shows that the OS refuses a reservation that was never a placeholder. A block that replaced a placeholder is a different case, since `VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)` is the documented way to free one back to a placeholder. Suppose the title commits a block at an address inside an XMem reservation and later decommits part of it. Is a slot 31 batch that names that part refused under Wine? On Windows the bit check refuses it. ### Smaller things - `X2W_XMEM_TEST_MAP_FIRST` (`src/xmem_mapped_pages.cpp:395`) and `X2W_XMEM_TEST_NO_PLACEHOLDER_FALLBACK` (line 1332) are read by the deployed xmem.dll, and their controls run against `xmem_shim`. The Switches table lists both as test-controls build only. `X2W_XMEM_TEST_NO_MERGE` is guarded and has a `_deployed` test. - The `ReadFile`/`WriteFile` retry does not look at the handle type. On a pipe or an append handle the failed call may already have consumed or written bytes. Limiting the retry to `FILE_TYPE_DISK` would keep it to the case that was measured. - `src/startup_stubs/xcrdapi.cpp:954` logs every error except `ERROR_NOACCESS` as "copy faulted (source not readable)". That includes `ERROR_INVALID_PARAMETER` and a fault on the destination. - `x2w_xmem_map_counts` was inserted between the slab-accounting comment and `x2w_xmem_slab_stats`, so that comment now sits on the wrong export (`src/xmem_mapped_pages.cpp:1767`). - `tests/xmem_cross_call_merge_check.cpp` refers to "ready.md's table" (line 329) and "the review notes" (line 13). Neither is in the repository. - Repository conventions. The new registrations are in `CMakeLists.txt`, where `tests/cmake/README.md` asks for a `tests/cmake/<family>.cmake` fragment. The `xmem_placeholder_split` note went into `docs/experiments.md`, where AGENTS.md says new notes go in `docs/experiments/<topic>.md`. AGENTS.md also asks for one reviewable behavior per pull request, and the description names three groups. The slot 31 fallback and the fault-retry fix look independent of the joins and could land on their own. Measured here: the test results above, on one machine and one GPU. Not measured: points 2 and 4, which come from reading the code, and any start-up run in this pass. Edited once, to add the `_hardware` variants. AI-assisted (Claude Code).
JohnConnorNPC commented 2026-11-26 21:13:36 +00:00 (Migrated from github.com)

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


@pigalot Thanks for the Windows runs of 4a43a173.

Noted from your table (Windows 11, D3D12 hardware backend):

  • With the memory switches off, this PR ran the full 900 s and kept presenting (16381 frames to 894 s).
  • With them on, the run ended on a write fault in the executable at 191.7 s with this PR and at 250.0 s without it, at different addresses. So on Windows, main with the switches on gets well past the point where it stops under Wine (52-56 s in our runs), and these runs show no gain from this PR there.
  • DirectStorage: one destination capacity exceeded failure per run, and no copy faulted (source not readable) line.

Whether joins should stay on under -LazyMemory on Windows is being considered together with the review points below.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7203515088 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7203515088). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-26T21:13:36Z. --- @pigalot Thanks for the Windows runs of `4a43a173`. Noted from your table (Windows 11, D3D12 hardware backend): - With the memory switches off, this PR ran the full 900 s and kept presenting (16381 frames to 894 s). - With them on, the run ended on a write fault in the executable at 191.7 s with this PR and at 250.0 s without it, at different addresses. So on Windows, `main` with the switches on gets well past the point where it stops under Wine (52-56 s in our runs), and these runs show no gain from this PR there. - DirectStorage: one `destination capacity exceeded` failure per run, and no `copy faulted (source not readable)` line. Whether joins should stay on under `-LazyMemory` on Windows is being considered together with the review points below. This comment was AI-assisted.
JohnConnorNPC commented 2026-11-26 21:13:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-26T21:13:37Z.


@Not-Saii Thanks for the review and for the Windows test run of 4a43a173.

Both failures are valid at 4a43a173, and the description was wrong about the device test:

  • xmem_page_runs_device: a page gets its section slot at its first map (section_for, called from map_pages_locked). The single-page calls therefore take consecutive slots in call order, and each call joins the view before it. The description said this test's view boundaries were the same as before. That came from reading the code, not from a run, and it was wrong. So was the test's comment about reverse slot order.
  • linear_buffer_backing_share: the second call in allocate_split takes the next slot at the next address, so under X2W_XMEM_SHARED_VIEWS=1 it joins the first call, and sharing is no longer refused with E_INVALIDARG.
  • Our Wine host could not run either family. Tests that import d3d12.dll could not start in our test prefix, and all four of these exited 53 there, on main and on this head alike. Our suite therefore counted them among the failures both sides share.

Fixture changes:

  • xmem_page_runs_device: ad1980cb takes #2918's change f6020249 as it is (same patch-id): it maps the single pages from high to low addresses, so no call has a view ending at its address. It has not been run here. #2918 reports it passing on WARP and on a GTX 1080 Ti.
  • linear_buffer_backing_share, split row: a fix along the lines of #2918's 27778f4f (map the upper page first) is being considered together with the review points. The cause of the pin row change is not confirmed yet.

I checked your four review points and the smaller ones against the code at 4a43a173, and each matches it as you describe. I have not reproduced points 2 and 4. How to address them is being considered: the DirectStorage copy path, the break history, a separate switch for joins, the placeholder fallback, the CI coverage, where the test registrations and notes live, and the scope of this PR.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7203515404 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7203515404). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-26T21:13:37Z. --- @Not-Saii Thanks for the review and for the Windows test run of `4a43a173`. Both failures are valid at `4a43a173`, and the description was wrong about the device test: - `xmem_page_runs_device`: a page gets its section slot at its first map (`section_for`, called from `map_pages_locked`). The single-page calls therefore take consecutive slots in call order, and each call joins the view before it. The description said this test's view boundaries were the same as before. That came from reading the code, not from a run, and it was wrong. So was the test's comment about reverse slot order. - `linear_buffer_backing_share`: the second call in `allocate_split` takes the next slot at the next address, so under `X2W_XMEM_SHARED_VIEWS=1` it joins the first call, and sharing is no longer refused with `E_INVALIDARG`. - Our Wine host could not run either family. Tests that import `d3d12.dll` could not start in our test prefix, and all four of these exited 53 there, on `main` and on this head alike. Our suite therefore counted them among the failures both sides share. Fixture changes: - `xmem_page_runs_device`: `ad1980cb` takes #2918's change `f6020249` as it is (same patch-id): it maps the single pages from high to low addresses, so no call has a view ending at its address. It has not been run here. #2918 reports it passing on WARP and on a GTX 1080 Ti. - `linear_buffer_backing_share`, `split` row: a fix along the lines of #2918's `27778f4f` (map the upper page first) is being considered together with the review points. The cause of the `pin` row change is not confirmed yet. I checked your four review points and the smaller ones against the code at `4a43a173`, and each matches it as you describe. I have not reproduced points 2 and 4. How to address them is being considered: the DirectStorage copy path, the break history, a separate switch for joins, the placeholder fallback, the CI coverage, where the test registrations and notes live, and the scope of this PR. This comment was AI-assisted.
JohnConnorNPC commented 2026-11-27 01:28:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T01:28:07Z.


The branch is now at 0c6be971, 34 commits on main 6ee878d8. The description lists each commit and what it changes. The 17 commits after 4a43a173 address @Not-Saii's review points 1 to 4 and the smaller ones (see "Review changes"), and they carry #2918's f6020249 and 27778f4f as ad1980cb and 238ed78a (same patch-ids).

@MasterDomino Thanks for the lazy-off runs on #2918 (comment 7204145940), and for labelling the token null difference as a hint.

  • The path you named changed in f19890e4. With shared views off, a DirectStorage copy through xmem.dll now takes no mapping mutex and no run lookup. It checks resident read-write pages first and then falls back to the region walk, as XCRDAPI does without xmem.dll (#2685). With shared views on, it takes the mutex only when the destination or the source overlaps a recorded run.
  • Measured under Wine with the test-controls build's counters:
    • startup_dstorage_break_window_views_off: with shared views off, an XMem page destination was copied 0 times with the mutex and once without it.
    • startup_dstorage_break_window_plain: a VirtualAlloc destination was copied without the mutex, and a run destination with it.
  • Your runs were of 27778f4f, which held the mutex for every copy. If you can, a re-run of the same lazy-off pair on 0c6be971 would test your hypothesis: does the token null count follow that path? We cannot run it, because our host has no Windows.

Windows fixture run: could a reviewer with Windows run these on 0c6be971?

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)' -V
  • This selects 31 tests in our configure:
    • xmem_page_runs_device_hardware and linear_buffer_backing_share_hardware need a physical GPU.
    • The three _warp tests need WARP.
    • xmem_placeholder_split_control, _deployed and _partial should skip (77) where the OS reports the placeholder bit.
  • The pr CI preset now runs 28 of them, all but the _hardware two and xmem_shim_page_runs.
  • CI's Build and test on Windows job ran the pr preset on 0c6be971 (run 45921712354, image windows-2025-vs2026). It ran 68 tests and all of them passed. Of the 28 above, 25 passed and 3 skipped (77): xmem_placeholder_split_control, _deployed and _partial.
    • The 25 include xmem_page_runs_device_warp, xmem_page_runs_device_join_warp and linear_buffer_backing_share_warp.
    • xmem_page_runs_device and linear_buffer_backing_share failed at 4a43a173.
  • Still without a Windows result: xmem_page_runs_device_hardware, linear_buffer_backing_share_hardware and xmem_shim_page_runs, and every test on a physical GPU.
  • Please give the adapter, driver, Windows build and debug-layer status with the counts.

Measured here, on Linux under Proton Experimental (wine-11.0) with a clang-cl cross build at 0c6be971:

  • The 31 tests above: 26 passed. The three _warp tests failed because there is no WARP here, and the two _hardware tests skipped (77).
  • The full suite: 614 passed, 1668 failed and 109 skipped (77) of 2391. The failures are the host's: no D3D12, WARP or GPU, and targets the cross toolchain cannot build.
  • The pure-Python checks: all 210 passed.
  • xmem_lazy_commit_off is unmeasured under Wine, because host load decides it.

Not measured: a Windows run of this head outside CI's pr preset, and any start-up run of this head. Nothing here claims that a title runs.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7207311832 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7207311832). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-27T01:28:07Z. --- The branch is now at `0c6be971`, 34 commits on `main` `6ee878d8`. The description lists each commit and what it changes. The 17 commits after `4a43a173` address @Not-Saii's review points 1 to 4 and the smaller ones (see "Review changes"), and they carry #2918's `f6020249` and `27778f4f` as `ad1980cb` and `238ed78a` (same patch-ids). @MasterDomino Thanks for the lazy-off runs on #2918 ([comment 7204145940](https://github.com/R0Y00/Xbox2Windows/pull/2918#issuecomment-7204145940)), and for labelling the token null difference as a hint. - The path you named changed in `f19890e4`. With shared views off, a DirectStorage copy through xmem.dll now takes no mapping mutex and no run lookup. It checks resident read-write pages first and then falls back to the region walk, as XCRDAPI does without xmem.dll (#2685). With shared views on, it takes the mutex only when the destination or the source overlaps a recorded run. - Measured under Wine with the test-controls build's counters: - `startup_dstorage_break_window_views_off`: with shared views off, an XMem page destination was copied 0 times with the mutex and once without it. - `startup_dstorage_break_window_plain`: a `VirtualAlloc` destination was copied without the mutex, and a run destination with it. - Your runs were of `27778f4f`, which held the mutex for every copy. If you can, a re-run of the same lazy-off pair on `0c6be971` would test your hypothesis: does the token null count follow that path? We cannot run it, because our host has no Windows. Windows fixture run: could a reviewer with Windows run these on `0c6be971`? ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)' -V ``` - This selects 31 tests in our configure: - `xmem_page_runs_device_hardware` and `linear_buffer_backing_share_hardware` need a physical GPU. - The three `_warp` tests need WARP. - `xmem_placeholder_split_control`, `_deployed` and `_partial` should skip (77) where the OS reports the placeholder bit. - The `pr` CI preset now runs 28 of them, all but the `_hardware` two and `xmem_shim_page_runs`. - CI's `Build and test on Windows` job ran the `pr` preset on `0c6be971` (run 45921712354, image `windows-2025-vs2026`). It ran 68 tests and all of them passed. Of the 28 above, 25 passed and 3 skipped (77): `xmem_placeholder_split_control`, `_deployed` and `_partial`. - The 25 include `xmem_page_runs_device_warp`, `xmem_page_runs_device_join_warp` and `linear_buffer_backing_share_warp`. - `xmem_page_runs_device` and `linear_buffer_backing_share` failed at `4a43a173`. - Still without a Windows result: `xmem_page_runs_device_hardware`, `linear_buffer_backing_share_hardware` and `xmem_shim_page_runs`, and every test on a physical GPU. - Please give the adapter, driver, Windows build and debug-layer status with the counts. Measured here, on Linux under Proton Experimental (wine-11.0) with a clang-cl cross build at `0c6be971`: - The 31 tests above: 26 passed. The three `_warp` tests failed because there is no WARP here, and the two `_hardware` tests skipped (77). - The full suite: 614 passed, 1668 failed and 109 skipped (77) of 2391. The failures are the host's: no D3D12, WARP or GPU, and targets the cross toolchain cannot build. - The pure-Python checks: all 210 passed. - `xmem_lazy_commit_off` is unmeasured under Wine, because host load decides it. Not measured: a Windows run of this head outside CI's `pr` preset, and any start-up run of this head. Nothing here claims that a title runs. This comment was AI-assisted.
R0Y00 commented 2026-11-27 07:04:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T07:04:22Z.

Review: COMMENTED


Independent Windows integration run at 104617d6 with current main c09145a7 (8c7bdd99 locally). Both Debug and Release /O2 built the listed fixtures. ctest --preset <dev|release> --no-tests=error -V -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)' gave 28 passes and zero failures in each preset. The three Wine-oriented placeholder controls (control, deployed, partial) skipped with 77 because Windows reports the placeholder bit.

The DirectStorage break fixture waited and copied all bytes, and the negative control reported a refusal during the break. The prior review's page-runs and linear-buffer-sharing fixtures passed on both WARP and RTX 4060 Laptop, including the WARP join variant. Windows 11 build 26200.9974, WARP driver 10.0.26100.9818 and RTX driver 32.0.16.1656, debug layer off for these D3D12 cases. Hosted Windows and Linux checks are green.

This run covers the Windows fixture matrix. The PR's original-executable and Wine evidence is from earlier heads. Can the Wine tester repeat a current-head run with the default run.sh joining behavior and add the matching control run with X2W_XMEM_JOIN_CALLS=0? The final-head startup performance and the Wine-only placeholder branches are the remaining evidence gaps from this run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6084626023 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#pullrequestreview-6084626023). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T07:04:22Z. **Review:** COMMENTED --- Independent Windows integration run at `104617d6` with current `main` `c09145a7` (`8c7bdd99` locally). Both Debug and Release `/O2` built the listed fixtures. `ctest --preset <dev|release> --no-tests=error -V -R '^(xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first|page_runs_device|shim_page_runs)|startup_dstorage_break_window|linear_buffer_backing_share)'` gave 28 passes and zero failures in each preset. The three Wine-oriented placeholder controls (`control`, `deployed`, `partial`) skipped with 77 because Windows reports the placeholder bit. The DirectStorage break fixture waited and copied all bytes, and the negative control reported a refusal during the break. The prior review's page-runs and linear-buffer-sharing fixtures passed on both WARP and RTX 4060 Laptop, including the WARP join variant. Windows 11 build 26200.9974, WARP driver 10.0.26100.9818 and RTX driver 32.0.16.1656, debug layer off for these D3D12 cases. Hosted Windows and Linux checks are green. This run covers the Windows fixture matrix. The PR's original-executable and Wine evidence is from earlier heads. Can the Wine tester repeat a current-head run with the default `run.sh` joining behavior and add the matching control run with `X2W_XMEM_JOIN_CALLS=0`? The final-head startup performance and the Wine-only placeholder branches are the remaining evidence gaps from this run.
JohnConnorNPC commented 2026-11-27 07:14:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T07:14:06Z.


Thanks for the independent Windows run and for the adapter and driver details.

Fixture-level Wine evidence at 104617d6: under Proton Experimental's Wine on Linux (test binaries cross-built with clang-cl 19 against the Windows SDK, our CTest-driven Wine runner, 2 jobs), all four placeholder-split rows pass: xmem_placeholder_split, xmem_placeholder_split_control, xmem_placeholder_split_deployed and xmem_placeholder_split_partial. The partial row's result line:

PASS xmem_placeholder_split_partial (exit 0) last: x2w-xmem placeholder bit reported=0, plain reservation kept by a placeholder release=1

These are fixture results only. They are not a start-up run and say nothing about start-up performance at this head.

Once the Wine test machine is free, I'll repeat the start-up run at the current head with run.sh's default joining, plus the matching control run with X2W_XMEM_JOIN_CALLS=0. For each run I'll post the commit, the command, the environment and the end line or first mismatch.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7212273620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7212273620). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-27T07:14:06Z. --- Thanks for the independent Windows run and for the adapter and driver details. Fixture-level Wine evidence at `104617d6`: under Proton Experimental's Wine on Linux (test binaries cross-built with clang-cl 19 against the Windows SDK, our CTest-driven Wine runner, 2 jobs), all four placeholder-split rows pass: `xmem_placeholder_split`, `xmem_placeholder_split_control`, `xmem_placeholder_split_deployed` and `xmem_placeholder_split_partial`. The `partial` row's result line: ``` PASS xmem_placeholder_split_partial (exit 0) last: x2w-xmem placeholder bit reported=0, plain reservation kept by a placeholder release=1 ``` These are fixture results only. They are not a start-up run and say nothing about start-up performance at this head. Once the Wine test machine is free, I'll repeat the start-up run at the current head with `run.sh`'s default joining, plus the matching control run with `X2W_XMEM_JOIN_CALLS=0`. For each run I'll post the commit, the command, the environment and the end line or first mismatch. This comment was AI-assisted.
JohnConnorNPC commented 2026-11-27 10:33:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T10:33:52Z.


Correction: the branch runs' "first archive" times in the Evidence table (69.8, 71.5, 79.3 and 53.3 s) came after what appears to have been hand controller input in the menus: button reads before the script's A, direction-pad presses, and a controller visible to the executable. The body did not say this, so those times are not start-up timings and are not comparable between rows. I've edited the body to say so.

New measurement at 0c6be971 with the input script only (one A, no hand input), under Wine: the executable reads the A at 49 s and then opens no archive after the menus before we stopped the runs at about 6.5 min (3 runs). With the local menu-skipping change, which is not in this PR, it opens that archive at 67.3 s (1 run).

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7216037194 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7216037194). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-27T10:33:52Z. --- Correction: the branch runs' "first archive" times in the Evidence table (69.8, 71.5, 79.3 and 53.3 s) came after what appears to have been hand controller input in the menus: button reads before the script's A, direction-pad presses, and a controller visible to the executable. The body did not say this, so those times are not start-up timings and are not comparable between rows. I've edited the body to say so. New measurement at `0c6be971` with the input script only (one A, no hand input), under Wine: the executable reads the A at 49 s and then opens no archive after the menus before we stopped the runs at about 6.5 min (3 runs). With the local menu-skipping change, which is not in this PR, it opens that archive at 67.3 s (1 run). This comment was AI-assisted.
JohnConnorNPC commented 2026-11-27 10:55:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-27T10:55:46Z.


Start-up runs under Wine for the joining switch, as asked in the last review. Two parts are measured. The current head is not yet.

Measured: 0c6be971 (this PR's head before merging main) with the local menu-skipping change. That change is not in this PR. It lets a script-only run read a save and skip the menus. Without it, the menus need input the script doesn't give: the runs read the script's one A at about 49 s and then wait in the menu (3 runs, stopped at about 6.5 min).

  • Launcher: tools/startup/run.sh --seconds 0 --memory-gib 40 --continue-asserts 1000 --fake-user --render --translate --gpu-mirror --host-cpu --startup-below-40, an input script that presses A once, X2W_XMEM_LAZY_COMMIT=1 X2W_XMEM_LAZY_STARTUP=1, and the switches listed in the body. X2W_TITLE_ID/X2W_STORAGE_MB were set by hand (see below).
  • A: run.sh's defaults, so X2W_XMEM_SHARED_VIEWS=1 and X2W_XMEM_JOIN_CALLS=1. C: the same with X2W_XMEM_JOIN_CALLS=0. In the executable's environment, that is the only difference.
  • Environment: Linux 6.12, Proton Experimental, an NVIDIA RTX 4070 Ti SUPER, a copy of a warm shader cache (key revision 28), xapu built with Opus. One run each, no timeout.
run A read first archive after the menus last frame heartbeat end
A (joins on) 49.0 s 67.3 s 2683 frames at 164.9 s write access violation in the executable, 200.7 s
C (joins off) 49.3 s 75.7 s 6556 frames at 625.6 s the same access violation, at the same address, 661.9 s
  • First difference: C presented no frame from 10 to 20 s (288 frames at both marks, A 320 at 20 s). C then opened the archive 8.4 s later.
  • Both runs end with the same second-chance access violation, at the same address, as the earlier branch runs in the body's table.
  • With one run each, the different end times (200.7 vs 661.9 s) are not a measured effect of the switch.

Not measured yet: the current head. main's #2979 changes the shader key revision from 28 to 29, so every earlier translation misses. A current-head run first needs those shaders translated again. So far the start-up path has asked for 1855 rev-29 requests. 3 graphics requests translated; the rest were refused, mostly compute. That run is next, once the test machine is free.

Found along the way, outside this PR: on Linux, run.sh looks for MicrosoftGame.config, and this package ships MicrosoftGame.Config, so the manifest's title ID and storage size are not read. run.sh also needs a desktop DISPLAY in its environment.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7216475212 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2911#issuecomment-7216475212). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-27T10:55:46Z. --- Start-up runs under Wine for the joining switch, as asked in the last review. Two parts are measured. The current head is not yet. **Measured: `0c6be971` (this PR's head before merging `main`) with the local menu-skipping change.** That change is not in this PR. It lets a script-only run read a save and skip the menus. Without it, the menus need input the script doesn't give: the runs read the script's one A at about 49 s and then wait in the menu (3 runs, stopped at about 6.5 min). - Launcher: `tools/startup/run.sh --seconds 0 --memory-gib 40 --continue-asserts 1000 --fake-user --render --translate --gpu-mirror --host-cpu --startup-below-40`, an input script that presses A once, `X2W_XMEM_LAZY_COMMIT=1 X2W_XMEM_LAZY_STARTUP=1`, and the switches listed in the body. `X2W_TITLE_ID`/`X2W_STORAGE_MB` were set by hand (see below). - A: `run.sh`'s defaults, so `X2W_XMEM_SHARED_VIEWS=1` and `X2W_XMEM_JOIN_CALLS=1`. C: the same with `X2W_XMEM_JOIN_CALLS=0`. In the executable's environment, that is the only difference. - Environment: Linux 6.12, Proton Experimental, an NVIDIA RTX 4070 Ti SUPER, a copy of a warm shader cache (key revision 28), xapu built with Opus. One run each, no timeout. | run | A read | first archive after the menus | last frame heartbeat | end | |---|---|---|---|---| | A (joins on) | 49.0 s | 67.3 s | 2683 frames at 164.9 s | write access violation in the executable, 200.7 s | | C (joins off) | 49.3 s | 75.7 s | 6556 frames at 625.6 s | the same access violation, at the same address, 661.9 s | - First difference: C presented no frame from 10 to 20 s (288 frames at both marks, A 320 at 20 s). C then opened the archive 8.4 s later. - Both runs end with the same second-chance access violation, at the same address, as the earlier branch runs in the body's table. - With one run each, the different end times (200.7 vs 661.9 s) are not a measured effect of the switch. **Not measured yet: the current head.** `main`'s #2979 changes the shader key revision from 28 to 29, so every earlier translation misses. A current-head run first needs those shaders translated again. So far the start-up path has asked for 1855 rev-29 requests. 3 graphics requests translated; the rest were refused, mostly compute. That run is next, once the test machine is free. Found along the way, outside this PR: on Linux, `run.sh` looks for `MicrosoftGame.config`, and this package ships `MicrosoftGame.Config`, so the manifest's title ID and storage size are not read. `run.sh` also needs a desktop `DISPLAY` in its environment. This comment was AI-assisted.
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!2911
No description provided.