Repository navigation
Conversation
Two checks that the title's memory is committed and writable asked VirtualQuery: the destination of every DirectStorage request (dstorage::writable) and every emulated CLZERO line or loop on a CPU without CLZERO (eh::is_writable, outside the coherent window). VirtualQuery sizes the committed run around the address by walking it to its end, and in a sparse window that run is gigabytes. A retail game's requests and CLZERO lines there took 6.7 ms a check on average and up to 138 ms, and while a walk ran its submit thread waited in GetWriteWatch (title_textures::refresh_once): a one-page GetWriteWatch took 10-17 ms in the game and 3 us outside it. known_writable answers for a range in the sparse windows from their own record of commits (committed / decommitted: every page in a mapped tile and not a hole), and asks the working set for the protection of the pages in it (K32QueryWorkingSetEx, 64 pages a call, touching none). A page the record does not hold as committed, or one in the working set without a writable protection, still takes the VirtualQuery path, so the record can only answer yes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two checks that a title's memory is committed and writable ask
VirtualQuery: the destination of every DirectStorage request (dstorage::writable, at enqueue and at execute) and, on a CPU without CLZERO, every emulated CLZERO line or loop (eh::is_writable, outside the coherent window).VirtualQuerysizes the committed run around the address by walking it to its end, and in a sparse window that run is gigabytes. The same walk was the cost #332 removed fromreadable, which does not cover these two checks. Related to #278 (theis_writableguards); #314 covers the coherent window only.In GTA VI both run against the sparse windows all the time. A walk holds the process's address space while it runs, and the title's submit thread waits for it in
GetWriteWatch(title_textures::refresh_once, before each submit). The waits showed up as follows:GetWriteWatchtook 10–17 ms in the game and 3 µs in a standalone program.ZwGetWriteWatchand two threads inVirtualQuery:xcl-dstorageand a title thread in XCL's exception handler.writablemade 15,015 calls that took 101 s in 166 s (6.7 ms on average, at most 138 ms).sparse::known_writableanswers for a range in the sparse windows from their own record of commits. That record iscommitted/decommitted, which every commit and decommit path in a window already keeps: a page counts as committed when it is in a mapped tile and not a hole. The protection of the pages that are in the working set comes fromK32QueryWorkingSetEx, 64 pages a call, touching none, so a guard page keeps its guard. A page the record does not hold as committed, or one in the working set without a writable protection, still takes theVirtualQuerypath. The record can only answer yes.What is in it
Memory: writes into a sparse window are checked without VirtualQuery:known_writable,recorded_committedandresident_pages_writableincrates/xcl/src/hle/d3d12x/sparse.rs, called first bydstorage::writable(crates/xcl/src/hle/dstorage.rs) andeh::is_writable(crates/xcl/src/eh.rs).recorded_committed_needs_every_page_in_a_mapped_tile_and_no_hole(whole tiles, a range across tiles, a hole, a tile with no video memory) andresident_pages_writable_judges_the_pages_in_the_working_set(written, read-only and never-touched pages, and that asking leaves a page out of the working set).Tested
cargo build --workspace, thencargo test --workspace -- --test-threads=4on c73b0c8: 678 passed, 0 failed, 41 ignored over 16 test binaries. SKIPPED (no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware.XCL_PRESS_A_AT), 240 s, no timing code:GetWriteWatchwent from 10–17 ms to 1.7 µs (5,985 looks, 10 ms in all), and the look over the watched ranges from 38–52 ms per submit to about 4.5 ms.Regression run
scripts/smoke.ps1 -Game <GTA VI> -Seconds 90, no input (the title stays at its first menus), release builds; main at 2997c9a, this branch's base.main:
this PR:
Not tested
AI use
GetWriteWatchprogram), the code, the tests and this description. The runs and tests were made on the hardware named above.🤖 Generated with Claude Code