Repository navigation
Conversation
gpu::shader::readable checks title pointers with VirtualQuery, and VirtualQuery sizes the whole region around the address by walking it, so its cost follows the size of the region, not of the range asked about. In GTA VI's world load the page arrays of its DirectStorage requests (8-32 bytes, checked when a request is enqueued and again when it runs) live in a 2259 MB block of committed memory: each check took 20-25 ms, one VirtualQuery each. 416 calls of 20 ms or more took ~10.2 s, and time in readable went from 366 ms over the first 524k calls to 14.1 s by 1.05M calls. Thread dumps taken while no frames were presented found the title's streaming thread in readable -> VirtualQuery, called from queue_enqueue_request -> snapshot_page_array, while its main thread waited. readable now asks K32QueryWorkingSetEx first, for all pages of a range of up to 16 pages in one call. When every page is valid in the working set with a readable protection (no PAGE_NOACCESS, no PAGE_GUARD, as the VirtualQuery walk judges Protect), the answer is yes. Any other page (never touched, paged out, guard, reserved, no access) falls back to the existing walk, so every answer is the same as before. The query touches no page: a guard page keeps its guard. Measured on the integration tree, with timing added only for the run: 524,288 calls, 524,281 answered from the working set, 494 ms in total, none of 20 ms or more. Both runs crashed in a loading pause before the world load, so the ~1M-call phase where the slow calls were measured was not reached; an unchanged build crashes there the same way. Assisted-by: Claude Code (Claude Opus 5.5)
|
Test report for Tested
Reviewed (read the whole diff)
Not tested
AI use
|
Contributor
|
Remove the overlap with #322 |
This was referenced Nov 24, 2026
ivall
added a commit
that referenced
this pull request
Nov 24, 2026
… Vaximous) gpu::shader::readable checked title pointers with VirtualQuery, which sizes the whole region around the address by walking it, so its cost follows the region, not the range. In a retail game's world load the page arrays of its DirectStorage requests (8-32 bytes, checked at enqueue and again at execute) live in a 2 GB block of committed memory: each check took 20-25 ms. readable now asks K32QueryWorkingSetEx about up to 16 pages first, in one call; only a page not valid in the working set falls back to the walk.
This was referenced Nov 24, 2026
Owner
|
Merged as a squash commit (a6f5f7a) with the game's name left out of the comment and the message - thanks! Checked on an RX 9070 (RDNA4) on main a6f5f7a, together with #335, #322, #331, #330, #338, #318 and #332: |
This was referenced Nov 24, 2026
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.
gpu::shader::readablechecks title pointers withVirtualQuery, which sizes the whole region around the address by walking it, so its cost follows the size of the region and not of the range asked about. In GTA VI's world load the page arrays of its DirectStorage requests (8–32 bytes, checked on enqueue insnapshot_page_arrayand again inexecute, #289) live in a 2259 MB block of committed memory: each check took 20–25 ms, oneVirtualQueryeach. Thread dumps taken while no frames were presented found the title's streaming thread inreadable→VirtualQuery, called fromqueue_enqueue_request→snapshot_page_array, while its main thread waited.readablenow first asksK32QueryWorkingSetExabout all pages of a range of up to 16 pages, in one call. If every page is valid in the working set with a readable protection (judged as the existing walk judgesProtect), the answer is yes. Any other page (never touched, paged out, guard, reserved, no access) falls back to the existing walk, so the answers are the same as before. The query touches no page: a guard page keeps its guard.Overlaps: #254 (open) removes the same
VirtualQuerycost inkernelx::committed_pageonly; it does not touchreadable. #232 decodes the title's watchdog, which fires when its threads stall.What is in it
Memory: readable answers a short range from the working set:resident_and_readableand its call inreadable, with the testreadable_answers_from_the_working_set_without_touching_pages(crates/xcl/src/gpu/shader.rs). The test covers written, never-touched, no-access, guard and reserved pages, ranges that cross into them, a long range that takes the walk, that a guard page is still a guard page after it was asked about, and that written pages are answered from the working set.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on aa1a1ec: 653 passed, 0 failed, 40 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.XCL_PRESS_A_AT), with timing aroundreadableadded for the runs only:readablecalls of 20 ms or more, about 10.2 s in total; time inreadable366 ms over the first 524k calls, 14.1 s by 1.05M calls.Regression run
scripts/smoke.ps1 -Game <GTA VI> -Seconds 60, no input, release builds; main at 4017f8f (this branch's base). Thegpu:line is the first adapter the script found; the title ran on the RTX 4070 Ti. The PC was in use for other work during both runs.main:
this PR:
Not tested
XCL_PRESS_A_AT=14,17,21,40,60,66,72, 240 s), main and this branch both crash at about 120–128 s with a write fault atgame_scarlett_master.exe+0x13936, before the phase where the slow calls were measured; whole-run DirectStorage requests were 45,718 (main) and 46,184 (this branch).AI use