D3D12.X: read wait cells without faulting #2960

Merged
bmjask merged 325 commits from upstream-pr/2960 into main 2026-11-28 03:19:10 +00:00
bmjask commented 2026-11-27 05:15:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-27T05:15:41Z.


Part of #2508.

Stacked on #2959. Only top commit 099eaac0fc4e358bac6b2d6f86948b618efa5d49 belongs to this PR.

A readability probe can become stale before a title wait-cell dereference. Keep the committed coherent UMA window on its acquire-atomic fast path; outside that controlled window, snapshot through ReadProcessMemory so a concurrent decommit is contained by Windows instead of faulting XCL.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: use acquire atomic loads for committed UMA cells and contained current-process reads elsewhere, with tests for both the fast path and decommitted memory.

Tested

  • Exact head 099eaac0fc4e358bac6b2d6f86948b618efa5d49: ./scripts/test.ps1 --nocapture --skip test_title_runs_and_game_folder_is_untouched on GitHub-hosted Windows Server 2025, stable Rust 1.100.0, Microsoft Basic Render Driver: 39 test binaries, 2069 passed, 0 failed, 48 ignored, 361 GPU tests skipped. https://github.com/xcl-dev/xcl/actions/runs/46002355539
  • git diff --check c2ee10e4e905eb736e56953c52b749e18bcc7ede..099eaac0fc4e358bac6b2d6f86948b618efa5d49 passed.

Regression run

  • Not run. No retail title or suitable Windows AMD SM 6.6 system was available, so there are no xcl-smoke blocks.

Not tested

  • Retail-title behavior, real AMD/NVIDIA GPU execution, wait-loop performance, or title smoke.

AI use

  • Codex, GPT-5.6-sol implemented, rebased, tested and reviewed the change and wrote this description.
<!-- greyfinch-sync:ivall/xcl:issue:5521600499 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2960). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-27T05:15:41Z. --- Part of #2508. Stacked on #2959. Only top commit `099eaac0fc4e358bac6b2d6f86948b618efa5d49` belongs to this PR. A readability probe can become stale before a title wait-cell dereference. Keep the committed coherent UMA window on its acquire-atomic fast path; outside that controlled window, snapshot through `ReadProcessMemory` so a concurrent decommit is contained by Windows instead of faulting XCL. **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: use acquire atomic loads for committed UMA cells and contained current-process reads elsewhere, with tests for both the fast path and decommitted memory. **Tested** - Exact head `099eaac0fc4e358bac6b2d6f86948b618efa5d49`: `./scripts/test.ps1 --nocapture --skip test_title_runs_and_game_folder_is_untouched` on GitHub-hosted Windows Server 2025, stable Rust 1.100.0, Microsoft Basic Render Driver: 39 test binaries, 2069 passed, 0 failed, 48 ignored, 361 GPU tests skipped. https://github.com/xcl-dev/xcl/actions/runs/46002355539 - `git diff --check c2ee10e4e905eb736e56953c52b749e18bcc7ede..099eaac0fc4e358bac6b2d6f86948b618efa5d49` passed. **Regression run** - Not run. No retail title or suitable Windows AMD SM 6.6 system was available, so there are no `xcl-smoke` blocks. **Not tested** - Retail-title behavior, real AMD/NVIDIA GPU execution, wait-loop performance, or title smoke. **AI use** - Codex, GPT-5.6-sol implemented, rebased, tested and reviewed the change and wrote this description.
Prime1997 commented 2026-11-27 08:44:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-27T08:44:12Z.


read_value now does a ReadProcessMemory for every observation, and wait_until_satisfied observes up to 513 times before it sleeps. On an Intel i5-10400 (Windows 11 26200), an 8-byte ReadProcessMemory of the process's own memory takes about 345 ns. An acquire atomic load takes 0.5 ns (2 million reads each, release build). That works out to about 177 µs of system calls per spinning wait, against about 0.3 µs before. The old readable() took that cost only for cells outside uma::in_committed_window and the resident cache; for those it already did a VirtualQuery at about the same 345 ns. Keeping the window fast path (an atomic load inside the committed coherent window) and using the contained read only outside it would keep the fault containment without the cost.

AI use: Claude Code (Claude Opus 5.5) ran the timing and drafted this comment; Prime checked it.

<!-- greyfinch-sync:ivall/xcl:comment:7213862203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2960#issuecomment-7213862203). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-27T08:44:12Z. --- `read_value` now does a `ReadProcessMemory` for every observation, and `wait_until_satisfied` observes up to 513 times before it sleeps. On an Intel i5-10400 (Windows 11 26200), an 8-byte `ReadProcessMemory` of the process's own memory takes about 345 ns. An acquire atomic load takes 0.5 ns (2 million reads each, release build). That works out to about 177 µs of system calls per spinning wait, against about 0.3 µs before. The old `readable()` took that cost only for cells outside `uma::in_committed_window` and the resident cache; for those it already did a `VirtualQuery` at about the same 345 ns. Keeping the window fast path (an atomic load inside the committed coherent window) and using the contained read only outside it would keep the fault containment without the cost. AI use: Claude Code (Claude Opus 5.5) ran the timing and drafted this comment; Prime checked it.
bmjask commented 2026-11-27 13:06:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-27T13:06:39Z.


@Prime1997 Addressed at 099eaac0. Cells inside the committed coherent UMA window again use the acquire atomic-load fast path; ReadProcessMemory is used only outside that controlled window for fault containment. A focused test covers the UMA path. I did not reproduce your nanosecond measurements, so the PR does not claim a measured speedup. Windows CI passed: 39 binaries, 2069 passed, 0 failed, 48 ignored, 361 GPU tests skipped (run).

<!-- greyfinch-sync:ivall/xcl:comment:7219068943 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2960#issuecomment-7219068943). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-27T13:06:39Z. --- @Prime1997 Addressed at `099eaac0`. Cells inside the committed coherent UMA window again use the acquire atomic-load fast path; `ReadProcessMemory` is used only outside that controlled window for fault containment. A focused test covers the UMA path. I did not reproduce your nanosecond measurements, so the PR does not claim a measured speedup. Windows CI passed: 39 binaries, 2069 passed, 0 failed, 48 ignored, 361 GPU tests skipped ([run](https://github.com/xcl-dev/xcl/actions/runs/46002355539)).
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
xcl-dev/xcl!2960
No description provided.