Repository navigation
D3D12.X: readable checks remember pages and probe instead of asking Wine - #3021
voiceovarian1-max wants to merge 1 commit into
Conversation
`shader::readable` guards XCL's reads of title pointers (vtables in `is_adopted`, view descs, code bytes). Under Wine each answer is a system call under Wine's virtual-memory lock, ~20 us and more while other threads commit or free memory. In a retail title's world: 70,000-126,000 checks per 2 s, 1.5-2.8 s of the title's threads per 2 s. - A thread remembers the pages (ranges of up to 4) it found readable for 250 ms (`SEEN`, a ring of 64). shortcut: a page freed within that time still reads as readable on that thread; the checks guard against garbage pointers, which point at pages never seen readable. Measured: checks asked of the system 70,000-126,000 -> 4,000-20,000 per 2 s. - Under Wine, a range of up to 16 pages is read a byte a page with `IsBadReadPtr` instead of asked. Wine's IsBadReadPtr catches access violations only, so a vectored handler turns a guard-page fault during the probe into an access violation and puts the guard back (the guard page ended the process before). `XCL_READABLE_PROBE=0`: asked, as before. Measured: the remaining 16,500-21,800 checks per 2 s (1.9-2.5 s) gone. - `readable_fresh` skips the remembered pages, for memory that may have been freed since: the next page of an instruction (`eh::code_bytes_at`). The GPU-address test checks the freed page on a thread of its own, since the page it bound is remembered on its thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on AMD under Wine, on a port of this PR rather than its own branch: amd-dev
Not verified, a guess: amd-dev commits full read-write sparse title pages on their first CPU access (97d83b5, Locally we now leave the probe off unless Tested and written by Claude Code (Claude Opus 5.5). |
|
No open or merged PR makes the same change (#2437 and #501 avoid
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Review (head 1484286, diff read, not a merge-check; draft,
Fine: the probe itself is gated on AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
For nvidia-dev.
shader::readableguards XCL's reads of title pointers: vtables inis_adopted, the title's view descs, code bytes. Under Wine each answer is a system call (K32QueryWorkingSetEx/VirtualQuery) under Wine's virtual-memory lock, ~20 µs each and more while other threads commit or free memory. In a retail title's world there were 70,000–126,000 checks per 2 s, about 4 per draw or dispatch, which took 1.5–2.8 s of the title's threads per 2 s.There are two parts:
readable_freshskips the remembered pages for memory that may have been freed since: the next page of an instruction (eh::code_bytes_at).IsBadReadPtrinstead of being asked of the system. Wine'sIsBadReadPtrcatches access violations only, and a guard page it read ended the process. So during the probe a vectored handler puts the guard back and turns the guard-page fault into an access violation.XCL_READABLE_PROBE=0asks the system, as before.What is in it
gpu/shader.rs:SEEN,readable_fresh,probe_on,probe_guard_page,readable_asked(the old body).eh.rs:code_bytes_atusesreadable_fresh.hle/d3d12x/list_x.rs: the GPU-address test checks the freed page on a thread of its own, because the page it bound is remembered on its thread.gpu/shader.rs's working-set test expects the probe's answer under Wine.Tested
x86_64-pc-windows-gnu, release. Head14842863on nvidia-dev3f39671d.cargo test -p xcl --lib -- --test-threads=4): 1691 passed, 8 failed, 28 ignored. The same 8 tests fail on nvidia-dev3f39671d.Regression run
scripts/smoke.ps1needs Windows, and we only have Linux. On Windows only the page memory applies.Not tested
VirtualQuerythere was not measured, so whether the page memory helps there is unknown), AMD, a retail title on this branch.AI use
🤖 Generated with Claude Code