D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync #2406
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T18:10:38Z.
Once 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
c6562a0c(rebased ontomain765b2c5bto resolve conflicts): the suite has not been rerun on it; the counts below are from the earlier heads they name.main336fdddaon 2026-11-28.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on68227880: 2124 passed, 9 failed, 48 ignored; 25 SKIPPED (21no wave64, 3 refused #1426 forms, 1no heap windows). The 9 failures are #3093's, the same 9 tests that fail onmain336fddda(2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase.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
Current head
c6562a0c, rebased ontomain765b2c5bon 2026-11-28 to resolve conflicts withmain. RTX 2070 SUPER, the retail game, 60 s,XCL_PRESS_AT=25:A,XCL_PREPARE=0(no startup shader preparation), release builds; each run started from a copy of the same DXIL cache (one queue job:main, then PR heads one after the other).main:This PR's head:
Not tested
XCL_PREPARE=0): shaders are built when the title first uses them, onmainand on this PR alike.AI use
main336fddda, ran the suite and the regression runs and updated this description.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T19:27:32Z.
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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:30:14Z.
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!
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:43:14Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T20:24:28Z.
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.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T22:15:17Z.
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)
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:22:14Z.
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
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T08:04:38Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T11:24:54Z.
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:00:05Z.
Triage (#1607) – head
c6562a0#2437 and #2533 are stacked on this PR: both contain this commit (
c6562a0) and add their own changes to the mirror sync on top. That makes this the base of the stack, not a duplicate. Main has none of these counters (sync_title_buffersis unchanged there). WithoutXCL_ACTIVITYthe sync only does one extra relaxed load per draw. No problems found in the diff. It conflicts with main's list_x.rs and needs a rebase.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T14:14:59Z.
Thanks for the triage. Rebased onto
maindf0cfef6: thelist_x.rsconflict wasmain's newresolve_query_data_x_notes_exact_result_bytes_for_all_query_typestest next to this PR's two tests, and I kept both. New headccc2763b. The suite and the smoke run are queued again on it; the description will get the new counts and blocks once they are in.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:18:40Z.
Follow-up review (head
ccc2763b, sincec6562a0, diff read, not a merge-check; checks red):git range-diff/ patch-id); this push only rebases onto the currentmain.New: none.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.