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· +253 −22 · 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 accounted vs untimed milliseconds per 2 s 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 µs; 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-levelaccountedtotals),submitter_summary_line(window_ms)(reportingaccounted X ms of Y ms (Z ms untimed)), and 3 unit tests (sub_microsecond_calls_accumulate_without_truncation,time_if_disabled_adds_zero_counts_and_zero_time,submitter_summary_excludes_sub_calls_from_accounted_and_computes_untimed).crates/xcl/src/host.rs: track the actual elapsedwindow_mson each periodic activity tick and logapi_cost::submitter_summary_line(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:: --nocapture(debug WARP):5 passed, 0 failed, 0 ignored(0 skipped).cargo test --release -p xcl --lib -- hle::api_cost::tests:: --nocapture(release RTX 4060):5 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(0 µsvs expected>= 500 µs).cargo clippy --all-targets: 0 new warnings across all 6 modified files.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture(RTX 4060):1750 passed, 3 failed, 48 ignoredacross 39 test binaries + doc-tests (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 by rerunning those 3 targets with--test-threads=1on 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):1550frames (PresentX 1550),60 60 60presents per 2 s,0device removals,0crashes,15519 MBpeak commit. All 27calls of the submitting thread (2 s):windows satisfiedaccounted <= window_ms(0over-window, steady state1996-1997 msaccounted of2001 ms,4-5 ms untimed), and 7 of 9 new categories fired live oncalls (2 s, all threads):with exact 1:1 draw/dispatch count parity againstactivity (2 s):calls (2 s, all threads): 89 placed textures in 30 ms, 2 placed buffers in 0 ms, 1 physical page calls in 44 ms, 1 memory calls in 1 ms, 42 pipelines in 39 ms, 60 ExecuteCommandLists in 90 ms, 29 presents in 30 ms, 29 waits of a present for the last frame's copy in 0 ms, 57 WaitFrameEventX in 762 ms, 88 draw recording in 1 ms, 540 state and root bindings in 2 ms, 183 view and descriptor calls in 1 ms, 153 barriers and flushes in 0 ms, 205 copies, clears, and memory ops in 2 ms, 162 list close and reset in 18 mscalls (2 s, all threads): 120 ExecuteCommandLists in 361 ms, 60 presents in 30 ms, 60 waits of a present for the last frame's copy in 0 ms, 120 WaitFrameEventX in 1605 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 2 ms, 540 list close and reset in 5 ms/calls of the submitting thread (2 s): 120 ExecuteCommandLists in 361 ms, 60 presents in 30 ms, 60 waits of a present for the last frame's copy in 0 ms, 120 WaitFrameEventX in 1605 ms; accounted 1996 ms of 2001 ms (5 ms untimed)HEAD(54650948,XCL_LOOK_STATSunset) emitted0submitting-thread summary lines inxcl.log.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(54650948):main(b49be183, merge-base):nvidia-dev(af2cecc408, target base):PR
HEAD(54650948, 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 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 andXCL_LOOK_STATS=2submitting-thread instrumentation, wrote the unit tests and this description, and ran the unit tests, clippy, workspace tests, and retail smoke runs on the hardware above.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.