D3D12.X: count Wait32/64BitValueX waits made on the CPU, by reason #3323

Merged
Prime1997 merged 1 commit from upstream-pr/3323 into main 2026-12-02 17:38:01 +00:00
Prime1997 commented 2026-11-29 08:12:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-29T08:12:52Z.


Requested by Prime

Only a 64-bit, GREATER_EQUAL, full-mask wait on an address a list wrote with Write64BitValue becomes a GPU queue.Wait; every other Wait32/64BitValueX the memory does not yet hold blocks the submitting thread (up to XCL_WAIT_TIMEOUT_MS). Which kinds a title makes, and how long they hold the submit threads, decides which ones are worth moving to the GPU, and nothing measured it: XCL_STALL_TRACE lumps these waits together with the CPU-write waits.

Each CPU wait is now counted by the first reason try_gpu_wait refuses it (32-bit, not >=, masked, >= 0, untracked address, not monotonic, not recorded yet, other) with its time. At most every 10 s, and only after a CPU wait, one info line gives the counts, the times and the waits that went to the GPU. The cost is two clock reads and a sync-graph lookup on a path that then blocks anyway.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: CpuWaitWhy, cpu_wait_why, the counters and note_cpu_wait / cpu_wait_report (the D3D12.X: memory waits on the CPU in the last N s line), called from wait_all_on_noting_cpu; tests a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it and the_cpu_wait_report_names_only_the_kinds_that_happened

