Repository navigation
Conversation
…orking set On a CPU without CLZERO, `eh::is_writable` checks each emulated CLZERO line or loop before it writes. Outside the coherent window it asked `VirtualQuery`, which sizes the committed run around the address by walking it to its end. A retail game's CLZERO loops zero 0.9-15 KB at a time inside its 1.1 GB block of committed private memory (not in the coherent window, not a sparse window), and each of those checks took 0.3-4.4 ms: 4,096 of them cost 10.3 s of the first minute on the thread that ran them, and the title presented ~5 frames a second with the GPU mostly idle. `is_writable` now first asks the working set, as `readable` already does (`resident_and_readable`, xcl-dev#332): up to 16 pages that are resident with a read-write protection and no guard are writable, in one call that touches none of them. Anything else (not resident, guard, no access, read-only, longer than 16 pages) takes the `VirtualQuery` path as before. The working-set check is shared with `resident_and_readable` (`resident_with`). Measured on an RTX 2060 SUPER / i5-9400F, retail title, `smoke.ps1 -Seconds 60`: 326 and 323 frames on main, 732 and 726 with this change. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XM3GUHydjd5DSUVNT9WNSR
|
Test run of Tested
Review: Resident pages are answered from the working set (RW / RWX and not a guard page), and a page that is not resident still goes to Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
Test report: #647 under Wine on an Intel CPU without CLZERO (Linux, NVIDIA)Same kind of CPU as the description (Intel without CLZERO, emulated), but under Wine, where Setup
Unit test (lib test binary under Wine): GTA VI 1.0.2.1 (my own dump; 60 s runs with
On (The first pair. Not tested
AI use: Claude Code (Claude Opus 5.5) built both commits, ran everything above on the machine above and wrote this report. The blocks and counts are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one. |
|
Test report and review for Tested
Review
Not tested
AI use |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
On a CPU without CLZERO (Intel before the newest generations), every emulated CLZERO line or loop asks
eh::is_writablebefore it writes. Outside the coherent window that was aVirtualQuery, which sizes the committed run around the address by walking it to its end. The retail title's CLZERO loops zero 0.9–15 KB at a time inside a 1.1 GB block of its own committed private memory, which is neither the coherent window (#306) nor a sparse window (#501). Each check there took 0.3–4.4 ms: 4,096 of them cost 10.3 s of the first minute on the thread that ran them, and the title presented ~5 frames a second with the GPU mostly idle.is_writablenow asks the working set first, asreadablealready does (resident_and_readable, #332): up to 16 pages that are resident with a read-write protection and no guard are writable, answered in one call that touches none of them. Anything else (not resident, guard, no access, read-only, more than 16 pages) takes theVirtualQuerypath as before. Related to #278.What is in it
crates/xcl/src/gpu/shader.rs:resident_and_writable, next toresident_and_readable; both use one working-set helper (resident_with). Unit testwritable_pages_are_answered_from_the_working_set(written read-write pages; resident read-only pages, also as a range's tail; never-touched and guard pages, and the guard is left intact; empty, null and wrapping ranges; more than 16 pages).crates/xcl/src/eh.rs:is_writableasks it after the coherent-window check.Tested
cargo test --workspace -- --test-threads=4on83deb3c: 688 passed, 0 failed, 41 ignored. SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).<package id>, 1.0.2.1),XCL_NETWORK=0,scripts\smoke.ps1 -Seconds 60on the first screen: 266 frames onmain, 534 with this change (presents per 2 s at the end 10–11 → 25–27); peak commit the same. Two earlier pairs of runs oncb868b2(same change, before the rebase): 326 / 323 frames onmain, 732 / 726 with it.XCL_THREAD_DUMP_AT) put the busiest title thread (56–67 % of a core) inVirtualQueryfromis_writablein about half of them; a local, uncommitted counter around thatVirtualQuerygave the region size and the per-call times above.Regression run
Not tested
VirtualQueryfallback in the same function) and Memory: writes into a sparse window are checked without VirtualQuery #501 (sparse windows): all three are checks before that fallback, so they should combine; whichever lands second needs a small rebase.Not covered here, and the next hotspot in the same samples:
list_x::gpu_vachecks vertex buffers withreadable, and the buffers longer than 16 pages still take itsVirtualQuerywalk.AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_01XM3GUHydjd5DSUVNT9WNSR