d3d12 gpu: VirtualQuery walks the write watch stood behind while walking (D3D12-HWRT-REGION-WALK-STALLS) #3410
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u"d3d12-hwrt-region-walk-stalls:Rockcabbage-d3d12-hwrt-region-walk-stalls" git switch "Rockcabbage-d3d12-hwrt-region-walk-stalls"
Open
leonida/mandy
Rockcabbage
wants to merge 5 commits from
Rockcabbage/mandy:d3d12-hwrt-region-walk-stalls into main
pull from: Rockcabbage/mandy:d3d12-hwrt-region-walk-stalls
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3410
Loading…
Reference in a new issue
No description provided.
Delete branch "Rockcabbage/mandy:d3d12-hwrt-region-walk-stalls"
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?
This branch is out-of-date with the base branch
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Claimed in the coordination issue as:
D3D12-HWRT-REGION-WALK-STALLS(claimed in #2570,done: ... -> #3113there; #3312 continues that issue)This carries on #3113. That pull request came over in the migration with its author shown as a placeholder, so its
branch cannot be updated from here. Its head (
5ce6907bd) has the same change as this one, but it is based on the mainfrom before the move. This branch is the same change as one commit on current
main, with one follow-up from asecond review (below). If this one is taken, #3113 can be closed in its favour.
mainat312d88d1d.d3d12-hwrt-region-walk-stallsat3889530c7.What and why
Two callers of
VirtualQueryheld up frames while walking with hardware ray tracing on.VirtualQueryanswers withthe length of the run of pages in the same state. To find it, it walks the page tables to the run's end; this is what
texture::by_queryalready says of the textures' pass. In the title's pools that is 21-36 ms a question, and thesubmitting thread's
GetWriteWatchstands behind the walk for as long.hwrt.rs:readable_len/title_readableare asked for each geometry of a batch of bottom-level builds. Theywalked twice in a row, 47-48 ms for the batch. They now ask page by page through
texture::readable_bytes(
QueryWorkingSetEx, 256 pages a call).LEONIDA_HW_RT_REGION_QUERY=1asksVirtualQueryas before, andLEONIDA_ABcan switch it.texture::readablenow leaves a working-set page that isPAGE_NOACCESSor a guard tothe one-byte read, so the page-wise answer refuses what the walk refused.
copystat.rs(diagnostics only): the frame meter's five-second lines askedVirtualQueryonly for the kind ofmemory of the ten ranges most copied from, one walk of 24-28 ms each time. They now ask about the one page
(
texture::shared, compiled with diagnostics or tests only). The line saysshareable memory/private or untouched memorywhere it gave the type's number.d3d12/docs/findings.md: a section with the measurements below.d3d12/docs/switches.mdis regenerated withtools/d3d12_switches.py.A committed page that is not resident is read one byte to learn whether it is there, so it is faulted in. The BLAS
build reads those bytes right after the question, so that fault is paid either way.
texture::committedmakes thesame trade for the textures' pass.
Measured
These measurements were taken before the move, on the earlier head (the same diff on the main of that time). They were
not taken again on this base.
The setup:
-HardwareRT -NoFrameGen, diag build.LEONIDA_KEYS).LEONIDA_TIMELINE).LEONIDA_AB=5,LEONIDA_HW_RT_REGION_QUERY), over two runs.hwrt.rsVirtualQuery(switch on)GetWriteWatchis 22-47 ms (0.2-2 ms in theothers), and the frames are 50-65 ms among frames of 40-50.
while walking does not move. This removes the frames that stood out above it.
walk does not repeat exactly.
7,510 frames in the world.
Tested
On this branch, rebuilt on
main312d88d1d:cargo check -p leonida-gpu, with and without--features diagnostics: no warnings on this change's lines. Thediagnostics build has one warning, in
book.rs; it is onmaintoo.cargo test -p leonida-gpu --lib --locked: 731 passed, 0 failed, 59 ignored. With--features diagnostics: 812 passed, 0 failed, 59 ignored.hwrt::tests::title_memory_is_asked_about_page_by_pagecovers committed, read-only, closed and uncommitted pages,a range across them, a wrapping length, and that
VirtualQuerywas not asked.texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping.readable_lensent back to the walk, the first test fails at "VirtualQuery asked" (9 walks against 0).texture::sharedanswering as the old code could not (alwaysSome(false)), the second test fails on themapping (
Some(false)againstSome(true)).mainneither test builds, because the functions and the count of walks are new.texture::readablenow checks: Windows takes a page out of theworking set as it closes it, so the one-byte read refuses that page with or without the check. Reverting the check
leaves the test green. It is kept as a guard, and the test's comment says so.
python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: passes.python -I tests/test_d3d12_switches.py: 22 OK.python -I scripts/check_no_game_data.pyon the changed files: exit 0.GPUs tested: NVIDIA GeForce RTX 4090, driver 621.24, Windows 11 (CPU: Intel i9-13900K)
AI-assisted: yes. Claude Code; Claude Fable 5.2 directing, Claude Opus 5.5 writing and reviewing.
commit: a third walk left on the default path, the protection of working-set pages, a dead-code warning, the
shared count of walks, and timings.
were exercised. That comment is corrected in the follow-up commit.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
In-game run report, head
3889530c7(onmain312d88d1d)-HardwareRT -NoFrameGen, diag build (diagnostics,dlss,mimalloc),LEONIDA_WINDOWS_BAR_MB=8192.LEONIDA_HW_RT_REGION_QUERYnot set, so the page-by-page path of this pull request ran.LEONIDA_KEYS_FILE).shader translated,host mesh pipelinelines inside the frame); that ismain's behaviour and not this change. I did not go through the other 33 one by one.Not measured again on this base: the by-turns count of walks in the description. That table is from the earlier head.
AI-assisted: yes (Claude Code; the run was started and its log and pictures read by Claude Fable 5.2).
Follow-up to the run report: a second run of the same build lost the device
I ran the same exe (built at
3889530c7; the head is nowe9670aede, a merge ofmainthat touches only the progress dashboard) a second time, same settings and walk, as a control for something else. This one must be on record too:0x887A0005, "The GPU device instance has been suspended", no device-removed data. No panic. The submitting thread was preparing a submission of 2 lists; BLAS memory 536 MB live of a 1536 MB budget, 0 evicted.mainwith-HardwareRTon this card has lost the device before without this change (the late-read BLAS transforms discussed in #3297, whose fix is not inmain), and the earlier head of this change ran 440 s clean before the move. But that is not shown for this run: the log names no command (noLEONIDA_D3D12_DEBUG=1).main528614662itself and this head again, each withLEONIDA_D3D12_DEBUG=1, and report both here.AI-assisted: yes (Claude Code, Claude Fable 5.2).
The two runs promised above, each with
LEONIDA_D3D12_DEBUG=1Same PC, settings and scripted walk, 440 s each.
main5286146623889530c7)main(with it). That is too few runs to saymainis free of it or that this change is.-HardwareRT, so that ismain's picture and not this change's.If a maintainer wants more before a decision, tell me how many clean runs without the debug layer would count, and I will run
mainand this head in turn that many times.AI-assisted: yes (Claude Code, Claude Fable 5.2).
A second read-only review of this branch (Claude Opus 5.5), and what changed for it. The head is now
83e33b76d, withmaina9361504amerged in; the hashes in the description are older.What the review checked
VirtualQuerywalk case by case: committed but not resident, reserved,PAGE_NOACCESSor guard pages, ranges across regions, a last partial page, wrapping lengths. It found no input where a BLAS build gets bytes the walk refused, or a different length.Changed (
1b7b5a29a)readable_lenandreadable_len_by_querythe same question in 14 cases, and they must agree. Before, the old function passed every value assertion too. Red: withreadable_bytescounting the last page whatever it is, the new assertion fails (0x2001 bytes: 8193 against 8192). Restored, it passes.cargo test -p leonida-gpu --lib --lockedon the merged head: 739 passed, 0 failed, 60 ignored.A correction to the description
"That fault is paid either way" is too strong. The page-wise answer reads one byte of each page not in the working set, which brings it in on the submitting thread. That is paid either way only for pages the BLAS build then reads, not for the rest of the 256 KiB vertex-index window that
decode_title_meshlet_ibasks about (up to 66 pages brought in for the question alone). A guard page met in a range is touched and then guarded again by the fault handler. The comment onreadable_lenand the findings section now say this. It is the side effect already noted on #3113.Also
texture::readableis only a safeguard: Windows keeps such a page out of the working set, so no test reaches it. Its comment says so now. I can take it out if you would rather not carry it.findings.md, so whichever lands second needs a merge there.🤖 Generated with Claude Code
Local validation of head
83e33b76da754170feef54669967e722b33eecb6applied to main6491bc1a15bf8b1f2ed817ac3e78e8ee6d9899ef, on NVIDIA RTX 3090 24 GiB, driver 610.88, Windows 11, Ryzen 9 5900X, 32 GiB RAM. Both optimized binaries were freshly built with Rust 1.98.1 anddiagnostics,dlss,mimalloc.Both legs failed to reach the stock driver's control/teleport transition: no CONTROL, teleport, location marks or native action commands were observed, and no action response log appeared. This supports world stability and HWRT activation only, with no busy-location, image-quality or performance result. The same coverage gap on main does not establish its cause. The earlier RTX 4090 non-debug device loss remains unexplained by these clean RTX 3090 diagnostics-feature runs; these did not enable the D3D12 debug layer.
AI-assisted validation: GPT-6.1 Sol, xhigh. Independent read-only review: GPT-6.1 Sol (xhigh), source/call paths and frozen test, build and runtime evidence; the reviewer executed no new tests.