Tested

  • RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0; the suite in debug, the smoke on a release build of the head commit
  • cargo test --workspace --no-fail-fast -- --test-threads=4 with the three uma_driver tests below skipped, on 60ee4e9948: 2607 passed, 0 failed, 49 ignored (SKIPPED GPU tests: 28 lines: 21 no wave64 (this card runs wave32), 3 a wave32 per-lane form refused by the translator (#1426), 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1), 1 no dxc.exe, 1 cannot disable the driver cache (needs Windows Developer Mode))
  • the three skipped tests on their own (cargo test -p xcl --lib -- --test-threads=1 uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window): 3 passed, 0 failed. They are left out of the whole run because on this PC's driver they can end the library test process (exit 0x7c10003, "coherent window could not be restored"), on main too
  • the library harness twice more (cargo test -p xcl --lib -- --test-threads=4, same skips): 2468 passed, 0 failed; 2468 passed, 0 failed
  • the same whole run on main fa204595a4: 2605 passed, 0 failed, 49 ignored, 28 SKIPPED lines (own-prs-20261129 run, same command)
  • retail title (60 s scripts/smoke.ps1, no input, copied profile and shader cache): blocks below

Regression run

xcl-smoke v1
commit: fa204595a488c60c6c5f905244f0172072c9c2a9
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1334 (PresentX 1334)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15272 MB
xcl-smoke v1
commit: 60ee4e99489e47ef497379ccd48b453ac7f8f33e
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1470 (PresentX 1470)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15350 MB

Not tested

  • AMD GPUs (this is an NVIDIA wave32 card)
  • the retail title's world: the 60 s runs end on the title's start-up screens
  • The 60 s smoke made no CPU memory wait, so the new line did not appear in its log; which waits a retail world makes was not measured yet.

AI use

  • Claude Code wrote the change and its test, wrote this description, and ran the tests and the smoke runs on this PC. The model is not named here: this session cannot tell which model served each turn.

Optional temporary Discord for coordinating contributor work, testing and comparing results.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5548912788 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-29T08:12:52Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ Only a 64-bit, `GREATER_EQUAL`, full-mask wait on an address a list wrote with `Write64BitValue` becomes a GPU `queue.Wait`; every other `Wait32/64BitValueX` the memory does not yet hold blocks the submitting thread (up to `XCL_WAIT_TIMEOUT_MS`). Which kinds a title makes, and how long they hold the submit threads, decides which ones are worth moving to the GPU, and nothing measured it: `XCL_STALL_TRACE` lumps these waits together with the CPU-write waits. Each CPU wait is now counted by the first reason `try_gpu_wait` refuses it (32-bit, not `>=`, masked, `>= 0`, untracked address, not monotonic, not recorded yet, other) with its time. At most every 10 s, and only after a CPU wait, one info line gives the counts, the times and the waits that went to the GPU. The cost is two clock reads and a sync-graph lookup on a path that then blocks anyway. **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: `CpuWaitWhy`, `cpu_wait_why`, the counters and `note_cpu_wait` / `cpu_wait_report` (the `D3D12.X: memory waits on the CPU in the last N s` line), called from `wait_all_on_noting_cpu`; tests `a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it` and `the_cpu_wait_report_names_only_the_kinds_that_happened` **Tested** - RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0; the suite in debug, the smoke on a release build of the head commit - `cargo test --workspace --no-fail-fast -- --test-threads=4` with the three `uma_driver` tests below skipped, on 60ee4e99489e: 2607 passed, 0 failed, 49 ignored (SKIPPED GPU tests: 28 lines: 21 `no wave64` (this card runs wave32), 3 a wave32 per-lane form refused by the translator (#1426), 2 `no heap windows` (opt-in `XCL_HEAP_WINDOWS=1`), 1 `no dxc.exe`, 1 `cannot disable the driver cache` (needs Windows Developer Mode)) - the three skipped tests on their own (`cargo test -p xcl --lib -- --test-threads=1 uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window`): 3 passed, 0 failed. They are left out of the whole run because on this PC's driver they can end the library test process (exit 0x7c10003, "coherent window could not be restored"), on `main` too - the library harness twice more (`cargo test -p xcl --lib -- --test-threads=4`, same skips): 2468 passed, 0 failed; 2468 passed, 0 failed - the same whole run on `main` fa204595a488: 2605 passed, 0 failed, 49 ignored, 28 `SKIPPED` lines (own-prs-20261129 run, same command) - retail title (60 s `scripts/smoke.ps1`, no input, copied profile and shader cache): blocks below **Regression run** ``` xcl-smoke v1 commit: fa204595a488c60c6c5f905244f0172072c9c2a9 gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 1334 (PresentX 1334) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 15272 MB ``` ``` xcl-smoke v1 commit: 60ee4e99489e47ef497379ccd48b453ac7f8f33e gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 1470 (PresentX 1470) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15350 MB ``` **Not tested** - AMD GPUs (this is an NVIDIA wave32 card) - the retail title's world: the 60 s runs end on the title's start-up screens - The 60 s smoke made no CPU memory wait, so the new line did not appear in its log; which waits a retail world makes was not measured yet. **AI use** - Claude Code wrote the change and its test, wrote this description, and ran the tests and the smoke runs on this PC. The model is not named here: this session cannot tell which model served each turn. Optional temporary [Discord](https://discord.gg/6B4TykyC4W) for coordinating contributor work, testing and comparing results. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
andrewDoing commented 2026-11-29 08:23:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T08:23:11Z.


Exercised the production reporting interval at 60ee4e99 on RTX 5070 / driver 616.92. Two otherwise identical 32-bit full-mask greater-or-equal waits resolved to 91. An independent D3D12 marker after the producer queue's write-fence signal distinguished their causes:

At wait entry Producer marker Why the CPU cell still held zero
Producer queue B already complete 1 B's deferred store was behind gated queue A on the CPU-write worker
Producer queue B itself gated 0 B had yet to reach its own write-fence signal

I released the respective gate after a deliberate 100 ms observation. Both CPU reads got 91, and repeating each already-satisfied wait added no counter. The actual log line was:

D3D12.X: memory waits on the CPU in the last 10 s: 2 (183.2 ms of submit threads; 32-bit 2 (183.2 ms)), on the GPU: 0

The line measures which wait forms fell back and their accumulated polling time. Here its one bucket combined an already-complete producer with a genuinely pending one. Likewise, "on the GPU: 0" counted zero waits routed to queue.Wait; it cannot establish that both GPU producers were ready. For a world trace, correlating wait entry with a known producer's queue/fence completion and subsequent CPU-cell publication would distinguish the two costs. The measured duration is synthetic and excludes setup before wait_until_satisfied.

The fixture used native queues, production deferred writes, and wait_all_on_noting_cpu with a constructed PendingWait. Guest list decoding and retail execution were outside this test.

AI disclosure: OpenAI Codex built and ran the fixture and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7253070721 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7253070721). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T08:23:11Z. --- Exercised the production reporting interval at `60ee4e99` on RTX 5070 / driver 616.92. Two otherwise identical 32-bit full-mask greater-or-equal waits resolved to 91. An independent D3D12 marker after the producer queue's write-fence signal distinguished their causes: | At wait entry | Producer marker | Why the CPU cell still held zero | |---|---:|---| | Producer queue B already complete | 1 | B's deferred store was behind gated queue A on the CPU-write worker | | Producer queue B itself gated | 0 | B had yet to reach its own write-fence signal | I released the respective gate after a deliberate 100 ms observation. Both CPU reads got 91, and repeating each already-satisfied wait added no counter. The actual log line was: ``` D3D12.X: memory waits on the CPU in the last 10 s: 2 (183.2 ms of submit threads; 32-bit 2 (183.2 ms)), on the GPU: 0 ``` The line measures which wait forms fell back and their accumulated polling time. Here its one bucket combined an already-complete producer with a genuinely pending one. Likewise, "on the GPU: 0" counted zero waits routed to queue.Wait; it cannot establish that both GPU producers were ready. For a world trace, correlating wait entry with a known producer's queue/fence completion and subsequent CPU-cell publication would distinguish the two costs. The measured duration is synthetic and excludes setup before `wait_until_satisfied`. The fixture used native queues, production deferred writes, and `wait_all_on_noting_cpu` with a constructed PendingWait. Guest list decoding and retail execution were outside this test. AI disclosure: OpenAI Codex built and ran the fixture and drafted this report.
Aniseto commented 2026-11-29 12:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:09:04Z.


Ran the CPU-wait accounting tests at 60ee4e99 on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_cpu_wait_report_names_only_the_kinds_that_happened -- --test-threads=1: 1 passed, 0 failed, 0 ignored.

What this adds
Both new tests pass: each CPU wait is counted by the first reason the GPU did not take it, and the periodic report names only the kinds that happened. The thread has a note about the reporting interval on an RTX 5070; this adds a 5070 Ti datapoint on driver 32.0.16.2140. These are CPU-side accounting tests, not a title's wait-time measurement.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

<!-- greyfinch-sync:ivall/xcl:comment:7255602720 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7255602720). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-29T12:09:04Z. --- Ran the CPU-wait accounting tests at `60ee4e99` on an NVIDIA Blackwell desktop part. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_cpu_wait_report_names_only_the_kinds_that_happened -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. **What this adds** Both new tests pass: each CPU wait is counted by the first reason the GPU did not take it, and the periodic report names only the kinds that happened. The thread has a note about the reporting interval on an RTX 5070; this adds a 5070 Ti datapoint on driver 32.0.16.2140. These are CPU-side accounting tests, not a title's wait-time measurement. **Not tested** A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - ran the commands above on this machine and wrote this report; no game data was used.
andrewDoing commented 2026-11-29 14:44:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T14:44:39Z.


I tried a narrow opt-in follow-up on 60ee4e99 for the attribution gap above. XCL_WAIT_PRODUCER_STATS=1 samples the producer fence at entry to a blocking 32-bit wait, when there is exactly one overlapping tracked deferred DWORD store whose value satisfies the wait. It preserves the existing wait behavior and keeps the new registry off the default path.

On RTX 5070 / 616.92 and Ryzen 7 5700X3D, the production report showed one pending fence and one complete fence, matching an independent native marker. Both waits returned 91. Two fresh-process controls (a host-only store and two overlapping deferred stores) both reported Unknown in the classifier and returned 91. A repeated already-satisfied wait remained on the fast path. With the switch unset, the paired native run had its original report and no extra diagnostic line. Four stock cpu_wait_ tests passed. Across the four fixture invocations and that filter, 8 tests passed with zero skips.

The new line reports state samples, not an elapsed-time breakdown or proof of the sole producer. Wider writes, multiple overlaps, publication already in progress and registry overflow all fall back to unknown. The registry is capped at 64 jobs with at most 64 write records per job. The fixtures used synthetic writes and native queues. Retail timing, overhead under sustained capture, and address aliases are unmeasured.

Two-file prototype (apply-checked on 60ee4e99)

--- a/crates/xcl/src/hle/d3d12x/cpu_writes.rs
+++ b/crates/xcl/src/hle/d3d12x/cpu_writes.rs
@@ -35,6 +35,7 @@
     value: u64,
     writes: Vec<Write>,
     done: Option<mpsc::Sender<()>>,
+    probe: Option<ProbeTicket>,
 }
 
 // SAFETY: the fence is a free-threaded COM object; the writes are plain data
@@ -49,6 +50,125 @@
 unsafe impl Send for QueueFence {}
 
 static FENCES: Mutex<Option<HashMap<usize, QueueFence>>> = Mutex::new(None);
+
+// Optional diagnostics. Keep snapshots bounded and treat overflow as unknown. A matching job
+// describes what XCL queued; guest CPU stores and writes through aliases may exist as well.
+const PROBE_LIMIT: usize = 64;
+static PROBE_ENABLED: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| {
+    std::env::var("XCL_WAIT_PRODUCER_STATS").is_ok_and(|v| v.trim() == "1")
+});
+static PROBES: Mutex<Option<Probes>> = Mutex::new(None);
+
+#[derive(Default)]
+struct Probes {
+    jobs: HashMap<u64, ProbeJob>,
+    next: u64,
+    omitted: usize,
+}
+
+struct ProbeJob {
+    fence: ID3D12Fence,
+    value: u64,
+    publishing: bool,
+    writes: Vec<ProbeWrite>,
+}
+
+// SAFETY: ID3D12Fence is free-threaded. The rest of the probe contains only owned data.
+unsafe impl Send for ProbeJob {}
+
+struct ProbeWrite {
+    start: usize,
+    end: usize,
+    word: Option<u32>,
+}
+
+struct ProbeTicket(Option<u64>);
+
+impl ProbeTicket {
+    fn register(job: &Job) -> Option<Self> {
+        if !*PROBE_ENABLED {
+            return None;
+        }
+        let mut guard = PROBES.lock().unwrap();
+        let probes = guard.get_or_insert_with(Probes::default);
+        if probes.jobs.len() >= PROBE_LIMIT || job.writes.len() > PROBE_LIMIT {
+            probes.omitted += 1;
+            return Some(Self(None));
+        }
+        let writes = job.writes.iter().filter_map(|w| {
+            let (start, bytes, word) = match w {
+                Write::Immediate(start, words) => (*start, words.len().saturating_mul(4),
+                    if words.len() == 1 { words.first().copied() } else { None }),
+                Write::ReadbackU64 { va, .. } => (*va, 8, None),
+            };
+            (bytes != 0).then_some(ProbeWrite { start, end: start.saturating_add(bytes), word })
+        }).collect();
+        let id = probes.next;
+        probes.next += 1;
+        probes.jobs.insert(id, ProbeJob { fence: job.fence.clone(), value: job.value, publishing: false, writes });
+        Some(Self(Some(id)))
+    }
+
+    fn mark_publishing(&self) {
+        if let Some(id) = self.0 {
+            if let Some(job) = PROBES.lock().unwrap().as_mut().and_then(|p| p.jobs.get_mut(&id)) {
+                job.publishing = true;
+            }
+        }
+    }
+}
+
+impl Drop for ProbeTicket {
+    fn drop(&mut self) {
+        let mut guard = PROBES.lock().unwrap();
+        let probes = guard.as_mut().unwrap();
+        if let Some(id) = self.0 {
+            let job = probes.jobs.remove(&id);
+            drop(guard);
+            drop(job);
+        } else {
+            probes.omitted -= 1;
+        }
+    }
+}
+
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub(super) enum WaitProbe {
+    Unknown,
+    FencePending,
+    FenceComplete,
+}
+
+/// Classify one DWORD wait using an exact overlapping XCL store that would satisfy it. Unknown
+/// includes multiple writers, wider writes, GPU-resolved values, and publication in progress.
+pub(super) fn probe_wait32(va: usize, accepts: impl FnOnce(u32) -> bool) -> Option<WaitProbe> {
+    if !*PROBE_ENABLED {
+        return None;
+    }
+    Some(probe_wait32_enabled(va, accepts).unwrap_or(WaitProbe::Unknown))
+}
+
+fn probe_wait32_enabled(va: usize, accepts: impl FnOnce(u32) -> bool) -> Option<WaitProbe> {
+    let end = va.checked_add(4)?;
+    let guard = PROBES.lock().unwrap();
+    let probes = guard.as_ref()?;
+    if probes.omitted != 0 {
+        return None;
+    }
+    let mut overlapping = probes.jobs.values().flat_map(|job| {
+        job.writes.iter().filter(move |w| w.start < end && va < w.end).map(move |w| (job, w))
+    });
+    let (job, write) = overlapping.next()?;
+    if overlapping.next().is_some() || job.publishing || write.start != va || !accepts(write.word?) {
+        return None;
+    }
+    let completed = unsafe { super::real::fence_completed(&job.fence) };
+    match completed {
+        u64::MAX => None,
+        value if value >= job.value => Some(WaitProbe::FenceComplete),
+        _ => Some(WaitProbe::FencePending),
+    }
+}
 
 /// Forget a retired queue's cached fence before its address can be reused. Submitted jobs own
 /// fence clones, so extracting this entry cannot let their writes run early.
