D3D12.X: count Wait32/64BitValueX waits made on the CPU, by reason #3323
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3323"
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?
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-29T08:12:52Z.
Requested by Prime
Only a 64-bit,
GREATER_EQUAL, full-mask wait on an address a list wrote withWrite64BitValuebecomes a GPUqueue.Wait; every otherWait32/64BitValueXthe memory does not yet hold blocks the submitting thread (up toXCL_WAIT_TIMEOUT_MS). Which kinds a title makes, and how long they hold the submit threads, decides which ones are worth moving to the GPU, and nothing measured it:XCL_STALL_TRACElumps these waits together with the CPU-write waits.Each CPU wait is now counted by the first reason
try_gpu_waitrefuses it (32-bit, not>=, masked,>= 0, untracked address, not monotonic, not recorded yet, other) with its time. At most every 10 s, and only after a CPU wait, one info line gives the counts, the times and the waits that went to the GPU. The cost is two clock reads and a sync-graph lookup on a path that then blocks anyway.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:CpuWaitWhy,cpu_wait_why, the counters andnote_cpu_wait/cpu_wait_report(theD3D12.X: memory waits on the CPU in the last N sline), called fromwait_all_on_noting_cpu; testsa_cpu_wait_is_counted_by_why_the_gpu_did_not_take_itandthe_cpu_wait_report_names_only_the_kinds_that_happenedTested
cargo test --workspace --no-fail-fast -- --test-threads=4with the threeuma_drivertests below skipped, on60ee4e9948: 2607 passed, 0 failed, 49 ignored (SKIPPED GPU tests: 28 lines: 21no wave64(this card runs wave32), 3 a wave32 per-lane form refused by the translator (#1426), 2no heap windows(opt-inXCL_HEAP_WINDOWS=1), 1no dxc.exe, 1cannot disable the driver cache(needs Windows Developer Mode))cargo test -p xcl --lib -- --test-threads=1 uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window): 3 passed, 0 failed. They are left out of the whole run because on this PC's driver they can end the library test process (exit 0x7c10003, "coherent window could not be restored"), onmaintoocargo test -p xcl --lib -- --test-threads=4, same skips): 2468 passed, 0 failed; 2468 passed, 0 failedmainfa204595a4: 2605 passed, 0 failed, 49 ignored, 28SKIPPEDlines (own-prs-20261129 run, same command)scripts/smoke.ps1, no input, copied profile and shader cache): blocks belowRegression run
Not tested
AI use
Optional temporary Discord for coordinating contributor work, testing and comparing results.
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T08:23:11Z.
Exercised the production reporting interval at
60ee4e99on RTX 5070 / driver 616.92. Two otherwise identical 32-bit full-mask greater-or-equal waits resolved to 91. An independent D3D12 marker after the producer queue's write-fence signal distinguished their causes:I released the respective gate after a deliberate 100 ms observation. Both CPU reads got 91, and repeating each already-satisfied wait added no counter. The actual log line was:
The line measures which wait forms fell back and their accumulated polling time. Here its one bucket combined an already-complete producer with a genuinely pending one. Likewise, "on the GPU: 0" counted zero waits routed to queue.Wait; it cannot establish that both GPU producers were ready. For a world trace, correlating wait entry with a known producer's queue/fence completion and subsequent CPU-cell publication would distinguish the two costs. The measured duration is synthetic and excludes setup before
wait_until_satisfied.The fixture used native queues, production deferred writes, and
wait_all_on_noting_cpuwith a constructed PendingWait. Guest list decoding and retail execution were outside this test.AI disclosure: OpenAI Codex built and ran the fixture and drafted this report.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:09:04Z.
Ran the CPU-wait accounting tests at
60ee4e99on an NVIDIA Blackwell desktop part.System
Results
XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it -- --test-threads=1: 1 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_cpu_wait_report_names_only_the_kinds_that_happened -- --test-threads=1: 1 passed, 0 failed, 0 ignored.What this adds
Both new tests pass: each CPU wait is counted by the first reason the GPU did not take it, and the periodic report names only the kinds that happened. The thread has a note about the reporting interval on an RTX 5070; this adds a 5070 Ti datapoint on driver 32.0.16.2140. These are CPU-side accounting tests, not a title's wait-time measurement.
Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T14:44:39Z.
I tried a narrow opt-in follow-up on
60ee4e99for the attribution gap above.XCL_WAIT_PRODUCER_STATS=1samples the producer fence at entry to a blocking 32-bit wait, when there is exactly one overlapping tracked deferred DWORD store whose value satisfies the wait. It preserves the existing wait behavior and keeps the new registry off the default path.On RTX 5070 / 616.92 and Ryzen 7 5700X3D, the production report showed one pending fence and one complete fence, matching an independent native marker. Both waits returned
91. Two fresh-process controls (a host-only store and two overlapping deferred stores) both reportedUnknownin the classifier and returned91. A repeated already-satisfied wait remained on the fast path. With the switch unset, the paired native run had its original report and no extra diagnostic line. Four stockcpu_wait_tests passed. Across the four fixture invocations and that filter, 8 tests passed with zero skips.The new line reports state samples, not an elapsed-time breakdown or proof of the sole producer. Wider writes, multiple overlaps, publication already in progress and registry overflow all fall back to unknown. The registry is capped at 64 jobs with at most 64 write records per job. The fixtures used synthetic writes and native queues. Retail timing, overhead under sustained capture, and address aliases are unmeasured.
Two-file prototype (apply-checked on
60ee4e99)AI disclosure: OpenAI Codex (GPT-6.2 Sol) implemented and tested the optional probe using the saved Codex/Astra fixtures and drafted this report.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:29Z.
Review: COMMENTED
Static review of
60ee4e99for the stack in the #3041 comparison.The new counters can misclassify waits.
GpuWaitOutcome::Handledalso covers waits released on the CPU and waits satisfied by a fence recheck. Both increment the GPU-wait counter. The CPU refusal reason is inferred from a second sync-graph lookup, so a concurrent producer can change the state used to label the refusal. Carrying the outcome and refusal reason from the original attempt would make the counts match the decisions. Counter and classificationReview assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:43:30Z.
Review: COMMENTED
Critical review of current head
60ee4e99. The new telemetry can misattribute waits.GpuWaitOutcome::Handledincludes cases resolved on the CPU or by a fence recheck, yet incrementsGPU_WAITS; the CPU refusal reason is reconstructed from a later sync-graph read and can change under concurrent writes. That makes the displayed GPU/CPU split unsuitable for deciding which waits to move. Return the actual route/reason fromtry_gpu_waitand count that immutable outcome, with a test for CPU-resolvedHandledand a concurrent producer. See the earlier source review. No local Windows run.Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T02:49:04Z.
merge-check
base:
cb8024684chead:
60ee4e9948merge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2811 passed, 1 failed, 51 ignored; SKIPPED: 27 lines (22
no wave64, 3 f16/f32 per-lane cases refused, 2no heap windows), the same as on the base; failing:hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails the same way on the base (it came in with #2369; #3474 fixes it). Base alone on this PC: 2809 passed, 1 failed, 51 ignored.review: whole diff read (+161/-0,
list_x.rs). Diagnostic only: the wait itself, its timeout and its loop are unchanged, and theSYNC_GRAPHlock taken to classify a CPU wait is released before the wait starts. Two notes for the author, neither a blocker. The report line has no switch:note_cpu_waitlogs at most one info line per 10 s whenever a wait fell back to the CPU, as the description says, where the other wait diagnostics here sit behindXCL_SYNC_TRACEorXCL_STALL_TRACE. AndGPU_WAITScounts every waittry_gpu_waitreports asHandled, so "on the GPU" in the line is wider than waits that went toqueue.Wait. The two new tests cover the pure functions (cpu_wait_why,cpu_wait_report) and touch no statics; the counting at the call site has no test. No open PR does the same (searched the titles).performance: no cost per draw. A wait handled without the CPU adds one relaxed atomic add; a wait that falls back to the CPU adds one mutex lookup, two clock reads and two atomic adds before it blocks anyway. Measured with
scripts/smoke.ps1, 60 s of a retail title, release: 1683 frames and 16059 MB peak commit against 1662 and 1684 frames, 16196 and 15752 MB on the base (run before and after). No device removal, no crash.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source)
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-30T16:03:15Z.
Test report for #3323 at
60ee4e99489e47ef497379ccd48b453ac7f8f33e, against its merge-base withmain,fa204595, under Wine on AMD.Tested
experimental-11.0-20261112, stock vkd3d-protonmaster71cae091. Debug build,x86_64-pc-windows-gnu, under Wine. It wasn't run on Windows.cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- <filter>.--test-threads=1 <name>): both pass:a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it,the_cpu_wait_report_names_only_the_kinds_that_happened. 2 passed, 0 failed.--test-threads=2, with--skip gpu::and these six:failed_restore_stops_before_importing_an_unbacked_window,grooming_leaves_a_window_under_1_gib_only_its_hole(both run out of memory here),write_buffer_immediate_on_open_existing_heap_visible_to_cpu,coherent_buffer_sanitizes_console_flags_and_state,serialize_root_signature_strips_console_flags_and_preserves_pc_flagsandexecute_indirect_reads_the_arguments_written_before_it. Under Wine each of the last four ends the process or makes RADV reject later submissions (#3067), so without them the suite reaches its summary:60ee4e99: 1502 passed, 112 failed, 5 ignoredfa204595: 1500 passed, 112 failed, 5 ignoredmain's known ones on stock vkd3d-proton: list creation refused (E_INVALIDARG, #175 / #1701) and the tests after it (#3067).Not tested
gpu::tests in the suite runs-p xcl --lib)AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T20:20:03Z.
merge-check claim
head:
60ee4e9948Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:47:00Z.
merge-check
base:
d0832e614fhead:
60ee4e9948merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (list_x.rs, +161). Counting is always on: each wait handled on the GPU adds a relaxed atomic add (~3620); each CPU fallback adds a SYNC_GRAPH lookup, two clock reads and two adds before it blocks anyway (~3625-3633), with one info line at most every 10 s, only when the CPU waited. Findings: (1)
GPU_WAITScounts everyHandledresult, including waits already released on the CPU (~3481, ~3517) and waits whose memory held the value after the fence check (~3521-3525), so "on the GPU" is wider than the waits that went toqueue.Wait. (2) The reason is guessed after the fact:cpu_wait_why(~3375-3391) repeatstry_gpu_wait's checks and reads the sync graph again after the refusal, so a Write64 recorded in between can turn "not recorded" into "other", a device mismatch (~3514) or a queue without device/type (~3462) ends up as "other" or a cell-based reason, and the two copies can drift. Havingtry_gpu_waitreturn the refusal reason fixes both and saves the extra lock. (3) A wait that times out and stops the process (~3681) never reports its last window. (4) The tests cover only the pure functions, not the counting at the call site. Fine: the wait, its timeout and loop are unchanged, the lock is released before blocking, and the CAS-gated report is right.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (ea8d77b4): 1516 -> 1673 frames shown (110 %; last presents per 2 s: 60 60 61), peak commit 18133 -> 17504 MB, 0 device removals, 0 crashes. The counters add one relaxed atomic per GPU-handled wait; no cost visible here.verdict: safe to merge (diagnostics only; having try_gpu_wait return the refusal reason would make the counts exact)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T11:47:59Z.
merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.
AI use: an agent posted this withdrawal.