startup: every view call asks VirtualQuery and xmem's commit mutex before writing its 32-byte token #3096

Closed
opened 2026-11-27 15:03:42 +00:00 by lukaslw-lab · 1 comment
lukaslw-lab commented 2026-11-27 15:03:42 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-27T15:03:42Z.


In the main executable's startup run (#870), device slot 18 (CreateShaderResourceView) and the other view slots are called about 110,000–130,000 times per second late in the load, by five recording threads at once. Each call ends in note_view (d3d12_capture.inl), which writes a view token into the title's descriptor memory after x2w_local::writable: commit_lazy (with X2W_XMEM_LAZY_COMMIT, x2w_xmem_commit_range, which takes xmem's commit mutex) and then a VirtualQuery. The comment on writable says "rare callers".

The destination is always inside a registered descriptor range (title_backed is checked first), so the write practically never faults.

Windows 10 22H2, i7-4790K (4 cores, 8 threads), RTX 3080 Ti, NVIDIA 32.0.16.1047, release on main 36d2cbeb, warm shader cache, scripted input, 250 s, with X2W_D3D12_RING_RELEASE_AT_SUBMIT=1, X2W_D3D12_TABLE_ALIAS=1 and X2W_D3D12_ROOT_SRV_AT_DRAW=1, two runs:

150–240 s
view calls per second 107,000–114,000
stand-in time in view calls 1.19–1.20 threads (10.4–11.2 µs per call)
share of a view call spent in writable (step timers, local build) about a third (4.0 of 12.0 µs)
recording threads runnable but without a free core (thread-state samples every 20 ms) 14–21% of the samples
mean frame rate 15.5 / 15.1 fps

Proposed in #3097: an opt-in X2W_D3D12_VIEW_TOKEN_GUARDED=1 that writes the token under an exception guard instead, with the same outcome for a page that refuses the write. The default stays as on main.

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6648988018 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3096). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-27T15:03:42Z. --- In the main executable's startup run (#870), device slot 18 (`CreateShaderResourceView`) and the other view slots are called about 110,000–130,000 times per second late in the load, by five recording threads at once. Each call ends in `note_view` (`d3d12_capture.inl`), which writes a view token into the title's descriptor memory after `x2w_local::writable`: `commit_lazy` (with `X2W_XMEM_LAZY_COMMIT`, `x2w_xmem_commit_range`, which takes xmem's commit mutex) and then a `VirtualQuery`. The comment on `writable` says "rare callers". The destination is always inside a registered descriptor range (`title_backed` is checked first), so the write practically never faults. Windows 10 22H2, i7-4790K (4 cores, 8 threads), RTX 3080 Ti, NVIDIA 32.0.16.1047, release on `main` `36d2cbeb`, warm shader cache, scripted input, 250 s, with `X2W_D3D12_RING_RELEASE_AT_SUBMIT=1`, `X2W_D3D12_TABLE_ALIAS=1` and `X2W_D3D12_ROOT_SRV_AT_DRAW=1`, two runs: | 150–240 s | | |---|---| | view calls per second | 107,000–114,000 | | stand-in time in view calls | 1.19–1.20 threads (10.4–11.2 µs per call) | | share of a view call spent in `writable` (step timers, local build) | about a third (4.0 of 12.0 µs) | | recording threads runnable but without a free core (thread-state samples every 20 ms) | 14–21% of the samples | | mean frame rate | 15.5 / 15.1 fps | Proposed in #3097: an opt-in `X2W_D3D12_VIEW_TOKEN_GUARDED=1` that writes the token under an exception guard instead, with the same outcome for a page that refuses the write. The default stays as on `main`. This report was prepared with AI assistance (Claude); the runs are mine.
lukaslw-lab commented 2026-12-01 01:07:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T01:07:30Z.


Closing together with #3097, reasons there: https://github.com/R0Y00/Xbox2Windows/pull/3097#issuecomment-7297110487. Can be reopened with it if a later profile shows the token write as a cost.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7297111729 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3096#issuecomment-7297111729). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T01:07:30Z. --- Closing together with #3097, reasons there: https://github.com/R0Y00/Xbox2Windows/pull/3097#issuecomment-7297110487. Can be reopened with it if a later profile shows the token write as a cost.
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#3096
No description provided.