@@ -81,6 +201,9 @@
                         }
                     }
                 }
+                if let Some(probe) = &job.probe {
+                    probe.mark_publishing();
+                }
                 for w in &job.writes {
                     match w {
                         Write::Immediate(va, words) => write_now(*va, words),
@@ -90,6 +213,7 @@
                         }
                     }
                 }
+                drop(job.probe);
                 if let Some(done) = job.done {
                     let _ = done.send(());
                 }
@@ -251,7 +375,7 @@
     } else {
         (None, None)
     };
-    let job = {
+    let mut job = {
         let mut g = FENCES.lock().unwrap();
         let m = g.get_or_insert_with(HashMap::new);
         let entry = match m.entry(queue as usize) {
@@ -270,8 +394,9 @@
         if super::real::native_queue_signal(q, &entry.fence, entry.value).is_err() {
             return None;
         }
-        Job { fence: entry.fence.clone(), value: entry.value, writes, done }
+        Job { fence: entry.fence.clone(), value: entry.value, writes, done, probe: None }
     };
+    job.probe = ProbeTicket::register(&job);
     static FIRST: std::sync::Once = std::sync::Once::new();
     FIRST.call_once(|| crate::xlog_info!("D3D12.X: bottom-of-pipe writes outside unified memory are done by the CPU after the GPU ({} in the first submission)", job.writes.len()));
     worker().lock().unwrap().send(job).ok()?;
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -3395,6 +3395,8 @@
 static CPU_WAITS: [(AtomicU64, AtomicU64); 8] = [const { (AtomicU64::new(0), AtomicU64::new(0)) }; 8];
 /// waits the memory did not hold that went to the GPU since the last report
 static GPU_WAITS: AtomicU64 = AtomicU64::new(0);
+/// Opt-in counts of fence states sampled at the start of DWORD CPU waits.
+static CPU_WAIT_PROBES: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3];
 /// when the last report was made, in milliseconds since `CPU_WAIT_EPOCH`
 static CPU_WAIT_REPORTED_MS: AtomicU64 = AtomicU64::new(0);
 static CPU_WAIT_EPOCH: OnceLock<Instant> = OnceLock::new();
@@ -3419,6 +3421,13 @@
     let gpu = GPU_WAITS.swap(0, Ordering::Relaxed);
     if let Some(line) = cpu_wait_report(&counts, gpu, Duration::from_millis(now - last)) {
         crate::xlog_info!("{line}");
+    }
+    let [unknown, pending, complete] = CPU_WAIT_PROBES.each_ref().map(|n| n.swap(0, Ordering::Relaxed));
+    if unknown != 0 || pending != 0 || complete != 0 {
+        crate::xlog_info!(
+            "D3D12.X: DWORD CPU wait entry samples: deferred write fence pending {pending}, \
+             deferred write fence complete {complete}, unknown or ambiguous {unknown}"
+        );
     }
 }
 
