D3D12.X: instrument submitting-thread call breakdown under XCL_LOOK_STATS=2 #2729
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!2729
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2729"
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?
@Decodere on GitHub · 2026-11-26 09:03 UTC · original
Decodere:ws8-part1-submitter-api-cost-breakdown→nvidia-dev· +400 −39 · 6 files · 1 commits · openTargets
nvidia-dev(af2cecc408). AddsXCL_LOOK_STATS=2-only submitting-thread and recording-path instrumentation toapi_costso CPU-bound frames on 8 GB GPUs can be broken down into non-overlapping completed top-level call durations per 2 s sample window. Zero behavior change and zero timer/atomic overhead whenXCL_LOOK_STATS != 2.Part of #2688
What is in it
crates/xcl/src/hle/api_cost.rs: accumulate durations internally in nanoseconds (exposing microseconds fromtotals()andsubmitter_totals()) so high-frequency sub-microsecond calls do not truncate to0 us; protectON_SUBMITTERentries with a single-writer seqlock (CounterPair) sosubmitter_totals()takes coherent(calls, us)snapshots; add#[inline] time_if(on, call)(no clock read, TLS lookup, or atomic write when disabled), 8XCL_LOOK_STATS=2-onlyCallvariants (DrawRecord,DispatchRecord,BindState,ViewDescriptor,ViewWant,ListBarrier,ListCopy,ListLifecycle),is_sub_call(excluding nestedPresentCopyWait,PipelineWait, andViewWantfrom top-level completed totals),all_threads_summary_parts,submitter_summary_line(now, before, window_ms)(accounting any nonzero count or duration delta and reporting; completed X ms (window Y ms)for calls completed since the prior sample without claiming an in-window untimed remainder), and 6 new/updated unit tests (sub_microsecond_calls_accumulate_without_truncation,time_if_disabled_adds_zero_counts_and_zero_time,submitter_summary_excludes_sub_calls_and_reports_completed_window,summary_retains_nonzero_duration_delta_when_count_delta_is_zero,submitter_counter_pair_snapshots_are_coherent_under_concurrent_writes,submitter_summary_describes_straddling_completed_call_without_untimed_claim).crates/xcl/src/host.rs: formatcalls (2 s, all threads)viaapi_cost::all_threads_summary_parts(retaining nonzero duration deltas even when count delta is 0), track the actual elapsedwindow_mson each periodic activity tick, and logapi_cost::submitter_summary_line(&spent, &own_cost, window_ms)whenXCL_LOOK_STATS=2is active.crates/xcl/src/hle/d3d12x/bind.rs: wiretime_if(deep(), ...)forDrawRecord(draw_instanced,draw_indexed_instanced,dispatch_mesh),DispatchRecord(dispatch), lazydeep().then(...)inexecute_indirect(sosignature_dispatches(sig)is never evaluated when disabled), andBindState(root-parameter, descriptor-table, and PSO bindings).crates/xcl/src/hle/d3d12x/list_x.rs: wiretime_if(deep(), ...)forDrawRecord,BindState(includingset_descriptor_heaps_x),ListBarrier,ListCopy, andListLifecycle; split outemit_uav_barrier_pc,reset_pc_inner, andcopy_buffer_region_innerso internal delegation paths (flush_cache_range_x/flush_pipeline_x,reset_stand_in,copy_resource_x) never double-count.crates/xcl/src/hle/d3d12x/real.rs: wireCall::FenceWaiton blockingSetEventOnCompletion(_, NULL)scoped to drop beforesettle_readbacks_try()soFenceSettlenever nests insideFenceWait; wireViewDescriptor(splittingdev_create_srv_inneranddev_create_uav_checked_innersodev_create_srv_at_xanddepth_uavtwins never double-count, and resolvingresource_atbefore startingViewDescriptorindev_create_srv_at_x/dev_create_uav_at_xsoCreatePlacedResourcenever nests insideViewDescriptor),BindState,ListCopy, andListLifecycle; guard all unconditional PC-vtable hooks (cl_close,cl_reset,alloc_reset,dev_create_rtv,cl_clear_rtv,cl_om_set_render_targets,fence_set_event_on_completion) with!title_textures::is_own_work() && !present::presenting()so XCL's own internal work and blit presents never double-count.crates/xcl/src/hle/d3d12x/view_want.rs: wiretime_if(deep(), Call::ViewWant)inwantafter theis_view(va)guard.Tested
rustc 1.100.0, DXC1.9.2609.5, debug and release.cargo test -p xcl --lib hle::api_cost::tests:: -- --test-threads=4 --nocapture(debug WARP):8 passed, 0 failed, 0 ignored(0 skipped).cargo test --release -p xcl --lib hle::api_cost::tests:: -- --test-threads=4 --nocapture(release RTX 4060):8 passed, 0 failed, 0 ignored(0 skipped). On unmodifiedorigin/nvidia-dev(af2cecc408,api_cost.rs:78),add()truncated each call withd.as_micros() as u64, soDuration::from_nanos(500)added0and failedsub_microsecond_calls_accumulate_without_truncation.cargo clippy --workspace --all-targets: 0 warnings and 0 errors across all 6 modified files (4 pre-existing clippy errors in untouchedlower_valu.rs,lower_wide.rs,lower.rs, andsparse.rs).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture(RTX 4060):1753 passed, 3 failed, 48 ignoredacross 39 test binaries + doc-tests (1626 passed, 0 failed, 28 ignoredinxcl --lib;30SKIPPEDlines: 21 wave64 on 32-lane RTX 4060, 3 per-lane form refused, 3 no D3D12 debug layer, 2XCL_HEAP_WINDOWSunset, 1 driver cache; plus sample-pack /xgameruntime.dllskips). All 3 failures (d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standin,gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs) are pre-existing on unmodifiedorigin/nvidia-dev(af2cecc408), verified on detachedaf2cecc408with the identical 3 failures.XCL_LOOK_STATS=2verification on RTX 4060 8 GB (XCL_LOOK_STATS=2,XCL_HEAP_WINDOWS=1,XCL_UMA_WINDOWS=16,XCL_DIRECT_DXIL=1,XCL_TEXTURE_SAFE_READ=1,XCL_WATCH_HOT_MS=60000, 60 sscripts/smoke.ps1ontitle: 29640639):1505frames (PresentX 1505),60 60 60presents per 2 s,0device removals,0crashes,15981 MBpeak commit. All 27calls of the submitting thread (2 s):windows reported; completed X ms (window Y ms)with 0untimedclaims, and 7 of 9 new categories fired live oncalls (2 s, all threads)::calls (2 s, all threads): 89 placed textures in 32 ms, 2 placed buffers in 0 ms, 4 physical page calls in 42 ms, 1 memory calls in 1 ms, 3 pipelines in 1 ms, 2 waits for pipelines being built in 7 ms, 56 ExecuteCommandLists in 98 ms, 27 presents in 35 ms, 27 waits of a present for the last frame's copy in 0 ms, 53 WaitFrameEventX in 719 ms, 82 draw recording in 8 ms, 504 state and root bindings in 2 ms, 181 view and descriptor calls in 1 ms, 143 barriers and flushes in 1 ms, 191 copies, clears, and memory ops in 2 ms, 154 list close and reset in 19 mscalls (2 s, all threads): 120 ExecuteCommandLists in 451 ms, 60 presents in 43 ms, 60 waits of a present for the last frame's copy in 0 ms, 120 WaitFrameEventX in 1500 ms, 1260 draw recording in 3 ms, 60 dispatch recording in 1 ms, 3900 state and root bindings in 3 ms, 120 view and descriptor calls in 0 ms, 360 barriers and flushes in 0 ms, 480 copies, clears, and memory ops in 3 ms, 540 list close and reset in 6 ms/calls of the submitting thread (2 s): 120 ExecuteCommandLists in 451 ms, 60 presents in 43 ms, 60 waits of a present for the last frame's copy in 0 ms, 120 WaitFrameEventX in 1500 ms; completed 1995 ms (window 2001 ms)Regression run
60 s
scripts/smoke.ps1runs on RTX 4060 with default flags (XCL_LOOK_STATSunset). Includesmain(b49be183, merge-base ofmainandnvidia-dev, same-day run on this hardware) forpr_check.py,nvidia-devbase (af2cecc408), and PRHEAD(93e66c19):main(b49be183, merge-base):nvidia-dev(af2cecc408, target base):PR
HEAD(93e66c19, default flags):Not tested
Call::FenceWait(blockingSetEventOnCompletion(_, NULL)) andCall::ViewWant(view_want::want), which had 0 calls during the 60 s smoke ontitle: 29640639(unit tests coverViewWantsub-call exclusion,FenceWaittorn-snapshot/straddling behavior, andtime_iftiming behavior).XCL_SAMPLE_RPF/XCL_SAMPLE_TTPF/XCL_SAMPLE_AWCunset) and D3D12 debug-layer tests (d3d12SDKLayers.dllnot installed).AI use
api_costnanosecond accumulation,CounterPairseqlock,XCL_LOOK_STATS=2submitting-thread instrumentation, and completed-call summary wording, wrote the unit tests and this description, and ran the unit tests, clippy, workspace tests, and retail smoke runs on the hardware above.@luckyteagirl on GitHub · 2026-11-26 09:38 UTC · original · reviewed
On
5465094,notepublishes a submitter call count and its duration in separate atomic writes, whilesubmitter_totalsreads them separately. An activity tick can snapshot(1 call, 0 µs)between the writes. The next tick then sees(1 call, 400000 µs)butsubmitter_summary_lineskips that category because the count delta is zero; the host still advances its baseline. That completed 400 ms call disappears from every newaccountedwindow, even though it remains in cumulative totals. Relaxed ordering makes this interleaving possible; stronger ordering on the two independent atomics alone would not make their snapshot coherent.Could the formatter account a nonzero duration delta independently of count, or take a coherent count/duration snapshot? A deterministic formatter/host fixture with snapshots
(0,0) → (1,0) → (1,400000)should retain the 400 ms in the second report. This is exact-head source review; I did not reproduce the race at runtime.@luckyteagirl on GitHub · 2026-11-26 09:39 UTC · original · reviewed
On
5465094, the newaccounted … of … (… untimed)line treats cumulative completed-call durations as time inside the last activity window. A call is added in full atTimer::drop. For example, a 2.5-second blocking fence wait spanning two 2-second samples adds zero to the first window and all 2500 ms to the second. That second report can sayaccounted 2500 ms of 2000 ms (0 ms untimed)even when no calls overlap, so the stated wall-clock remainder is misleading. This is separate from the count/duration snapshot race I reported earlier.Could the durations be split by overlap with the measurement window, or the line describe durations of calls completed since the prior sample without claiming an in-window untimed remainder? A synthetic call crossing a tick would make the chosen semantics testable. This is exact-head source review; I did not run a timing fixture.
@emirduran707 on GitHub · 2026-11-26 10:18 UTC · original
Independent AMD RDNA4 (native wave64) verification of exact PR head
546509487103c94e40d423b4e1d778cc54076741(base: nvidia-dev) on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1746 passed, 8 failed, 48 ignored(9 SKIPPED: 6 per-lane DXIL forms, 2no heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).hle::api_cost::tests::sub_microsecond_calls_accumulate_without_truncationhle::api_cost::tests::submitter_summary_excludes_sub_calls_from_accounted_and_computes_untimedhle::api_cost::tests::time_if_disabled_adds_zero_counts_and_zero_timeapi_cost(fuzz_validate_and_gpu_{1,3},texture_uploadx2,console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,async_compute_pso_registers_real_pso_and_not_standin,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs).cargo build --release -p xcl: passed (0errors).Not tested
scripts/smoke.ps1(thenvidia-devbranch started inline shader precompilation before printing the log path, sosmoke.ps1aborted early).XCL_LOOK_STATS=2output, NVIDIA / Intel GPUs, Linux / Wine.AI use
@MarcosMDev on GitHub · 2026-11-26 10:52 UTC · original
Test report:
5465094against its baseaf2ceccon an RTX 4060 (Windows): full suite, no new failure. No title was run.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4, debug, each commit in its own worktree and target folder:af2cecc: 1745 passed, 6 failed, 48 ignoredapi_costtests pass.I read the hook changes for the "no behavior change" claim. Each new guard only decides whether a timer starts; the hooks' own calls are unchanged.
deep()reads aOnceLock, so withXCL_LOOK_STATSunset each hook adds one branch. The two_innersplits keep the callers' arguments, and the depth-UAV twin now calls the inner function, so it isn't counted twice.RTX 4060 8 GB (driver 621.01), Ryzen 7 5700X, 24 GB, Windows 11 26200, rustc 1.100.0, DXC 1.9.2609.5.
Not tested: any title, so no
XCL_LOOK_STATS=2lines from a real run; overhead with it off; AMD.AI use: Claude Code (Claude Opus 5.5) ran the tests, read the diff and drafted this; I read it before posting.
5465094871to93e66c197c@Decodere on GitHub · 2026-11-26 11:29 UTC · original
Thanks for both reviews,
@luckyteagirl! Updated in93e66c19:ON_SUBMITTERentries with a single-writer seqlock (CounterPair, sinceSUBMITTERlatches at most one thread ID) sosubmitter_totals()returns coherent(calls, us)pairs, and updated bothsubmitter_summary_lineandall_threads_summary_parts(host.rs) to retain any category with a nonzero count or duration delta (dc > 0 || dus > 0). Added deterministic tests for both the(0, 0) -> (1, 0) -> (1, 400_000)fixture (summary_retains_nonzero_duration_delta_when_count_delta_is_zero) and concurrent seqlock coherence (submitter_counter_pair_snapshots_are_coherent_under_concurrent_writes).untimedremainder claim in favor of; completed {ms} ms (window {window_ms} ms)so durations of calls completed since the prior sample are reported honestly even when a long call straddles a 2 s tick, with a deterministic 2.5 s straddling-call test (submitter_summary_describes_straddling_completed_call_without_untimed_claim).Re-verified
hle::api_cost::tests::(8/8debug WARP and release RTX 4060), full release workspace (1753 passed, 3 pre-existing nvidia-dev failures), and 60 s RTX 4060 smokes (default+XCL_LOOK_STATS=2).@MarcosMDev on GitHub · 2026-11-26 11:52 UTC · original
Follow-up to my report, on the new head
93e66c1(same baseaf2cecc, same RTX 4060 and setup):api_costtests now in the PR pass, the concurrent seqlock one included.Not tested: any title, so no
XCL_LOOK_STATS=2lines from a real run; AMD.AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this; I read it before posting.
@Prime1997 on GitHub · 2026-11-26 12:46 UTC · original · reviewed
Good within the submitting-thread accounting scope. The current head keeps count/duration snapshots coherent and labels durations as completed-call time rather than claiming an untimed wall-clock remainder. The focused tests cover both earlier review cases, sub-microsecond accumulation, disabled instrumentation and thread separation.
Tested clean PR head
93e66c197c2737c2fa7cbb97645c367cf01b33eb, targeting currentnvidia-devaf2cecc40886a8682ecf3267f5328c6dc4b66ad7, in its own worktree and build directory. 8 passed, 0 failed, 0 ignored, 0 skipped. Each filter ran in a fresh process:hle::api_cost::tests::a_call_is_counted_with_its_timehle::api_cost::tests::the_submitting_thread_has_its_own_counthle::api_cost::tests::sub_microsecond_calls_accumulate_without_truncationhle::api_cost::tests::time_if_disabled_adds_zero_counts_and_zero_timehle::api_cost::tests::submitter_summary_excludes_sub_calls_and_reports_completed_windowhle::api_cost::tests::summary_retains_nonzero_duration_delta_when_count_delta_is_zerohle::api_cost::tests::submitter_counter_pair_snapshots_are_coherent_under_concurrent_writeshle::api_cost::tests::submitter_summary_describes_straddling_completed_call_without_untimed_claimBuild:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Execution:<test-exe> <each-exact-name-above> --exact --test-threads=1 --nocapture. Only private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug tests; no GPU calls in these selected fixtures.Not tested: No live XCL_LOOK_STATS=2 title output, instrumentation overhead, GPU behavior or full-suite run was measured. This supports retaining the PR; it is not whole-branch or merge certification.
AI use: Codex (GPT-6) reviewed source, ran the exact tests and checked the raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@throny on GitHub · 2026-11-26 14:23 UTC · original
Test report:
XCL_LOOK_STATS=2in the world on a 16 GB card. Here the submitting thread's time is inPresentX, not inExecuteCommandLists.Tested
93e66c1applied (git apply, as it is) onnvidia-devaf2cecc4+ #684 + #2697 + #2749. One run of the retail title of #505 into the world withXCL_LOOK_STATS=2: world from about 172 s, device removed (0x887a0005) at 607 s, as this card usually ends there.What it shows (the
calls of the submitting threadlines from 200 s on, 211 s of windows):PresentXExecuteCommandListsWaitFrameEventXN of N previous submits of lists submitted again were not done after 2000 ms – they go as they are130 times, so the GPU is behind by seconds per frame and the present is where the thread meets it.Not tested
AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report.
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.