Console CPU instructions: CLZERO into a title's own memory asks the working set #647
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!647
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-647"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@3L1A5-1 on GitHub · 2026-11-24 02:51 UTC · original
3L1A5-1:fix/is-writable-working-set→main· +61 −1 · 2 files · 1 commits · openOn 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 #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
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@MesshM on GitHub · 2026-11-24 03:24 UTC · original
Test run of
83deb3c24b0e4139290e650f42b0734741325c10on AMD RDNA4. I merged it onto currentmain91f9a5elocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 693 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 653 passed, 0 failed, 21 ignoredSKIPPED;writable_pages_are_answered_from_the_working_setpasses.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
VirtualQuery, so no case loses its answer; the PAGE_* modifier bits (write-combine, no-cache) sit beside the RW bits and do not hide them. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@JoaoPauluu on GitHub · 2026-11-24 04:33 UTC · original
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
VirtualQueryandQueryWorkingSetExare Wine's. The new test passes, and the title runs the same on both builds. Heremaindoesn't have the slowdown, so the speed-up doesn't show.Setup
clzeroin/proc/cpuinfo), 16 GB RAM, NVIDIA GeForce RTX 3060 12 GB, driver 620.70.06experimental-11.0-20261112(wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from #257, DXVK from Proton, DXC 1.9.2609,DXVK_CONFIG="dxgi.hideNvidiaGpu = False"x86_64-pc-windows-gnu(mingw-w64-gcc 16.2.0); debug for the test, release for the runs83deb3cand its basemaindd2ae9aUnit test (lib test binary under Wine):
gpu::shader::tests::writable_pages_are_answered_from_the_working_setok, 2 of 2 runs.GTA VI 1.0.2.1 (my own dump; 60 s runs with
scripts/linux/smoke.shfrom #257,XCL_NETWORK=0, alternating base / PR / PR / base). Every run logsClzeroLoop { end_reg: 10 } in game_scarlett_master.exe+0x4e8aa70 – a console CPU instruction this CPU lacks: emulated (logged once).dd2ae9a83deb3cOn
mainthis title already shows ~1000 frames in 60 s under Wine (the description has 266 onmainand 534 with the PR on Windows), so the 0.3–4.4 msVirtualQueryper check apparently doesn't happen with Wine'sVirtualQuery. I didn't count or time theis_writablecalls, so that is inferred from the frame counts, not measured.(The first pair.
peak commit: 0 MBis XCL reading 0 MB committed under Wine, see #257.)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.
@iggyvilla on GitHub · 2026-11-24 05:31 UTC · original
Test report and review for
83deb3c24b0e4139290e650f42b0734741325c10on AMD RDNA2 (merge basebdab19492, tested detached and clean, not merged onto currentmain).Tested
rustc 1.100.0 (0ef1bc386 2026-11-09) stable-x86_64-pc-windows-msvc.cargo build --release -p xclandcargo build --workspace(debug) succeeded.cargo test --workspace --no-fail-fast -- --test-threads=4on83deb3c(debug): 685 passed, 3 failed, 41 ignored, 0 SKIPPED (both wave64 tests ran and passed;xcllib: 645 passed, 3 failed, 21 ignored;e2e: 3 passed, 0 failed).gpu::shader::tests::writable_pages_are_answered_from_the_working_setpasses.bdab194:placed_title_textures_share_vram_and_preserve_pixels(#470 / #718) and twoPoisonErrorcascades (transitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memory, fixed by #673), both of which pass when rerun alone at--test-threads=1.scripts\smoke.ps1,XCL_NETWORK=0, release build, clean tree):Review
resident_and_readableintoresident_withpreserves the readable predicate (protect != 0 && protect & (PAGE_NOACCESS | PAGE_GUARD) == 0), which the smoke run exercises viareadable.is_writablefast-paths only residentValidpages withPAGE_READWRITE/PAGE_EXECUTE_READWRITEand withoutPAGE_GUARD(<=16 pages, non-empty/non-wrapping), falling back toVirtualQueryfor everything else (includingPAGE_WRITECOPY), so it cannot classify a non-writable page as writable. Unit test coverage is solid. Nothing to change found.Not tested
CLZEROnatively, so the title does not entereh's emulation oris_writableduring the smoke run;is_writable's working-set fast path is exercised by the unit test only, while the smoke run validates no regression and exercisesresident_withviareadable.bdab194or head merged onto currentmain; runs past 60 s;XCL_SAMPLE_*tests; Intel CPUs / NVIDIA GPUs.AI use
opencode with DeepSeek V4.1 Flash (
opencode-go/deepseek-v4.1-flash) ran the build, test suite, and smoke run and drafted this report.@DavidM1911 on GitHub · 2026-11-25 12:34 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.