@@ -3627,6 +3636,13 @@
             let g = SYNC_GRAPH.lock().unwrap();
             g.as_ref().and_then(|gr| gr.cells.get(&w.va)).map(|c| (c.non_monotonic, c.recorded_max))
         });
+        if w.width == 4 {
+            if let Some(probe) = super::cpu_writes::probe_wait32(w.va as usize, |word| {
+                compare_u64(w.comparison, u64::from(word) & w.mask, w.value) == Some(true)
+            }) {
+                CPU_WAIT_PROBES[probe as usize].fetch_add(1, Ordering::Relaxed);
+            }
+        }
         let memory_stall = crate::stall::span(crate::stall::StallKind::MemorySynchronization);
         let started = Instant::now();
         let satisfied = w.wait_until_satisfied(timeout);

AI disclosure: OpenAI Codex (GPT-6.2 Sol) implemented and tested the optional probe using the saved Codex/Astra fixtures and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7257541653 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7257541653). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T14:44:39Z. --- I tried a narrow opt-in follow-up on `60ee4e99` for the attribution gap above. `XCL_WAIT_PRODUCER_STATS=1` samples the producer fence at entry to a blocking 32-bit wait, when there is exactly one overlapping tracked deferred DWORD store whose value satisfies the wait. It preserves the existing wait behavior and keeps the new registry off the default path. On RTX 5070 / 616.92 and Ryzen 7 5700X3D, the production report showed one pending fence and one complete fence, matching an independent native marker. Both waits returned `91`. Two fresh-process controls (a host-only store and two overlapping deferred stores) both reported `Unknown` in the classifier and returned `91`. A repeated already-satisfied wait remained on the fast path. With the switch unset, the paired native run had its original report and no extra diagnostic line. Four stock `cpu_wait_` tests passed. Across the four fixture invocations and that filter, 8 tests passed with zero skips. The new line reports state samples, not an elapsed-time breakdown or proof of the sole producer. Wider writes, multiple overlaps, publication already in progress and registry overflow all fall back to unknown. The registry is capped at 64 jobs with at most 64 write records per job. The fixtures used synthetic writes and native queues. Retail timing, overhead under sustained capture, and address aliases are unmeasured. <details><summary>Two-file prototype (apply-checked on 60ee4e99)</summary> ```diff --- a/crates/xcl/src/hle/d3d12x/cpu_writes.rs +++ b/crates/xcl/src/hle/d3d12x/cpu_writes.rs @@ -35,6 +35,7 @@ value: u64, writes: Vec<Write>, done: Option<mpsc::Sender<()>>, + probe: Option<ProbeTicket>, } // SAFETY: the fence is a free-threaded COM object; the writes are plain data @@ -49,6 +50,125 @@ unsafe impl Send for QueueFence {} static FENCES: Mutex<Option<HashMap<usize, QueueFence>>> = Mutex::new(None); + +// Optional diagnostics. Keep snapshots bounded and treat overflow as unknown. A matching job +// describes what XCL queued; guest CPU stores and writes through aliases may exist as well. +const PROBE_LIMIT: usize = 64; +static PROBE_ENABLED: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| { + std::env::var("XCL_WAIT_PRODUCER_STATS").is_ok_and(|v| v.trim() == "1") +}); +static PROBES: Mutex<Option<Probes>> = Mutex::new(None); + +#[derive(Default)] +struct Probes { + jobs: HashMap<u64, ProbeJob>, + next: u64, + omitted: usize, +} + +struct ProbeJob { + fence: ID3D12Fence, + value: u64, + publishing: bool, + writes: Vec<ProbeWrite>, +} + +// SAFETY: ID3D12Fence is free-threaded. The rest of the probe contains only owned data. +unsafe impl Send for ProbeJob {} + +struct ProbeWrite { + start: usize, + end: usize, + word: Option<u32>, +} + +struct ProbeTicket(Option<u64>); + +impl ProbeTicket { + fn register(job: &Job) -> Option<Self> { + if !*PROBE_ENABLED { + return None; + } + let mut guard = PROBES.lock().unwrap(); + let probes = guard.get_or_insert_with(Probes::default); + if probes.jobs.len() >= PROBE_LIMIT || job.writes.len() > PROBE_LIMIT { + probes.omitted += 1; + return Some(Self(None)); + } + let writes = job.writes.iter().filter_map(|w| { + let (start, bytes, word) = match w { + Write::Immediate(start, words) => (*start, words.len().saturating_mul(4), + if words.len() == 1 { words.first().copied() } else { None }), + Write::ReadbackU64 { va, .. } => (*va, 8, None), + }; + (bytes != 0).then_some(ProbeWrite { start, end: start.saturating_add(bytes), word }) + }).collect(); + let id = probes.next; + probes.next += 1; + probes.jobs.insert(id, ProbeJob { fence: job.fence.clone(), value: job.value, publishing: false, writes }); + Some(Self(Some(id))) + } + + fn mark_publishing(&self) { + if let Some(id) = self.0 { + if let Some(job) = PROBES.lock().unwrap().as_mut().and_then(|p| p.jobs.get_mut(&id)) { + job.publishing = true; + } + } + } +} + +impl Drop for ProbeTicket { + fn drop(&mut self) { + let mut guard = PROBES.lock().unwrap(); + let probes = guard.as_mut().unwrap(); + if let Some(id) = self.0 { + let job = probes.jobs.remove(&id); + drop(guard); + drop(job); + } else { + probes.omitted -= 1; + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) enum WaitProbe { + Unknown, + FencePending, + FenceComplete, +} + +/// Classify one DWORD wait using an exact overlapping XCL store that would satisfy it. Unknown +/// includes multiple writers, wider writes, GPU-resolved values, and publication in progress. +pub(super) fn probe_wait32(va: usize, accepts: impl FnOnce(u32) -> bool) -> Option<WaitProbe> { + if !*PROBE_ENABLED { + return None; + } + Some(probe_wait32_enabled(va, accepts).unwrap_or(WaitProbe::Unknown)) +} + +fn probe_wait32_enabled(va: usize, accepts: impl FnOnce(u32) -> bool) -> Option<WaitProbe> { + let end = va.checked_add(4)?; + let guard = PROBES.lock().unwrap(); + let probes = guard.as_ref()?; + if probes.omitted != 0 { + return None; + } + let mut overlapping = probes.jobs.values().flat_map(|job| { + job.writes.iter().filter(move |w| w.start < end && va < w.end).map(move |w| (job, w)) + }); + let (job, write) = overlapping.next()?; + if overlapping.next().is_some() || job.publishing || write.start != va || !accepts(write.word?) { + return None; + } + let completed = unsafe { super::real::fence_completed(&job.fence) }; + match completed { + u64::MAX => None, + value if value >= job.value => Some(WaitProbe::FenceComplete), + _ => Some(WaitProbe::FencePending), + } +} /// Forget a retired queue's cached fence before its address can be reused. Submitted jobs own /// fence clones, so extracting this entry cannot let their writes run early. @@ -81,6 +201,9 @@ } } } + if let Some(probe) = &job.probe { + probe.mark_publishing(); + } for w in &job.writes { match w { Write::Immediate(va, words) => write_now(*va, words), @@ -90,6 +213,7 @@ } } } + drop(job.probe); if let Some(done) = job.done { let _ = done.send(()); } @@ -251,7 +375,7 @@ } else { (None, None) }; - let job = { + let mut job = { let mut g = FENCES.lock().unwrap(); let m = g.get_or_insert_with(HashMap::new); let entry = match m.entry(queue as usize) { @@ -270,8 +394,9 @@ if super::real::native_queue_signal(q, &entry.fence, entry.value).is_err() { return None; } - Job { fence: entry.fence.clone(), value: entry.value, writes, done } + Job { fence: entry.fence.clone(), value: entry.value, writes, done, probe: None } }; + job.probe = ProbeTicket::register(&job); static FIRST: std::sync::Once = std::sync::Once::new(); FIRST.call_once(|| crate::xlog_info!("D3D12.X: bottom-of-pipe writes outside unified memory are done by the CPU after the GPU ({} in the first submission)", job.writes.len())); worker().lock().unwrap().send(job).ok()?; --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -3395,6 +3395,8 @@ static CPU_WAITS: [(AtomicU64, AtomicU64); 8] = [const { (AtomicU64::new(0), AtomicU64::new(0)) }; 8]; /// waits the memory did not hold that went to the GPU since the last report static GPU_WAITS: AtomicU64 = AtomicU64::new(0); +/// Opt-in counts of fence states sampled at the start of DWORD CPU waits. +static CPU_WAIT_PROBES: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3]; /// when the last report was made, in milliseconds since `CPU_WAIT_EPOCH` static CPU_WAIT_REPORTED_MS: AtomicU64 = AtomicU64::new(0); static CPU_WAIT_EPOCH: OnceLock<Instant> = OnceLock::new(); @@ -3419,6 +3421,13 @@ let gpu = GPU_WAITS.swap(0, Ordering::Relaxed); if let Some(line) = cpu_wait_report(&counts, gpu, Duration::from_millis(now - last)) { crate::xlog_info!("{line}"); + } + let [unknown, pending, complete] = CPU_WAIT_PROBES.each_ref().map(|n| n.swap(0, Ordering::Relaxed)); + if unknown != 0 || pending != 0 || complete != 0 { + crate::xlog_info!( + "D3D12.X: DWORD CPU wait entry samples: deferred write fence pending {pending}, \ + deferred write fence complete {complete}, unknown or ambiguous {unknown}" + ); } } @@ -3627,6 +3636,13 @@ let g = SYNC_GRAPH.lock().unwrap(); g.as_ref().and_then(|gr| gr.cells.get(&w.va)).map(|c| (c.non_monotonic, c.recorded_max)) }); + if w.width == 4 { + if let Some(probe) = super::cpu_writes::probe_wait32(w.va as usize, |word| { + compare_u64(w.comparison, u64::from(word) & w.mask, w.value) == Some(true) + }) { + CPU_WAIT_PROBES[probe as usize].fetch_add(1, Ordering::Relaxed); + } + } let memory_stall = crate::stall::span(crate::stall::StallKind::MemorySynchronization); let started = Instant::now(); let satisfied = w.wait_until_satisfied(timeout); ``` </details> AI disclosure: OpenAI Codex (GPT-6.2 Sol) implemented and tested the optional probe using the saved Codex/Astra fixtures and drafted this report.
KOLESNiii commented 2026-11-29 22:39:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:29Z.

