Skip to content

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

Backlog

Description

@lukaslw-lab

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions