startup-runtime: the DirectStorage destination check costs ~10 ms of kernel time per request (VirtualQuery over large regions) #2676

Closed
opened 2026-11-26 02:00:39 +00:00 by lukaslw-lab · 1 comment
lukaslw-lab commented 2026-11-26 02:00:39 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-26T02:00:39Z.


The DirectStorage stand-in's destination check (destination_writable, xcrdapi.cpp, added in #1672) walks each destination with VirtualQuery. On the title's multi-gigabyte regions one query scans to the end of the region (the mechanism behind #2610, and the reason #1766 and probe_readable avoid it), so the check costs about one CPU core during the main executable's first load (#870).

Windows 10 22H2, i7-4790K, RTX 3080 Ti, release build of f4c6998a, warm shader cache, same switches in both runs. Per-thread CPU time of the stand-in's threads from !runaway (cdb, non-invasive) every 20 s, paired with the storage heartbeat:

Window Requests completed Stand-in kernel time Per request
20–40 s 3,429 → 5,038 19.2 s (one thread) 11.9 ms
40–60 s 5,038 → 6,886 18.2 s 9.9 ms
60–80 s 6,886 → 8,415 18.7 s 12.2 ms
80–100 s 8,415 → 9,817 17.1 s 12.2 ms
  • Stand-in user time in the same windows is under 1 s; stack samples show the busy thread in VirtualQuery called from destination_writable.
  • The decompression phase after the load (~6 ms kernel per request, page faults) is a separate cost and not part of this.
  • No request in these runs was refused as destination not writable.

Fix in #2685: probe the destination one byte per page with a value-preserving write instead of querying it.

This report was prepared with AI assistance (Claude); the runs are mine.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617832213 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2684). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-26T02:00:39Z. --- The DirectStorage stand-in's destination check (`destination_writable`, `xcrdapi.cpp`, added in #1672) walks each destination with `VirtualQuery`. On the title's multi-gigabyte regions one query scans to the end of the region (the mechanism behind #2610, and the reason #1766 and `probe_readable` avoid it), so the check costs about one CPU core during the main executable's first load (#870). Windows 10 22H2, i7-4790K, RTX 3080 Ti, release build of `f4c6998a`, warm shader cache, same switches in both runs. Per-thread CPU time of the stand-in's threads from `!runaway` (cdb, non-invasive) every 20 s, paired with the storage heartbeat: | Window | Requests completed | Stand-in kernel time | Per request | |---|---|---|---| | 20–40 s | 3,429 → 5,038 | 19.2 s (one thread) | 11.9 ms | | 40–60 s | 5,038 → 6,886 | 18.2 s | 9.9 ms | | 60–80 s | 6,886 → 8,415 | 18.7 s | 12.2 ms | | 80–100 s | 8,415 → 9,817 | 17.1 s | 12.2 ms | - Stand-in user time in the same windows is under 1 s; stack samples show the busy thread in `VirtualQuery` called from `destination_writable`. - The decompression phase after the load (~6 ms kernel per request, page faults) is a separate cost and not part of this. - No request in these runs was refused as `destination not writable`. Fix in #2685: probe the destination one byte per page with a value-preserving write instead of querying it. This report was prepared with AI assistance (Claude); the runs are mine.
triggered02 commented 2026-11-26 04:04:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T03:38:31Z.


This was fixed by #2685 (9caa6985 startup: probe DirectStorage destinations instead of walking them with VirtualQuery) and the current main (�8814b4f) shows the shape you described as the remaining fallback only:

src/startup_stubs/xcrdapi.cpp:182 destination_writable() now asks
esident_read_write(cursor, end) first and returns after a resident read-write probe; the VirtualQuery loop under it only judges pages that are not resident read-write (not resident, copy-on-write, guard, no access). Your profile � one CPU core for the whole first load, VirtualQuery in every stack sample from destination_writable � is the walk path, which a normal writable destination no longer enters.

So the ~10 ms/request cost in the table (11.9 ? 9.9 ? 12.2 ? 12.2 ms per request across the four windows) is addressed by construction rather than by a benchmark I ran here; I have not independently re-measured the per-request kernel time on your hardware, and I am not claiming the numbers moved by a specific amount. !runaway per-thread kernel time from the same 20 s cadence, with the same switches, would confirm the drop and belongs in this thread if you have it.

Since the issue is yours, could you close it if the re-measurement confirms it, or reopen the walk case if a destination still lands there? I cannot close another author's issue from this account.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181896705 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2684#issuecomment-7181896705). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-26T03:38:31Z. --- This was fixed by **#2685** (9caa6985 startup: probe DirectStorage destinations instead of walking them with VirtualQuery) and the current main (�8814b4f) shows the shape you described as the remaining fallback only: src/startup_stubs/xcrdapi.cpp:182 destination_writable() now asks esident_read_write(cursor, end) first and returns after a resident read-write probe; the VirtualQuery loop under it only judges pages that are **not** resident read-write (not resident, copy-on-write, guard, no access). Your profile � one CPU core for the whole first load, VirtualQuery in every stack sample from destination_writable � is the walk path, which a normal writable destination no longer enters. So the ~10 ms/request cost in the table (11.9 ? 9.9 ? 12.2 ? 12.2 ms per request across the four windows) is addressed by construction rather than by a benchmark I ran here; I have not independently re-measured the per-request kernel time on your hardware, and I am not claiming the numbers moved by a specific amount. !runaway per-thread kernel time from the same 20 s cadence, with the same switches, would confirm the drop and belongs in this thread if you have it. Since the issue is yours, could you close it if the re-measurement confirms it, or reopen the walk case if a destination still lands there? I cannot close another author's issue from this account.
Sign in to join this conversation.
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#2676
No description provided.