Review: COMMENTED


Static review of 60ee4e99 for the stack in the #3041 comparison.

The new counters can misclassify waits. GpuWaitOutcome::Handled also covers waits released on the CPU and waits satisfied by a fence recheck. Both increment the GPU-wait counter. The CPU refusal reason is inferred from a second sync-graph lookup, so a concurrent producer can change the state used to label the refusal. Carrying the outcome and refusal reason from the original attempt would make the counts match the decisions. Counter and classification

Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.

<!-- greyfinch-sync:ivall/xcl:review:6105175591 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#pullrequestreview-6105175591). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T22:39:29Z. **Review:** COMMENTED --- Static review of `60ee4e99` for the stack in the [#3041 comparison](https://github.com/xcl-dev/xcl/issues/3041#issuecomment-7263214809). **The new counters can misclassify waits.** `GpuWaitOutcome::Handled` also covers waits released on the CPU and waits satisfied by a fence recheck. Both increment the GPU-wait counter. The CPU refusal reason is inferred from a second sync-graph lookup, so a concurrent producer can change the state used to label the refusal. Carrying the outcome and refusal reason from the original attempt would make the counts match the decisions. [Counter and classification](https://github.com/xcl-dev/xcl/blob/60ee4e99/crates/xcl/src/hle/d3d12x/list_x.rs#L3618-L3634) Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
bmjask commented 2026-11-29 22:43:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:43:30Z.

Review: COMMENTED


Critical review of current head 60ee4e99. The new telemetry can misattribute waits. GpuWaitOutcome::Handled includes cases resolved on the CPU or by a fence recheck, yet increments GPU_WAITS; the CPU refusal reason is reconstructed from a later sync-graph read and can change under concurrent writes. That makes the displayed GPU/CPU split unsuitable for deciding which waits to move. Return the actual route/reason from try_gpu_wait and count that immutable outcome, with a test for CPU-resolved Handled and a concurrent producer. See the earlier source review. No local Windows run.

<!-- greyfinch-sync:ivall/xcl:review:6105191095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#pullrequestreview-6105191095). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T22:43:30Z. **Review:** COMMENTED --- Critical review of current head `60ee4e99`. **The new telemetry can misattribute waits.** `GpuWaitOutcome::Handled` includes cases resolved on the CPU or by a fence recheck, yet increments `GPU_WAITS`; the CPU refusal reason is reconstructed from a later sync-graph read and can change under concurrent writes. That makes the displayed GPU/CPU split unsuitable for deciding which waits to move. Return the actual route/reason from `try_gpu_wait` and count that immutable outcome, with a test for CPU-resolved `Handled` and a concurrent producer. See the [earlier source review](https://github.com/xcl-dev/xcl/pull/3323). No local Windows run.
tiagonleal commented 2026-11-30 02:49:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T02:49:04Z.


