Repository navigation
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
On 5465094, note publishes a submitter call count and its duration in separate atomic writes, while submitter_totals reads them separately. An activity tick can snapshot (1 call, 0 µs) between the writes. The next tick then sees (1 call, 400000 µs) but submitter_summary_line skips that category because the count delta is zero; the host still advances its baseline. That completed 400 ms call disappears from every new accounted window, 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
left a comment
There was a problem hiding this comment.
On 5465094, the new accounted … of … (… untimed) line treats cumulative completed-call durations as time inside the last activity window. A call is added in full at Timer::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 say accounted 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.
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
Not tested
AI use
|
|
Test report:
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. 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 AI use: Claude Code (Claude Opus 5.5) ran the tests, read the diff and drafted this; I read it before posting. |
5465094 to
93e66c1
Compare
|
Thanks for both reviews,
Re-verified |
|
Follow-up to my report, on the new head
Not tested: any title, so no AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this; I read it before posting. |
Prime1997
left a comment
There was a problem hiding this comment.
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 current nvidia-dev af2cecc40886a8682ecf3267f5328c6dc4b66ad7, 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_claim
Build: 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.
|
Test report: Tested
What it shows (the
Not tested
AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report. |
…TATS=2 With `XCL_LOOK_STATS=2`, `api_cost` previously truncated each call via `d.as_micros() as u64` (rounding sub-microsecond calls to 0), left `Call::FenceWait` unwired, and did not time command-list recording, state/root binding, view/descriptor calls, barriers/flushes, copies/clears, list lifecycle, or GPU-view tile asks on the submitting thread. - Accumulate call durations in nanoseconds inside `api_cost` and convert to microseconds in `totals()` / `submitter_totals()` so high-frequency sub-microsecond calls sum accurately without changing the public `(calls, us)` API. - Protect `ON_SUBMITTER` entries with a single-writer seqlock (`CounterPair`) so `submitter_totals()` snapshots coherent `(calls, us)` pairs, and retain nonzero duration deltas even when `count` delta is 0 in both `all_threads_summary_parts` and `submitter_summary_line`. - Add `#[inline] api_cost::time_if(on, call)` (zero clock, TLS, or atomic overhead when disabled), 8 `XCL_LOOK_STATS=2`-only `Call` variants (`DrawRecord`, `DispatchRecord`, `BindState`, `ViewDescriptor`, `ViewWant`, `ListBarrier`, `ListCopy`, `ListLifecycle`), `is_sub_call`, and `submitter_summary_line` (reporting completed top-level call durations alongside the elapsed `window_ms` without claiming an in-window untimed remainder or double-counting nested sub-timers `PresentCopyWait`, `PipelineWait`, and `ViewWant`). - Update `host.rs` to format `calls (2 s, all threads)` via `all_threads_summary_parts` and log `submitter_summary_line` using the actual elapsed tick duration. - Wire `XCL_LOOK_STATS=2`-gated timers across `bind.rs`, `list_x.rs`, `real.rs` (including `Call::FenceWait` on blocking `SetEventOnCompletion(_, NULL)` dropped before `settle_readbacks_try()`), and `view_want.rs`, splitting internal helpers (`emit_uav_barrier_pc`, `reset_pc_inner`, `copy_buffer_region_inner`, `dev_create_srv_inner`, `dev_create_uav_checked_inner`), resolving `resource_at` before starting `ViewDescriptor` in `dev_create_srv_at_x`/`dev_create_uav_at_x`, and guarding 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 `!is_own_work() && !presenting()` so no top-level call double-counts. - Add unit tests in `api_cost::tests` covering sub-microsecond accumulation, zero-count disabled `time_if`, `submitter_summary_line` sub-call exclusion, nonzero-duration delta retention on zero count delta (`(0,0) -> (1,0) -> (1,400_000)`), concurrent `CounterPair` snapshot coherence, and a 2.5 s call straddling two 2 s activity ticks. Part of xcl-dev#2688 Assisted-by: Google Antigravity (Gemini 4 Neon)
93e66c1 to
4922e39
Compare
|
Rebased cleanly onto
|
|
Follow-up on the rebased head
Not tested: any title, so no AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this; I read it before posting. |
Targets
nvidia-dev(eae01502). 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_flags, covering bothDispatchandDispatchX), lazydeep().then(...)inexecute_indirect(sosignature_dispatches(sig)is never evaluated when disabled), andBindState(root-parameter, descriptor-table, and PSO bindings), preservingcapture::op/capture_workand deferred two-pass pipeline queueing oneae01502.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 while preservingcapture::opinstrumentation.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()while preservingflush_two_pass,gpu_times::before_close, andeb784bc3submit/sparse lock-holder timing oneae01502.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 (WARP) and release (RTX 4060), rebased cleanly ontoorigin/nvidia-dev(eae01502).cargo test -p xcl --lib hle::api_cost::tests:: -- --test-threads=4 --nocapture(debugXCL_ADAPTER=warp):8 passed, 0 failed, 0 ignored(0skipped,0.00 s).cargo test --release -p xcl --lib hle::api_cost::tests:: -- --test-threads=4 --nocapture(release RTX 4060):8 passed, 0 failed, 0 ignored(0skipped,0.00 s).--test-threads=4):200 passed, 0 failed, 0 ignoredacrosshle::d3d12x::bind::(53/0/0,0.35 s,1opt-in skip withXCL_HEAP_WINDOWSunset),hle::d3d12x::list_x::(50/0/0,0.93 s,0skipped), andhle::d3d12x::real::(97/0/0,0skipped).cargo clippy --workspace --all-targets:0new warnings and0new errors across all added/changed lines in all 6 modified files (pre-existingnvidia-devclippy errors remain in untouchedlower_valu.rs,lower_wide.rs,recomp/lower.rs, andsparse.rs).XCL_LOOK_STATS=2 XCL_ACTIVITY=125 s RTX 4060 smoke on4922e39e(title: 29640639):470frames (PresentX 470),1 60 60presents/2 s,0device removals,0crashes,15788 MBpeak commit,exit: 0x0.Regression run
Quiet 60 s
scripts/smoke.ps1runs on RTX 4060 with default flags (XCL_LOOK_STATSunset). Includesmainmerge-base (b49be183, same-day run on this hardware) forpr_check.py,nvidia-devtarget base (eae01502), and rebased PRHEAD(4922e39e):main(b49be183, merge-base):nvidia-dev(eae01502, target base):PR
HEAD(4922e39e, default flags):Not tested
--workspacetest suite on the rebasedeae01502commit (targetedapi_cost::tests::and affectedbind::/list_x::/real::suites plus clippy and smokes ran on4922e39e).Call::FenceWait(blockingSetEventOnCompletion(_, NULL)) andCall::ViewWant(view_want::want), which did not fire during the short menu/intro smoke (covered by deterministic unit tests).XCL_HEAP_WINDOWS,XCL_SAMPLE_RPF,d3d12SDKLayers.dllunset/unavailable).AI use
api_costnanosecond accumulation,CounterPairseqlock,XCL_LOOK_STATS=2submitting-thread instrumentation, and completed-call summary wording, rebased ontoorigin/nvidia-dev(eae01502), ran the unit/module tests, clippy, and retail smoke runs on the hardware above, and updated this description.