D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync #2416
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!2416
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2416"
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?
@KOLESNiii on GitHub · 2026-11-25 18:10 UTC · original
KOLESNiii:d3d12x-mirror-sync-activity→main· +135 −2 · 2 files · 1 commits · openOnce any buffer mirror exists,
list_x::sync_title_buffersruns on every draw, and nothing reported what it costs. WithXCL_ACTIVITY=1it now logs one line every 2 s in which it ran. This is diagnostics only, with no change in behaviour, and withoutXCL_ACTIVITYthe sync takes no time stamps and touches no counter, so the other parts of #2389 have before and after numbers.Fixes #2391. Part of #2389.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: counters for draws synced and those with a mirror, copies (whole buffers), bytes copied, indices scanned,readable()calls (those over 16 pages), the time inreadable()and its slowest call, and the time in the function. The old body is nowsync_mirrors, unchanged apart from the counters.sync_title_buffersstill returns first when no mirror exists.XCL_ACTIVITYis set:host_maincallsenable_sync_activity()before it starts the activity thread; until thensync_title_buffers,sync_readable()andsync_count()only check one relaxedAtomicBool(noInstant::now(), no shared atomics).crates/xcl/src/host.rs: thebuffer mirrors (2 s): …line in theXCL_ACTIVITYthread, printed whenever any of its counters moved (list_x::sync_row_due), also with no draw synced: the counters of a sync still running at the sample, or stalled for over 2 s, land before its draw is counted, and its slowestreadable()would otherwise be dropped with the skipped row.readable()call. The measurement on #2389 found single calls of 16 pages or fewer taking 1–9 ms, which the totals average away.Tested
cargo test --workspace -- --test-threads=4on49f0474: 1425 passed, 0 failed, 46 ignored; 25 SKIPPED (21no wave64, 3 refused #1426 forms, 1no heap windows, as onmain).list_x::tests::the_mirror_sync_counts_only_once_xcl_activity_enables_it: with the counters off,sync_readable()/sync_count()leave every counter and the slowest time at their values; afterenable_sync_activity()they count.list_x::tests::a_mirror_sync_row_with_no_finished_draw_is_still_logged: a row withreadable()work or a slowest time but no draw synced is due, as is one with only a draw.Regression run
main:This PR:
Not tested
AI use
🤖 Generated with Claude Code
@emirduran707 on GitHub · 2026-11-25 19:27 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
b52e97f619cce2afbe09ad9715490dcee30e4e1c(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1273 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
XCL_ACTIVITY=1log output; D3D12 debug layer; Intel GPUs.AI use
@DavidM1911 on GitHub · 2026-11-25 19:30 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@thehollowedone on GitHub · 2026-11-25 20:24 UTC · original
Independent Windows/NVIDIA test on #2416 head
b52e97f(clean detached worktree):cargo build --offline --locked --workspace, thencargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4passed: 1,275 passed, 0 failed, 46 ignored across 23 test binaries. The log also had 26 explicitSKIPPEDnotices: 21 no wave64, three unsupported per-lane #1426 forms, one driver-cache-disable test needing Windows Developer Mode/SDK support, and one no heap windows. GPU tests that did not skip ran on the RTX 3080 Ti.Setup: Windows 11 build 26300; RTX 3080 Ti 12 GB, driver 621.35; Ryzen 7 9800X3D, 32 GB RAM; Rust 1.99.1; DXC 1.8.2502.11 from Windows SDK 10.0.26100.0.
XCL_NETWORK=0,XCL_ADAPTER=RTX 3080 Ti, andXCL_DXC_DIRpointed to that SDK's x64 bin directory. The firstcargo testinvocation had two launcher e2e failures because it precededcargo build --workspaceand the standalone test-title binaries were absent; the complete rerun after the build passed.Not tested: the new
XCL_ACTIVITY=1buffer-mirror log line (the suite did not establish that a draw created a mirror), retail smoke, or an AMD GPU. This is an independent suite check, not a claim that the new counters were exercised.AI-assisted: Codex (GPT-6, exact variant unavailable) inspected the diff, ran the build and tests, checked the counts, and drafted this report.
@KOLESNiii on GitHub · 2026-11-25 22:15 UTC · original
Thanks, agreed:
XCL_ACTIVITYonly gated the logging thread. Fixed in 15f4019 (squashed into the PR's commit):host_maincallslist_x::enable_sync_activity()before it starts the activity thread. Until thensync_title_buffers,sync_readable()andsync_count()check one relaxedAtomicBooland go straight to the untimed path: noInstant::now(), no shared atomics.the_mirror_sync_counts_only_once_xcl_activity_enables_it: with the counters off,sync_readable()/sync_count()leave every counter and the slowest time unchanged. Afterenable_sync_activity()they count.cargo test --workspace -- --test-threads=4on 15f4019 (RTX 2070 SUPER): 1276 passed, 0 failed, 46 ignored, 25 SKIPPED. New smoke block in the description.As you said, the retail smoke run makes no mirrors, so it does not reach these counters (this is under Not tested). I did not measure the off path separately.
(Claude Code, Claude Opus 5.5)
@DavidM1911 on GitHub · 2026-11-26 02:22 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@bmjask on GitHub · 2026-11-25 20:43 UTC · original · reviewed
P2: instrumentation is active regardless of XCL_ACTIVITY. sync_title_buffers always creates an Instant and updates atomics once mirrors exist; sync_readable always times/updates several atomics and each copy adds more. XCL_ACTIVITY only gates the logging thread, so normal users pay timing and shared-atomic contention on the per-draw mirror path despite the diagnostics-only/no-behavior-change claim. Gate all accounting behind an enabled fast path, then measure/test overhead-off. Current head also has no visible Windows Build/test and the smoke did not execute these counters.
@luckyteagirl on GitHub · 2026-11-26 08:04 UTC · original · reviewed
At head
fdbb6fe7ec0027a5b0274364475f0204684a8c5e, a mirror sync can cross the 2-second reporting boundary after areadable()call finishes but before the draw finishes.sync_readablepublishes its count/time and updatesSYNC_READABLE_MAX_NSduringsync_mirrors, whileSYNC_DRAWSis incremented only aftersync_mirrorsreturns (list_x.rs:3774-3795). If the host samples in that gap,s[0] == 0, sohost.rs:65-75suppresses the row but still advanceslast_syncand resets the slowest value. The next row counts the completed draw without that readable work or its maximum. This can hide an isolated slow call, which this diagnostic is intended to show. Could the host emit a row whenever any mirror statistic is nonzero (including zero completed draws), or publish the per-draw values together after completion if rows must represent completed draws?This is a source-derived diagnostics review, not a timed native reproduction. AI use: OpenAI Codex (GPT-6.2 Sol) traced the reporting path; I checked the exact-head counter and snapshot order before posting.
fdbb6fe7ecto49f0474926@KOLESNiii on GitHub · 2026-11-26 11:24 UTC · original
Thanks, confirmed: with no draw's sync finished in a window, the row was skipped while
take_sync_slowest()had already reset the slowestreadable(), so a stalled sync lost exactly the number this is for.Fixed in
49f0474(amended into the commit) the first way you suggested:host.rslogs the row whenever any mirror counter or the slowest time moved (list_x::sync_row_due), including with 0 draws synced, which then reads as a sync still running at the sample or stalled. I kept the counters published as they happen rather than at the end of the draw, so a sync that never returns still shows up. New test:a_mirror_sync_row_with_no_finished_draw_is_still_logged. The full suite and the smoke run were redone on49f0474(counts and block in the description).AI use: Claude Code (Claude Opus 5.5) checked the review against the code, wrote the fix and ran the tests; I reviewed it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.