merge-check
base: cb8024684c
head: 60ee4e9948
merge: clean
build: cargo build --workspace -> ok (also cargo build --release -p xcl)
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2811 passed, 1 failed, 51 ignored; SKIPPED: 27 lines (22 no wave64, 3 f16/f32 per-lane cases refused, 2 no heap windows), the same as on the base; failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails the same way on the base (it came in with #2369; #3474 fixes it). Base alone on this PC: 2809 passed, 1 failed, 51 ignored.
review: whole diff read (+161/-0, list_x.rs). Diagnostic only: the wait itself, its timeout and its loop are unchanged, and the SYNC_GRAPH lock taken to classify a CPU wait is released before the wait starts. Two notes for the author, neither a blocker. The report line has no switch: note_cpu_wait logs at most one info line per 10 s whenever a wait fell back to the CPU, as the description says, where the other wait diagnostics here sit behind XCL_SYNC_TRACE or XCL_STALL_TRACE. And GPU_WAITS counts every wait try_gpu_wait reports as Handled, so "on the GPU" in the line is wider than waits that went to queue.Wait. The two new tests cover the pure functions (cpu_wait_why, cpu_wait_report) and touch no statics; the counting at the call site has no test. No open PR does the same (searched the titles).
performance: no cost per draw. A wait handled without the CPU adds one relaxed atomic add; a wait that falls back to the CPU adds one mutex lookup, two clock reads and two atomic adds before it blocks anyway. Measured with scripts/smoke.ps1, 60 s of a retail title, release: 1683 frames and 16059 MB peak commit against 1662 and 1684 frames, 16196 and 15752 MB on the base (run before and after). No device removal, no crash.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source)

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7267343867 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7267343867). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-30T02:49:04Z. --- merge-check base: cb8024684c7babcb0569ecda2217a54b8bedafb1 head: 60ee4e99489e47ef497379ccd48b453ac7f8f33e merge: clean build: cargo build --workspace -> ok (also `cargo build --release -p xcl`) tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2811 passed, 1 failed, 51 ignored; SKIPPED: 27 lines (22 `no wave64`, 3 f16/f32 per-lane cases refused, 2 `no heap windows`), the same as on the base; failing: `hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline`, which fails the same way on the base (it came in with #2369; #3474 fixes it). Base alone on this PC: 2809 passed, 1 failed, 51 ignored. review: whole diff read (+161/-0, `list_x.rs`). Diagnostic only: the wait itself, its timeout and its loop are unchanged, and the `SYNC_GRAPH` lock taken to classify a CPU wait is released before the wait starts. Two notes for the author, neither a blocker. The report line has no switch: `note_cpu_wait` logs at most one info line per 10 s whenever a wait fell back to the CPU, as the description says, where the other wait diagnostics here sit behind `XCL_SYNC_TRACE` or `XCL_STALL_TRACE`. And `GPU_WAITS` counts every wait `try_gpu_wait` reports as `Handled`, so "on the GPU" in the line is wider than waits that went to `queue.Wait`. The two new tests cover the pure functions (`cpu_wait_why`, `cpu_wait_report`) and touch no statics; the counting at the call site has no test. No open PR does the same (searched the titles). performance: no cost per draw. A wait handled without the CPU adds one relaxed atomic add; a wait that falls back to the CPU adds one mutex lookup, two clock reads and two atomic adds before it blocks anyway. Measured with `scripts/smoke.ps1`, 60 s of a retail title, release: 1683 frames and 16059 MB peak commit against 1662 and 1684 frames, 16196 and 15752 MB on the base (run before and after). No device removal, no crash. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source) - Tiago
ClosetPie107 commented 2026-11-30 16:03:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-30T16:03:15Z.


Test report for #3323 at 60ee4e99489e47ef497379ccd48b453ac7f8f33e, against its merge-base with main, fa204595, under Wine on AMD.

Tested

  • RX 9070 16 GB (RDNA4), Mesa 26.3.1 RADV, Ryzen 5 9600X, CachyOS; Proton Experimental experimental-11.0-20261112, stock vkd3d-proton master 71cae091. Debug build, x86_64-pc-windows-gnu, under Wine. It wasn't run on Windows.
  • Command: cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- <filter>.
  • The PR's new tests, each alone (--test-threads=1 <name>): both pass: a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it, the_cpu_wait_report_names_only_the_kinds_that_happened. 2 passed, 0 failed.
  • The lib suite at --test-threads=2, with --skip gpu:: and these six: failed_restore_stops_before_importing_an_unbacked_window, grooming_leaves_a_window_under_1_gib_only_its_hole (both run out of memory here), write_buffer_immediate_on_open_existing_heap_visible_to_cpu, coherent_buffer_sanitizes_console_flags_and_state, serialize_root_signature_strips_console_flags_and_preserves_pc_flags and execute_indirect_reads_the_arguments_written_before_it. Under Wine each of the last four ends the process or makes RADV reject later submissions (#3067), so without them the suite reaches its summary:
    • #3323 60ee4e99: 1502 passed, 112 failed, 5 ignored
    • base fa204595: 1500 passed, 112 failed, 5 ignored
  • The same tests fail on both. Most of the base's failures under Wine are main's known ones on stock vkd3d-proton: list creation refused (E_INVALIDARG, #175 / #1701) and the tests after it (#3067).

Not tested

  • native Windows
  • NVIDIA
  • the gpu:: tests in the suite runs
  • the workspace's other crates and integration tests (only -p xcl --lib)
  • a game run (no regression block)

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7284039009 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7284039009). Originally posted by [ClosetPie107](https://github.com/ClosetPie107) on 2026-11-30T16:03:15Z. --- Test report for #3323 at `60ee4e99489e47ef497379ccd48b453ac7f8f33e`, against its merge-base with `main`, `fa204595`, under Wine on AMD. **Tested** - RX 9070 16 GB (RDNA4), Mesa 26.3.1 RADV, Ryzen 5 9600X, CachyOS; Proton Experimental `experimental-11.0-20261112`, stock vkd3d-proton `master` `71cae091`. Debug build, `x86_64-pc-windows-gnu`, under Wine. It wasn't run on Windows. - Command: `cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- <filter>`. - The PR's new tests, each alone (`--test-threads=1 <name>`): both pass: `a_cpu_wait_is_counted_by_why_the_gpu_did_not_take_it`, `the_cpu_wait_report_names_only_the_kinds_that_happened`. **2 passed, 0 failed.** - The lib suite at `--test-threads=2`, with `--skip gpu::` and these six: `failed_restore_stops_before_importing_an_unbacked_window`, `grooming_leaves_a_window_under_1_gib_only_its_hole` (both run out of memory here), `write_buffer_immediate_on_open_existing_heap_visible_to_cpu`, `coherent_buffer_sanitizes_console_flags_and_state`, `serialize_root_signature_strips_console_flags_and_preserves_pc_flags` and `execute_indirect_reads_the_arguments_written_before_it`. Under Wine each of the last four ends the process or makes RADV reject later submissions (#3067), so without them the suite reaches its summary: - #3323 `60ee4e99`: 1502 passed, 112 failed, 5 ignored - base `fa204595`: 1500 passed, 112 failed, 5 ignored - The same tests fail on both. Most of the base's failures under Wine are `main`'s known ones on stock vkd3d-proton: list creation refused (`E_INVALIDARG`, #175 / #1701) and the tests after it (#3067). **Not tested** - native Windows - NVIDIA - the `gpu::` tests in the suite runs - the workspace's other crates and integration tests (only `-p xcl --lib`) - a game run (no regression block) AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
brainhay5 commented 2026-11-30 20:20:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T20:20:03Z.


merge-check claim
head: 60ee4e9948

<!-- greyfinch-sync:ivall/xcl:comment:7290748645 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7290748645). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-11-30T20:20:03Z. --- merge-check claim head: 60ee4e99489e47ef497379ccd48b453ac7f8f33e
Foniass commented 2026-12-01 05:47:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:47:00Z.


merge-check
base: d0832e614f
head: 60ee4e9948
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (list_x.rs, +161). Counting is always on: each wait handled on the GPU adds a relaxed atomic add (~3620); each CPU fallback adds a SYNC_GRAPH lookup, two clock reads and two adds before it blocks anyway (~3625-3633), with one info line at most every 10 s, only when the CPU waited. Findings: (1) GPU_WAITS counts every Handled result, including waits already released on the CPU (~3481, ~3517) and waits whose memory held the value after the fence check (~3521-3525), so "on the GPU" is wider than the waits that went to queue.Wait. (2) The reason is guessed after the fact: cpu_wait_why (~3375-3391) repeats try_gpu_wait's checks and reads the sync graph again after the refusal, so a Write64 recorded in between can turn "not recorded" into "other", a device mismatch (~3514) or a queue without device/type (~3462) ends up as "other" or a cell-based reason, and the two copies can drift. Having try_gpu_wait return the refusal reason fixes both and saves the extra lock. (3) A wait that times out and stops the process (~3681) never reports its last window. (4) The tests cover only the pure functions, not the counting at the call site. Fine: the wait, its timeout and loop are unchanged, the lock is released before blocking, and the CAS-gated report is right.
performance: 60 s smoke of a retail title, main d0832e61 vs this merge (ea8d77b4): 1516 -> 1673 frames shown (110 %; last presents per 2 s: 60 60 61), peak commit 18133 -> 17504 MB, 0 device removals, 0 crashes. The counters add one relaxed atomic per GPU-handled wait; no cost visible here.
verdict: safe to merge (diagnostics only; having try_gpu_wait return the refusal reason would make the counts exact)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7302132980 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7302132980). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:47:00Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 60ee4e99489e47ef497379ccd48b453ac7f8f33e merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (list_x.rs, +161). Counting is always on: each wait handled on the GPU adds a relaxed atomic add (~3620); each CPU fallback adds a SYNC_GRAPH lookup, two clock reads and two adds before it blocks anyway (~3625-3633), with one info line at most every 10 s, only when the CPU waited. Findings: (1) `GPU_WAITS` counts every `Handled` result, including waits already released on the CPU (~3481, ~3517) and waits whose memory held the value after the fence check (~3521-3525), so "on the GPU" is wider than the waits that went to `queue.Wait`. (2) The reason is guessed after the fact: `cpu_wait_why` (~3375-3391) repeats `try_gpu_wait`'s checks and reads the sync graph again after the refusal, so a Write64 recorded in between can turn "not recorded" into "other", a device mismatch (~3514) or a queue without device/type (~3462) ends up as "other" or a cell-based reason, and the two copies can drift. Having `try_gpu_wait` return the refusal reason fixes both and saves the extra lock. (3) A wait that times out and stops the process (~3681) never reports its last window. (4) The tests cover only the pure functions, not the counting at the call site. Fine: the wait, its timeout and loop are unchanged, the lock is released before blocking, and the CAS-gated report is right. performance: 60 s smoke of a retail title, main d0832e61 vs this merge (ea8d77b4): 1516 -> 1673 frames shown (110 %; last presents per 2 s: 60 60 61), peak commit 18133 -> 17504 MB, 0 device removals, 0 crashes. The counters add one relaxed atomic per GPU-handled wait; no cost visible here. verdict: safe to merge (diagnostics only; having try_gpu_wait return the refusal reason would make the counts exact) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
brainhay5 commented 2026-12-01 11:47:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T11:47:59Z.


merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.

AI use: an agent posted this withdrawal.

<!-- greyfinch-sync:ivall/xcl:comment:7310158393 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3323#issuecomment-7310158393). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T11:47:59Z. --- merge-check claim withdrawn Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take. *AI use: an agent posted this withdrawal.*
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3323
No description provided.