Memory: readable answers a short range from the working set #332
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!332
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/332/head"
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?
@Vaximous on GitHub · 2026-11-23 23:35 UTC · original
Vaximous:shader-readable-working-set→main· +76 −0 · 1 files · 1 commits · closed without merginggpu::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 the retail title'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=4onaa1a1ec: 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 <game folder> -Seconds 60, no input, release builds; main at4017f8f(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
@throny on GitHub · 2026-11-24 00:01 UTC · original
Test report for
aa1a1ec, merged onto currentmain2b4bb43(clean merge, merge commit5128f81): pass.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace && cargo test --workspace -- --test-threads=4: 671 passed, 0 failed, 41 ignored (lib: 631 / 0 / 21,readable_answers_from_the_working_set_without_touching_pagesok)SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)readabledisabled (if false && resident_and_readable(..)),gpu::shader::testsstill pass (4/4). So everyreadableanswer in the new test is the same with and without the fast path, which is what the description claims. It also means only the directresident_and_readableasserts check the fast path; no test fails ifreadablestops calling it.Reviewed (read the whole diff)
PSAPI_WORKING_SET_EX_BLOCK: bit 0Valid, bits 4–14Win32Protection, as the code reads them. Valid is checked first, and the protection test is the same one theVirtualQuerywalk applies (!= 0, noPAGE_NOACCESS/PAGE_GUARD).p != 0,len != 0and the overflow check run beforeresident_and_readable, soend - 1cannot underflow.VirtualQuerycost on the same path (snapshot_page_arrayand the file vtable check) by not callingreadablethere. The two do not conflict textually, but each makes part of the other's measured gain moot.Not tested
scripts/smoke.ps1) on a title, noXCL_SAMPLE_*game-data tests.AI use
@Cattn on GitHub · 2026-11-24 00:02 UTC · original
Remove the overlap with #322
@ivall on GitHub · 2026-11-24 00:03 UTC · original
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 maina6f5f7a, together with #335, #322, #331, #330, #338, #318 and #332:cargo test --workspace -- --test-threads=4- 636 unit tests passed, 0 failed; the retail game reaches its menu and draws it (frame dump) and goes on past it.Pull request closed