Shaders: speed up startup preparation with dynamic LPT workers #2906

Open
github-bot wants to merge 1 commit from github-bot/gh-2906 into nvidia-dev AGit
Owner

@⁠saintwolf on GitHub · 2026-11-26 22:36 UTC · original
saintwolf:perf/nvidia-shader-prep → nvidia-dev · +409 −32 · 3 files · 1 commits · open

Speeds up startup shader preparation on NVIDIA GPUs by removing static-slice tail stalls, pack-RAM duplication across workers, and under-utilized pipeline concurrency.

What is in it

  • crates/xcl/src/gpu/pack.rs: adds Pack::seek_read (random-access single-record read via FileExt::seek_read) and Pack::record_len so workers read individual records on demand without loading the entire shader pack into memory.
  • crates/xcl/src/gpu/recomp/dxc.rs: adds set_memory_reserve(gb) so prepare_for_launch can temporarily lower the DXC commit reserve (restored via RAII before title start).
  • crates/xcl/src/shaders.rs:
    • Replaces static worker slicing with dynamic LPT (largest-first) work-stealing over a single shared --compute-worker job stream (0 MB pack RAM per worker).
    • Tunes default worker pipeline concurrency to XCL_PIPELINE_THREADS=2 and adds compute_worker_count targeting cores / 2 concurrent compiles (1 per physical core, avoiding SMT/L3 thrashing) within a 1.5 GiB/worker commit budget.
    • Preserves per-entry D3D12 validation for cached .pso blobs so damaged or stale cache entries are always detected and rebuilt.
    • Sorts precompile() and graphics_in_workers() largest-first (LPT), deduplicates identical blobs in precompile(), lowers dxc::set_memory_reserve(2) during prepare_for_launch (restored to 6 GB via RAII before title start), and routes VS/PS/MS through console_to_dxil_in / console_mesh_in when XCL_DIRECT_DXIL is enabled.
    • Adds unit tests parse_compute_job_accepts_three_numbers_and_rejects_malformed, compute_worker_count_saturates_cpu_within_commit_budget, and a_valid_canary_does_not_hide_a_second_stale_compute_blob.

Tested

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D (8 cores / 16 threads), rustc 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.8.2502.11.
  • cargo test -p xcl --lib shaders:: -- --test-threads=1: 18 passed, 0 failed, 0 ignored (1 skipped: pso_measurement_compiles_an_exact_synthetic_record, Developer Mode required), including a_valid_canary_does_not_hide_a_second_stale_compute_blob.
  • cargo test -p xcl --lib gpu::pack:: -- --test-threads=1: 4 passed, 0 failed.
  • .\scripts\test.ps1 (debug): 1,690 passed across the workspace with 0 failures in shaders::, pack::, pso::, or dxc:: (3 pre-existing nvidia-dev failures: gpu_compute_thread_limits_leave_the_lanes_past_them_out and two texture_upload overflow tests).
  • Paired cold A/B benchmark on 10% of retail CS shaders (~269 cold NVIDIA PSOs, XCL_DIRECT_DXIL=1, isolated caches):
    • Old 4w × 1t static modulo slicing: 315.3 s
    • New 4w × 2t LPT: 167.8 s (1.88× faster; 8w × 2t measured 229.9 s due to SMT/L3 thrashing on 8 physical cores, confirming cores / 2 as the sweet spot).
  • Full live startup preparation run (XCL_DIRECT_DXIL=1, 704 used compute pipelines across 4 dynamic LPT workers): first 198 heaviest pipelines in 373 s (0.53/s), remaining 506 pipelines in 131 s (3.86/s — 7.3× acceleration through the tail, zero end-of-run stall, 504 s total).
  • Paired nvidia-dev base (eae015021c639866ab061cdff2e9daf8ba9daac5) 60 s smoke (XCL_DIRECT_DXIL=1, XCL_PREPARE_GRAPHICS=0): 1539 frames (PresentX 1539), 60 60 60 presents/2 s, 0 removals, 0 crashes, 17602 MB peak commit.

Regression run
main:

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1045 (PresentX 1045)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14930 MB

PR head (XCL_DIRECT_DXIL=1, XCL_PREPARE_GRAPHICS=0):

xcl-smoke v1
commit: 023395ae4cec59763b37334c2e6b51058643794e
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17977 MB

Not tested

  • AMD RDNA / Intel GPUs and Linux / Wine / vkd3d-proton (tested on Windows 11 + NVIDIA RTX 4070 SUPER only).
  • Loose .dxbc folder inputs for prepare_for_launch (pack path tested).

AI use

  • Antigravity (Gemini 4 Neon) for profiling, implementation, tests, benchmarking, and PR drafting; all builds, tests, benchmarks, and retail runs were executed locally on the hardware above.
**@⁠saintwolf** on GitHub · 2026-11-26 22:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906) `saintwolf:perf/nvidia-shader-prep` → `nvidia-dev` · +409 −32 · 3 files · 1 commits · open Speeds up startup shader preparation on NVIDIA GPUs by removing static-slice tail stalls, pack-RAM duplication across workers, and under-utilized pipeline concurrency. **What is in it** - `crates/xcl/src/gpu/pack.rs`: adds `Pack::seek_read` (random-access single-record read via `FileExt::seek_read`) and `Pack::record_len` so workers read individual records on demand without loading the entire shader pack into memory. - `crates/xcl/src/gpu/recomp/dxc.rs`: adds `set_memory_reserve(gb)` so `prepare_for_launch` can temporarily lower the DXC commit reserve (restored via RAII before title start). - `crates/xcl/src/shaders.rs`: - Replaces static worker slicing with dynamic LPT (largest-first) work-stealing over a single shared `--compute-worker` job stream (`0 MB` pack RAM per worker). - Tunes default worker pipeline concurrency to `XCL_PIPELINE_THREADS=2` and adds `compute_worker_count` targeting `cores / 2` concurrent compiles (1 per physical core, avoiding SMT/L3 thrashing) within a 1.5 GiB/worker commit budget. - Preserves per-entry D3D12 validation for cached `.pso` blobs so damaged or stale cache entries are always detected and rebuilt. - Sorts `precompile()` and `graphics_in_workers()` largest-first (LPT), deduplicates identical blobs in `precompile()`, lowers `dxc::set_memory_reserve(2)` during `prepare_for_launch` (restored to 6 GB via RAII before title start), and routes VS/PS/MS through `console_to_dxil_in` / `console_mesh_in` when `XCL_DIRECT_DXIL` is enabled. - Adds unit tests `parse_compute_job_accepts_three_numbers_and_rejects_malformed`, `compute_worker_count_saturates_cpu_within_commit_budget`, and `a_valid_canary_does_not_hide_a_second_stale_compute_blob`. **Tested** - Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver `32.0.16.2140`), AMD Ryzen 7 7800X3D (8 cores / 16 threads), `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC/DXIL `1.8.2502.11`. - `cargo test -p xcl --lib shaders:: -- --test-threads=1`: **18 passed, 0 failed, 0 ignored** (1 skipped: `pso_measurement_compiles_an_exact_synthetic_record`, Developer Mode required), including `a_valid_canary_does_not_hide_a_second_stale_compute_blob`. - `cargo test -p xcl --lib gpu::pack:: -- --test-threads=1`: **4 passed, 0 failed**. - `.\scripts\test.ps1` (debug): **1,690 passed** across the workspace with 0 failures in `shaders::`, `pack::`, `pso::`, or `dxc::` (3 pre-existing `nvidia-dev` failures: `gpu_compute_thread_limits_leave_the_lanes_past_them_out` and two `texture_upload` overflow tests). - Paired cold A/B benchmark on 10% of retail CS shaders (~269 cold NVIDIA PSOs, `XCL_DIRECT_DXIL=1`, isolated caches): - Old `4w × 1t` static modulo slicing: **315.3 s** - New `4w × 2t` LPT: **167.8 s** (**1.88× faster**; `8w × 2t` measured **229.9 s** due to SMT/L3 thrashing on 8 physical cores, confirming `cores / 2` as the sweet spot). - Full live startup preparation run (`XCL_DIRECT_DXIL=1`, 704 used compute pipelines across 4 dynamic LPT workers): first 198 heaviest pipelines in **373 s** (`0.53`/s), remaining 506 pipelines in **131 s** (`3.86`/s — **7.3× acceleration** through the tail, zero end-of-run stall, **504 s** total). - Paired `nvidia-dev` base (`eae015021c639866ab061cdff2e9daf8ba9daac5`) 60 s smoke (`XCL_DIRECT_DXIL=1`, `XCL_PREPARE_GRAPHICS=0`): `1539 frames (PresentX 1539)`, `60 60 60` presents/2 s, `0` removals, `0` crashes, `17602 MB` peak commit. **Regression run** `main`: ``` xcl-smoke v1 commit: e120925e3abc9956a8b9bae631969d32e8ccd43c gpu: NVIDIA GeForce RTX 4070 SUPER title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1045 (PresentX 1045) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14930 MB ``` PR head (`XCL_DIRECT_DXIL=1`, `XCL_PREPARE_GRAPHICS=0`): ``` xcl-smoke v1 commit: 023395ae4cec59763b37334c2e6b51058643794e gpu: NVIDIA GeForce RTX 4070 SUPER title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1602 (PresentX 1602) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17977 MB ``` **Not tested** - AMD RDNA / Intel GPUs and Linux / Wine / vkd3d-proton (tested on Windows 11 + NVIDIA RTX 4070 SUPER only). - Loose `.dxbc` folder inputs for `prepare_for_launch` (pack path tested). **AI use** - Antigravity (Gemini 4 Neon) for profiling, implementation, tests, benchmarking, and PR drafting; all builds, tests, benchmarks, and retail runs were executed locally on the hardware above.
Speeds up startup shader preparation on NVIDIA GPUs by removing static-slice tail stalls, pack-RAM duplication across workers, and under-utilized pipeline concurrency:

- Replaces static worker slicing with dynamic LPT (largest-first) work-stealing over a single shared --compute-worker job stream; workers read individual records via seek_read (0 MB pack RAM per worker).
- Tunes default worker pipeline concurrency to XCL_PIPELINE_THREADS=2 and adds compute_worker_count targeting cores / 2 concurrent compiles within a 1.5 GiB/worker commit budget (measured 1.88x faster cold CS PSO prep vs 4w x 1t).
- Keeps per-entry D3D12 validation for cached .pso blobs so a damaged or stale cache entry is always detected and rebuilt.
- Sorts precompile() and graphics_in_workers() largest-first, deduplicates identical blobs in precompile(), lowers dxc::set_memory_reserve(2) during prepare_for_launch (restored via RAII before title start), and routes VS/PS/MS through console_to_dxil_in / console_mesh_in when XCL_DIRECT_DXIL is enabled.
- Adds unit tests for compute job parsing, worker count sizing, and per-entry cache validation (_valid_canary_does_not_hide_a_second_stale_compute_blob).

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:15:37 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 22:52 UTC · original

On exact #2906 head 5224220c59262488b7bde3f15a1ddba968c054f1, the warm-cache shortcut can count a damaged compute PSO as prepared. After one cached blob passes D3D12 validation, Pipelines::make_one treats every later nonempty, in-cap file as reused without reading or validating it. The compute cache filename includes the DXIL hash, size and flags, but no driver or adapter identity. A mixed or damaged cache can therefore pass the one canary while another entry is unusable. The runtime may rebuild such an entry at first use; I did not measure that in a title.

I added a synthetic two-PSO test using a temporary cache and the NVIDIA D3D12 adapter. It warms distinct A and B, replaces only B's file with nonempty invalid bytes, then creates a fresh Pipelines instance and prepares A followed by B. On the unchanged PR code, cargo test --offline --locked -p xcl --lib a_valid_canary_does_not_hide_a_second_stale_compute_blob -- --test-threads=1 --nocapture failed: 0 passed, 1 failed, 0 ignored, 0 skipped. B stayed damaged while made=2, reused=2.

The small candidate below restores per-entry native validation while retaining this PR's worker scheduling and LPT changes. With it, B was repaired and made=2, reused=1; the test passed 1/0/0/0. cargo test --offline --locked -p xcl --lib shaders:: -- --test-threads=1 passed 18/0/0/0. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, rustc 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. No game files were used.

Restoring validation removes the reported 2.27 s warm-cache shortcut, so that timing needs a new measurement if this approach is adopted. A future skip path would need validity established per entry for the current adapter/driver, rather than inferred from one other blob. I have not run the full workspace suite or paired retail smoke for this local candidate.

Candidate correction and regression diff
diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs
index d543ece6..58fe1013 100644
--- a/crates/xcl/src/shaders.rs
+++ b/crates/xcl/src/shaders.rs
@@ -1254,9 +1254,6 @@ struct Pipelines {
     most: usize,
     /// DXIL bytes a pipeline is still handed to the driver (`XCL_PIPELINE_MAX_KB`, 8 MiB; 0: off)
     max_dxil: usize,
-    /// True once at least one cached `.pso` blob passed D3D12 validation on this device; remaining
-    /// non-empty `.pso` files in the same driver cache can then be skipped without D3D12 calls.
-    cache_verified: std::sync::atomic::AtomicBool,
     #[cfg(test)]
     cache_dir: Option<PathBuf>,
 }
@@ -1443,6 +1440,59 @@ mod pipeline_cap_tests {
             assert_eq!(pipelines.reused.load(Ordering::Relaxed), reused_before + 1);
         }
     }
+
+    #[test]
+    fn a_valid_canary_does_not_hide_a_second_stale_compute_blob() {
+        use super::{Pipelines, recomp, Ordering};
+        use crate::hle::d3d12x::real::driver_cache;
+        use std::time::{SystemTime, UNIX_EPOCH};
+
+        struct Scratch(std::path::PathBuf);
+        impl Drop for Scratch {
+            fn drop(&mut self) { let _ = std::fs::remove_dir_all(&self.0); }
+        }
+        if let Err(reason) = recomp::dxc::location() {
+            recomp::runner::skip_test(&format!("no DXC: {reason}"));
+            return;
+        }
+        let mut warm = match Pipelines::for_adapter("NVIDIA") {
+            Ok(p) => p,
+            Err(reason) => {
+                recomp::runner::skip_test(&format!("no NVIDIA D3D12 device: {reason}"));
+                return;
+            }
+        };
+        let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();
+        let scratch = Scratch(std::env::temp_dir().join(format!("xcl-two-pso-{nonce}")));
+        std::fs::create_dir(&scratch.0).expect("scratch cache directory");
+        warm.cache_dir = Some(scratch.0.clone());
+
+        let compile = |value| {
+            let hlsl = format!("RWByteAddressBuffer mem : register(u2); [numthreads(1,1,1)] void main() {{ mem.Store(0, {value}); }}");
+            let dxil = recomp::dxc::compile(&hlsl, "main", "cs_6_6", &[]).expect("DXC compile");
+            recomp::pso::Compiled { dispatch_chain: None, dxil, samplers: vec![] }
+        };
+        let (a, b) = (compile(7), compile(11));
+        assert_ne!(a.dxil, b.dxil);
+        let b_path = scratch.0.join(driver_cache::name_for(&b.dxil, 0, false));
+        warm.make(&a);
+        warm.make(&b);
+        assert!(b_path.is_file());
+        std::fs::write(&b_path, b"damaged nonempty driver blob").expect("damage B");
+
+        let mut fresh = Pipelines::for_adapter("NVIDIA").expect("same NVIDIA device");
+        fresh.cache_dir = Some(scratch.0.clone());
+        fresh.make(&a); // valid canary
+        assert_eq!(fresh.reused.load(Ordering::Relaxed), 1);
+        fresh.make(&b); // corrupt entry must be rebuilt, not reported as reused
+        let b_bytes = std::fs::read(&b_path).expect("B cache file");
+        let reused = fresh.reused.load(Ordering::Relaxed);
+        let made = fresh.made.load(Ordering::Relaxed);
+        println!("second blob still damaged: {}, made={made}, reused={reused}", b_bytes == b"damaged nonempty driver blob");
+        assert_ne!(b_bytes, b"damaged nonempty driver blob");
+        assert_eq!(reused, 1);
+        assert_eq!(made, 2);
+    }
 }
 
 // D3D12 devices and root signatures are free-threaded
@@ -1480,7 +1530,6 @@ impl Pipelines {
                 running: (Mutex::new(0), std::sync::Condvar::new()),
                 most,
                 max_dxil,
-                cache_verified: std::sync::atomic::AtomicBool::new(false),
                 #[cfg(test)]
                 cache_dir: None,
             })
@@ -1556,7 +1605,6 @@ impl Pipelines {
         };
         use crate::hle::d3d12x::real::driver_cache;
         let over_cap = self.max_dxil != 0 && dxil.len() > self.max_dxil;
-        let has_override = path_override.is_some();
         let path = path_override.or_else(|| {
             #[cfg(test)]
             if let Some(dir) = self.cache_dir.as_deref() {
@@ -1564,19 +1612,6 @@ impl Pipelines {
             }
             driver_cache::path_for(dxil, desc.Flags.0, chained)
         });
-        // Fast path for resumed / warm runs: once one canary `.pso` blob has passed D3D12
-        // validation on this device, trust other existing non-empty in-cap `.pso` files without
-        // paying `CreateComputePipelineState` + `GetCachedBlob` on thousands of already-cached blobs.
-        if !over_cap && !has_override && self.cache_verified.load(Ordering::Acquire) {
-            if let Some(p) = path.as_deref() {
-                if std::fs::metadata(p).is_ok_and(|m| m.len() > 0) {
-                    self.reused.fetch_add(1, Ordering::Relaxed);
-                    self.made.fetch_add(1, Ordering::Relaxed);
-                    drop(std::mem::ManuallyDrop::into_inner(desc.pRootSignature));
-                    return;
-                }
-            }
-        }
         let mut cached = path.as_deref().and_then(driver_cache::load);
         // over the cap and no blob from an earlier run: the driver's compile of this one takes
         // tens of minutes and gigabytes; the pass finishes without it, and the runtime builds it
@@ -1636,7 +1671,6 @@ impl Pipelines {
             return;
         }
         let r = if let Some(pso) = from_cache {
-            self.cache_verified.store(true, Ordering::Release);
             self.reused.fetch_add(1, Ordering::Relaxed);
             Ok(pso)
         } else {

AI use: Codex (GPT-6.2 Sol) traced the cache path, wrote and ran the regression and candidate, and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-26 22:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7205055359) On exact [#2906 head `5224220c59262488b7bde3f15a1ddba968c054f1`](https://github.com/xcl-dev/xcl/commit/5224220c59262488b7bde3f15a1ddba968c054f1), the warm-cache shortcut can count a damaged compute PSO as prepared. After one cached blob passes D3D12 validation, [`Pipelines::make_one`](https://github.com/xcl-dev/xcl/blob/5224220c59262488b7bde3f15a1ddba968c054f1/crates/xcl/src/shaders.rs#L1570-L1578) treats every later nonempty, in-cap file as reused without reading or validating it. The [compute cache filename](https://github.com/xcl-dev/xcl/blob/5224220c59262488b7bde3f15a1ddba968c054f1/crates/xcl/src/hle/d3d12x/real.rs#L5176-L5180) includes the DXIL hash, size and flags, but no driver or adapter identity. A mixed or damaged cache can therefore pass the one canary while another entry is unusable. The runtime may rebuild such an entry at first use; I did not measure that in a title. I added a synthetic two-PSO test using a temporary cache and the NVIDIA D3D12 adapter. It warms distinct A and B, replaces only B's file with nonempty invalid bytes, then creates a fresh `Pipelines` instance and prepares A followed by B. On the **unchanged PR code**, `cargo test --offline --locked -p xcl --lib a_valid_canary_does_not_hide_a_second_stale_compute_blob -- --test-threads=1 --nocapture` **failed: 0 passed, 1 failed, 0 ignored, 0 skipped**. B stayed damaged while `made=2, reused=2`. The small candidate below restores per-entry native validation while retaining this PR's worker scheduling and LPT changes. With it, B was repaired and `made=2, reused=1`; the test passed **1/0/0/0**. `cargo test --offline --locked -p xcl --lib shaders:: -- --test-threads=1` passed **18/0/0/0**. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, rustc 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. No game files were used. Restoring validation removes the reported 2.27 s warm-cache shortcut, so that timing needs a new measurement if this approach is adopted. A future skip path would need validity established **per entry** for the current adapter/driver, rather than inferred from one other blob. I have not run the full workspace suite or paired retail smoke for this local candidate. <details><summary>Candidate correction and regression diff</summary> ```diff diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs index d543ece6..58fe1013 100644 --- a/crates/xcl/src/shaders.rs +++ b/crates/xcl/src/shaders.rs @@ -1254,9 +1254,6 @@ struct Pipelines { most: usize, /// DXIL bytes a pipeline is still handed to the driver (`XCL_PIPELINE_MAX_KB`, 8 MiB; 0: off) max_dxil: usize, - /// True once at least one cached `.pso` blob passed D3D12 validation on this device; remaining - /// non-empty `.pso` files in the same driver cache can then be skipped without D3D12 calls. - cache_verified: std::sync::atomic::AtomicBool, #[cfg(test)] cache_dir: Option<PathBuf>, } @@ -1443,6 +1440,59 @@ mod pipeline_cap_tests { assert_eq!(pipelines.reused.load(Ordering::Relaxed), reused_before + 1); } } + + #[test] + fn a_valid_canary_does_not_hide_a_second_stale_compute_blob() { + use super::{Pipelines, recomp, Ordering}; + use crate::hle::d3d12x::real::driver_cache; + use std::time::{SystemTime, UNIX_EPOCH}; + + struct Scratch(std::path::PathBuf); + impl Drop for Scratch { + fn drop(&mut self) { let _ = std::fs::remove_dir_all(&self.0); } + } + if let Err(reason) = recomp::dxc::location() { + recomp::runner::skip_test(&format!("no DXC: {reason}")); + return; + } + let mut warm = match Pipelines::for_adapter("NVIDIA") { + Ok(p) => p, + Err(reason) => { + recomp::runner::skip_test(&format!("no NVIDIA D3D12 device: {reason}")); + return; + } + }; + let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(); + let scratch = Scratch(std::env::temp_dir().join(format!("xcl-two-pso-{nonce}"))); + std::fs::create_dir(&scratch.0).expect("scratch cache directory"); + warm.cache_dir = Some(scratch.0.clone()); + + let compile = |value| { + let hlsl = format!("RWByteAddressBuffer mem : register(u2); [numthreads(1,1,1)] void main() {{ mem.Store(0, {value}); }}"); + let dxil = recomp::dxc::compile(&hlsl, "main", "cs_6_6", &[]).expect("DXC compile"); + recomp::pso::Compiled { dispatch_chain: None, dxil, samplers: vec![] } + }; + let (a, b) = (compile(7), compile(11)); + assert_ne!(a.dxil, b.dxil); + let b_path = scratch.0.join(driver_cache::name_for(&b.dxil, 0, false)); + warm.make(&a); + warm.make(&b); + assert!(b_path.is_file()); + std::fs::write(&b_path, b"damaged nonempty driver blob").expect("damage B"); + + let mut fresh = Pipelines::for_adapter("NVIDIA").expect("same NVIDIA device"); + fresh.cache_dir = Some(scratch.0.clone()); + fresh.make(&a); // valid canary + assert_eq!(fresh.reused.load(Ordering::Relaxed), 1); + fresh.make(&b); // corrupt entry must be rebuilt, not reported as reused + let b_bytes = std::fs::read(&b_path).expect("B cache file"); + let reused = fresh.reused.load(Ordering::Relaxed); + let made = fresh.made.load(Ordering::Relaxed); + println!("second blob still damaged: {}, made={made}, reused={reused}", b_bytes == b"damaged nonempty driver blob"); + assert_ne!(b_bytes, b"damaged nonempty driver blob"); + assert_eq!(reused, 1); + assert_eq!(made, 2); + } } // D3D12 devices and root signatures are free-threaded @@ -1480,7 +1530,6 @@ impl Pipelines { running: (Mutex::new(0), std::sync::Condvar::new()), most, max_dxil, - cache_verified: std::sync::atomic::AtomicBool::new(false), #[cfg(test)] cache_dir: None, }) @@ -1556,7 +1605,6 @@ impl Pipelines { }; use crate::hle::d3d12x::real::driver_cache; let over_cap = self.max_dxil != 0 && dxil.len() > self.max_dxil; - let has_override = path_override.is_some(); let path = path_override.or_else(|| { #[cfg(test)] if let Some(dir) = self.cache_dir.as_deref() { @@ -1564,19 +1612,6 @@ impl Pipelines { } driver_cache::path_for(dxil, desc.Flags.0, chained) }); - // Fast path for resumed / warm runs: once one canary `.pso` blob has passed D3D12 - // validation on this device, trust other existing non-empty in-cap `.pso` files without - // paying `CreateComputePipelineState` + `GetCachedBlob` on thousands of already-cached blobs. - if !over_cap && !has_override && self.cache_verified.load(Ordering::Acquire) { - if let Some(p) = path.as_deref() { - if std::fs::metadata(p).is_ok_and(|m| m.len() > 0) { - self.reused.fetch_add(1, Ordering::Relaxed); - self.made.fetch_add(1, Ordering::Relaxed); - drop(std::mem::ManuallyDrop::into_inner(desc.pRootSignature)); - return; - } - } - } let mut cached = path.as_deref().and_then(driver_cache::load); // over the cap and no blob from an earlier run: the driver's compile of this one takes // tens of minutes and gigabytes; the pass finishes without it, and the runtime builds it @@ -1636,7 +1671,6 @@ impl Pipelines { return; } let r = if let Some(pso) = from_cache { - self.cache_verified.store(true, Ordering::Release); self.reused.fetch_add(1, Ordering::Relaxed); Ok(pso) } else { ``` </details> AI use: Codex (GPT-6.2 Sol) traced the cache path, wrote and ran the regression and candidate, and drafted this report.
Author
Owner

@⁠saintwolf on GitHub · 2026-11-27 00:15 UTC · original

Good catch — thank you for the concrete repro. Removed the cache_verified canary shortcut in 023395ae so every cached compute .pso blob is validated per entry through D3D12 (keeping the dynamic LPT work-stealing, seek_read 0 MB pack RAM, cores / 2 worker scaling, and XCL_PIPELINE_THREADS=2 cold-prep improvements intact).

Added shaders::pipeline_cap_tests::a_valid_canary_does_not_hide_a_second_stale_compute_blob covering this exact scenario (made=2, reused=1, damaged B rebuilt on disk), verified cargo test -p xcl --lib shaders:: -- --test-threads=1 (18 passed, 0 failed, 0 ignored, 1 skipped for Developer Mode), re-ran the 60 s regression smoke on 023395ae, and updated the PR description accordingly. Any future warm-cache skip can be tackled separately with per-entry adapter/driver-keyed validation.

**@⁠saintwolf** on GitHub · 2026-11-27 00:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7206316017) Good catch — thank you for the concrete repro. Removed the `cache_verified` canary shortcut in `023395ae` so every cached compute `.pso` blob is validated per entry through D3D12 (keeping the dynamic LPT work-stealing, `seek_read` 0 MB pack RAM, `cores / 2` worker scaling, and `XCL_PIPELINE_THREADS=2` cold-prep improvements intact). Added `shaders::pipeline_cap_tests::a_valid_canary_does_not_hide_a_second_stale_compute_blob` covering this exact scenario (`made=2, reused=1`, damaged `B` rebuilt on disk), verified `cargo test -p xcl --lib shaders:: -- --test-threads=1` (`18 passed, 0 failed, 0 ignored`, 1 skipped for Developer Mode), re-ran the 60 s regression smoke on `023395ae`, and updated the PR description accordingly. Any future warm-cache skip can be tackled separately with per-entry adapter/driver-keyed validation.
Author
Owner

@⁠ettehn on GitHub · 2026-11-27 00:21 UTC · original

The new dynamic worker count has the same byte/MiB mismatch as the older worker selection tracked by #2705. On 023395ae, host::system_commit() returns bytes. The dynamic caller passes that difference directly to compute_worker_count, which divides by 1,536 MiB. The unit test calls the helper with values already in MiB, so it misses the caller mismatch.

I compiled the exact helper from this head on Windows and fed it synthetic commit snapshots using the caller's units. With 16 logical CPUs, 2 pipeline threads per worker and 3 GiB free, the current call selects 4 workers versus 2 after converting the bytes to MiB. At 512 MiB free it selects 4 versus 1. No system memory pressure was induced. A shared bytes-to-MiB conversion at both host-commit call sites, plus a test starting from bytes, would cover this path without changing the explicit XCL_PREPARE_WORKERS override.

The clean head also passed the shaders:: filter on native Windows / RTX 5070 Ti Laptop (driver 621.24, Rust 1.97.1 MSVC, DXC 1.8.2502.11), including the stale-blob regression. Harness totals: 18 passed, 0 failed, 0 ignored, with one of those 18 returning early because XCL_SAMPLE_RPF was unset. OpenAI Codex (6.2sol) assisted with verification.

**@⁠ettehn** on GitHub · 2026-11-27 00:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7206398726) The new dynamic worker count has the same byte/MiB mismatch as the older worker selection tracked by #2705. On `023395ae`, [`host::system_commit()`](https://github.com/xcl-dev/xcl/blob/023395ae4cec59763b37334c2e6b51058643794e/crates/xcl/src/host.rs#L12-L22) returns bytes. The [dynamic caller](https://github.com/xcl-dev/xcl/blob/023395ae4cec59763b37334c2e6b51058643794e/crates/xcl/src/shaders.rs#L1984-L1991) passes that difference directly to [`compute_worker_count`](https://github.com/xcl-dev/xcl/blob/023395ae4cec59763b37334c2e6b51058643794e/crates/xcl/src/shaders.rs#L1963-L1969), which divides by 1,536 MiB. The unit test calls the helper with values already in MiB, so it misses the caller mismatch. I compiled the exact helper from this head on Windows and fed it synthetic commit snapshots using the caller's units. With 16 logical CPUs, 2 pipeline threads per worker and 3 GiB free, the current call selects **4 workers** versus **2** after converting the bytes to MiB. At 512 MiB free it selects **4** versus **1**. No system memory pressure was induced. A shared bytes-to-MiB conversion at both host-commit call sites, plus a test starting from bytes, would cover this path without changing the explicit `XCL_PREPARE_WORKERS` override. The clean head also passed the `shaders::` filter on native Windows / RTX 5070 Ti Laptop (driver 621.24, Rust 1.97.1 MSVC, DXC 1.8.2502.11), including the stale-blob regression. Harness totals: 18 passed, 0 failed, 0 ignored, with one of those 18 returning early because `XCL_SAMPLE_RPF` was unset. OpenAI Codex (6.2sol) assisted with verification.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-27 00:35 UTC · original

Tested: Clean 023395ae4cec59763b37334c2e6b51058643794e, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Ran xcl run <synthetic-title-folder> -- --hello on exact head and parent eae015021c639866ab061cdff2e9daf8ba9daac5, with fresh caches, Arc A770, Direct DXIL, two worker processes, two pipeline threads per worker and startup graphics preparation off. Both produced the same eight driver-cache filenames and zero worker failures. The head reported eight unique jobs from a 12-record pack containing four duplicates. In this matched rerun the worker phase took about 1.43 s on parent and 0.33 s on head. Both launchers exited 1 on the same synthetic RSSetDepthBiasX pixel check, and both skipped optional voices because no audio device was available.

Not tested: Retail performance, automatic worker sizing under pressure, startup graphics preparation, and the full suite.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and drafted the report.

**@⁠JJAutoCompare** on GitHub · 2026-11-27 00:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7206593138) **Tested:** Clean `023395ae4cec59763b37334c2e6b51058643794e`, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Ran `xcl run <synthetic-title-folder> -- --hello` on exact head and parent `eae015021c639866ab061cdff2e9daf8ba9daac5`, with fresh caches, Arc A770, Direct DXIL, two worker processes, two pipeline threads per worker and startup graphics preparation off. Both produced the same eight driver-cache filenames and zero worker failures. The head reported eight unique jobs from a 12-record pack containing four duplicates. In this matched rerun the worker phase took about 1.43 s on parent and 0.33 s on head. Both launchers exited 1 on the same synthetic `RSSetDepthBiasX` pixel check, and both skipped optional voices because no audio device was available. **Not tested:** Retail performance, automatic worker sizing under pressure, startup graphics preparation, and the full suite. **AI use:** T3 Code / Codex (`gpt-6.2-sol`) ran and reran the checks and drafted the report.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:07 UTC · original

On head 023395ae4cec59763b37334c2e6b51058643794e, changing XCL_PREPARE_WORKERS changed whether startup enforced the explicit pipeline size cap.

I built the unmodified head with cargo build --locked -p xcl --bin xcl and ran xcl run <synthetic-title> -- --hello. The repository test title contained a synthetic shaders.rpf with one valid compute shader, 64 threads per group, and the instructions s_mov_b32 and s_endpgm. The DXIL was 4,452 bytes. Both runs used fresh, separate data and shader caches, XCL_PIPELINE_MAX_KB=1, XCL_PIPELINE_THREADS=1, XCL_PREPARE_GRAPHICS=0, and XCL_PSO_DISK_CACHE_MIN_MS=0.

XCL_PREPARE_WORKERS Preparation result Launcher result
1 In-process preparation reported one pipeline over the cap. Exited 2 before guest entry.
2 The dynamic queue used one child for the single job and reported 1 compute pipelines done and zero failed workers. The guest ran to completion, exit 0.

The expected driver blob was absent in both capped runs. With the default cap and a fresh cache, the standalone pipeline command created one native pipeline and its driver blob for the same pack. The worker currently acknowledges each input line after calling pipelines.make, including when the size cap prevents creation. Reporting capped jobs separately and propagating that status to launch preparation would make the two paths agree.

All inputs were synthetic. The test covers the startup preparation gate. Retail title behavior was outside this run.

AI use: OpenAI Codex (GPT-6.2 Astra) generated the synthetic pack, ran the controls, inspected the source, and drafted this report.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207031728) On head `023395ae4cec59763b37334c2e6b51058643794e`, changing `XCL_PREPARE_WORKERS` changed whether startup enforced the explicit pipeline size cap. I built the unmodified head with `cargo build --locked -p xcl --bin xcl` and ran `xcl run <synthetic-title> -- --hello`. The repository test title contained a synthetic `shaders.rpf` with one valid compute shader, 64 threads per group, and the instructions `s_mov_b32` and `s_endpgm`. The DXIL was 4,452 bytes. Both runs used fresh, separate data and shader caches, `XCL_PIPELINE_MAX_KB=1`, `XCL_PIPELINE_THREADS=1`, `XCL_PREPARE_GRAPHICS=0`, and `XCL_PSO_DISK_CACHE_MIN_MS=0`. | XCL_PREPARE_WORKERS | Preparation result | Launcher result | |---|---|---| | 1 | In-process preparation reported one pipeline over the cap. | Exited 2 before guest entry. | | 2 | The dynamic queue used one child for the single job and reported `1 compute pipelines done` and zero failed workers. | The guest ran to completion, exit 0. | The expected driver blob was absent in both capped runs. With the default cap and a fresh cache, the standalone pipeline command created one native pipeline and its driver blob for the same pack. The worker currently acknowledges each input line after calling `pipelines.make`, including when the size cap prevents creation. Reporting capped jobs separately and propagating that status to launch preparation would make the two paths agree. All inputs were synthetic. The test covers the startup preparation gate. Retail title behavior was outside this run. AI use: OpenAI Codex (GPT-6.2 Astra) generated the synthetic pack, ran the controls, inspected the source, and drafted this report.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:12 UTC · original

Follow-up to my capped-job report: a local candidate keeps an acknowledgement for scheduling progress but separately makes a worker exit unsuccessfully if a translation, size-cap or native-pipeline failure occurred. The parent checks acknowledged job count and the exit status of workers that actually started.

In synthetic subprocess checks:

  • Two normal jobs and two workers: 2/2 acknowledged, guest exit 0.
  • Two capped jobs: 2/2 acknowledged, both workers reported failure, launch exited 2.
  • With a test-only missing-executable injection on one worker: the other worker drained both jobs, 2/2 acknowledged, and launch exited 0.
  • With that injection on all workers: 0/2 acknowledged and launch exited 2.

The injection is test-only and not part of the candidate. These runs validate the scheduling and failure gates, not GTA VI loading time or retail behavior. The distinction between requested workers and successfully started workers matters: a failed spawn need not fail an otherwise fully completed job set.

AI use: OpenAI Codex with GPT-6.2 Astra designed and ran the synthetic checks and reviewed the candidate; Codex coordinated and prepared this report.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207096870) Follow-up to my capped-job report: a local candidate keeps an acknowledgement for scheduling progress but separately makes a worker exit unsuccessfully if a translation, size-cap or native-pipeline failure occurred. The parent checks acknowledged job count and the exit status of workers that actually started. In synthetic subprocess checks: - Two normal jobs and two workers: 2/2 acknowledged, guest exit 0. - Two capped jobs: 2/2 acknowledged, both workers reported failure, launch exited 2. - With a test-only missing-executable injection on one worker: the other worker drained both jobs, 2/2 acknowledged, and launch exited 0. - With that injection on all workers: 0/2 acknowledged and launch exited 2. The injection is test-only and not part of the candidate. These runs validate the scheduling and failure gates, not GTA VI loading time or retail behavior. The distinction between requested workers and successfully started workers matters: a failed spawn need not fail an otherwise fully completed job set. AI use: OpenAI Codex with GPT-6.2 Astra designed and ran the synthetic checks and reviewed the candidate; Codex coordinated and prepared this report.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:16 UTC · original

I checked an interaction with #2931 using a local integration of the two PRs. Two overlapping test/scheduling hunks needed manual resolution; this is not a test of either standalone head. Trace-only instrumentation counted shared-helper starts and fallback-helper starts.

With the same four synthetic split shaders and separate fresh caches:

  • Offline preparation started two persistent shared helpers and enqueued all 16 pieces through that pool.
  • The actual --compute-worker path started no shared helpers and instead created four fallback helper groups, with eight distinct helper threads for the same 16 pieces.

Both runs completed successfully and produced the same set of distinct PSO filenames; the worker acknowledged all four jobs. Source review indicates that the shared pool currently starts inside precompile(), while compute_worker() calls Pipelines::make directly. If these PRs are combined, opening the shared pool around the worker loop may preserve the intended bound during startup as well.

This is synthetic integration evidence, not a measured GTA VI thread count or loading-time regression. AI use: OpenAI Codex with GPT-6.2 Astra integrated and ran the checks; Codex coordinated and prepared this report.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207154966) I checked an interaction with #2931 using a local integration of the two PRs. Two overlapping test/scheduling hunks needed manual resolution; this is not a test of either standalone head. Trace-only instrumentation counted shared-helper starts and fallback-helper starts. With the same four synthetic split shaders and separate fresh caches: - Offline preparation started two persistent shared helpers and enqueued all 16 pieces through that pool. - The actual `--compute-worker` path started no shared helpers and instead created four fallback helper groups, with eight distinct helper threads for the same 16 pieces. Both runs completed successfully and produced the same set of distinct PSO filenames; the worker acknowledged all four jobs. Source review indicates that the shared pool currently starts inside `precompile()`, while `compute_worker()` calls `Pipelines::make` directly. If these PRs are combined, opening the shared pool around the worker loop may preserve the intended bound during startup as well. This is synthetic integration evidence, not a measured GTA VI thread count or loading-time regression. AI use: OpenAI Codex with GPT-6.2 Astra integrated and ran the checks; Codex coordinated and prepared this report.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:28 UTC · original

A scope correction to my #2931 interaction test above: the four synthetic compute records split into 16 pieces with --windows 1 and XCL_DIRECT_SPLIT_INSTRUCTIONS=12. Those helper-thread counts apply to that setup.

On unmodified #2906 head 023395ae4cec59763b37334c2e6b51058643794e, omitting --windows selected four windows. Both implicit and explicit four-window runs built four whole pipelines at the same forced threshold. A diagnostic-only build showed why: each program had an indivisible component of 52 IR instructions; the planner keeps the program whole when that exceeds four times the limit (48).

With four windows and a forced limit of 16, the same four records again split into 16 pieces. Through xcl run on the repository synthetic title, one configured preparation worker selected in-process preparation and built those 16 pieces plus four whole pipelines. Two configured workers selected the dynamic path: the same seven distinct piece blobs were present, but the four additional whole-pipeline blobs were absent. Both guests exited 0. This last case is the existing whole-form preparation issue tracked by #2794.

No retail title was used. These tests varied a synthetic split threshold and did not measure loading time or repeat the helper-thread count at four windows.

AI use: OpenAI Codex (GPT-6.2 Astra) ran the comparisons and prepared this follow-up.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207321832) A scope correction to my #2931 interaction test above: the four synthetic compute records split into 16 pieces with `--windows 1` and `XCL_DIRECT_SPLIT_INSTRUCTIONS=12`. Those helper-thread counts apply to that setup. On unmodified #2906 head `023395ae4cec59763b37334c2e6b51058643794e`, omitting `--windows` selected four windows. Both implicit and explicit four-window runs built four whole pipelines at the same forced threshold. A diagnostic-only build showed why: each program had an indivisible component of 52 IR instructions; the planner keeps the program whole when that exceeds four times the limit (48). With four windows and a forced limit of 16, the same four records again split into 16 pieces. Through `xcl run` on the repository synthetic title, one configured preparation worker selected in-process preparation and built those 16 pieces plus four whole pipelines. Two configured workers selected the dynamic path: the same seven distinct piece blobs were present, but the four additional whole-pipeline blobs were absent. Both guests exited 0. This last case is the existing whole-form preparation issue tracked by #2794. No retail title was used. These tests varied a synthetic split threshold and did not measure loading time or repeat the helper-thread count at four windows. AI use: OpenAI Codex (GPT-6.2 Astra) ran the comparisons and prepared this follow-up.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:32 UTC · original

Another startup-discovery case on head 023395ae4cec59763b37334c2e6b51058643794e: a valid compute record named Asset01 starts with AS but does not have an AS_ stage prefix. The worker collector rejects it before checking the shader payload, while in-process preparation classifies the payload as compute.

Three native runs used the repository synthetic title, the same valid compute bytes, fresh separate caches and data roots, and XCL_PREPARE_ALL=1. The only pack difference was the seven-byte record name; all guests exited successfully.

Record name Configured workers Result
Asset01 1 In-process preparation built one pipeline.
Asset01 2 No compute job or disk PSO was produced.
CS_Test 2 One job and one disk PSO were produced.

The two successful builds produced the same PSO key. The finding concerns prewarming only; the test does not establish whether retail packs contain such names or whether gameplay stalls. Checking the separator before interpreting a stage prefix would protect this example; inspecting the container stage remains the reliable choice for arbitrary names.

AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the synthetic controls; Codex coordinated and prepared this follow-up.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207374693) Another startup-discovery case on head `023395ae4cec59763b37334c2e6b51058643794e`: a valid compute record named `Asset01` starts with `AS` but does not have an `AS_` stage prefix. The worker collector rejects it before checking the shader payload, while in-process preparation classifies the payload as compute. Three native runs used the repository synthetic title, the same valid compute bytes, fresh separate caches and data roots, and `XCL_PREPARE_ALL=1`. The only pack difference was the seven-byte record name; all guests exited successfully. | Record name | Configured workers | Result | | --- | --- | --- | | `Asset01` | 1 | In-process preparation built one pipeline. | | `Asset01` | 2 | No compute job or disk PSO was produced. | | `CS_Test` | 2 | One job and one disk PSO were produced. | The two successful builds produced the same PSO key. The finding concerns prewarming only; the test does not establish whether retail packs contain such names or whether gameplay stalls. Checking the separator before interpreting a stage prefix would protect this example; inspecting the container stage remains the reliable choice for arbitrary names. AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the synthetic controls; Codex coordinated and prepared this follow-up.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 01:36 UTC · original

Follow-up to the Asset01 report: I tested a local stage-token change that accepts a name as an explicit stage prefix only when the recognized token is followed by _ and a nonempty suffix. Noncanonical names fall through to the existing container-stage inspection; canonical names keep the fast path.

The pack tests passed 5/5, covering all eight recognized tokens, namespaced names and ASCII case. Four synthetic title launches with worker preparation exited 0: Asset01, fx:cs_Test, and CS_Test each produced the same compute PSO; asset_pixel with a real pixel-shader payload produced no compute PSO. The candidate was independently reviewed.

This fixes accidental prefix collisions, not every possible name/payload disagreement. For example, a compute payload explicitly named PS_Test still follows the existing trusted canonical-name fast path. Retail naming, startup cost and GTA VI behavior were not measured.

AI use: OpenAI Codex with GPT-6.2 Astra wrote, tested and reviewed the local candidate; Codex coordinated and prepared this follow-up.

**@⁠andrewDoing** on GitHub · 2026-11-27 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7207425774) Follow-up to the `Asset01` report: I tested a local stage-token change that accepts a name as an explicit stage prefix only when the recognized token is followed by `_` and a nonempty suffix. Noncanonical names fall through to the existing container-stage inspection; canonical names keep the fast path. The pack tests passed 5/5, covering all eight recognized tokens, namespaced names and ASCII case. Four synthetic title launches with worker preparation exited 0: `Asset01`, `fx:cs_Test`, and `CS_Test` each produced the same compute PSO; `asset_pixel` with a real pixel-shader payload produced no compute PSO. The candidate was independently reviewed. This fixes accidental prefix collisions, not every possible name/payload disagreement. For example, a compute payload explicitly named `PS_Test` still follows the existing trusted canonical-name fast path. Retail naming, startup cost and GTA VI behavior were not measured. AI use: OpenAI Codex with GPT-6.2 Astra wrote, tested and reviewed the local candidate; Codex coordinated and prepared this follow-up.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 02:41 UTC · original

I checked the loose-input case listed under Not tested on unmodified head 023395ae4cec59763b37334c2e6b51058643794e, using the repository synthetic title and one valid nested compute shader at shaders/nested/Asset01.dxbc, with no shaders.rpf. Each run used fresh data and shader caches and the title's required --hello argument.

With XCL_PREPARE_WORKERS=1 and separately with =2, preparation compiled one shader with zero errors or skips, produced the same PSO cache filename, and the synthetic guest exited 0 with zero failures. Loose inputs remain in-process in this path. This differs from my earlier packed Asset01 report, where the dynamic worker collector omitted the record.

The native driver blobs were not byte-identical across runs, so the comparison is of the cache filename and successful behavior, not blob bytes. No retail title or GTA VI loading time was tested.

AI use: OpenAI Codex with GPT-6.2 Astra ran the synthetic checks; Codex coordinated and prepared this follow-up.

**@⁠andrewDoing** on GitHub · 2026-11-27 02:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7208354357) I checked the loose-input case listed under Not tested on unmodified head `023395ae4cec59763b37334c2e6b51058643794e`, using the repository synthetic title and one valid nested compute shader at `shaders/nested/Asset01.dxbc`, with no `shaders.rpf`. Each run used fresh data and shader caches and the title's required `--hello` argument. With `XCL_PREPARE_WORKERS=1` and separately with `=2`, preparation compiled one shader with zero errors or skips, produced the same PSO cache filename, and the synthetic guest exited 0 with zero failures. Loose inputs remain in-process in this path. This differs from my earlier packed `Asset01` report, where the dynamic worker collector omitted the record. The native driver blobs were not byte-identical across runs, so the comparison is of the cache filename and successful behavior, not blob bytes. No retail title or GTA VI loading time was tested. AI use: OpenAI Codex with GPT-6.2 Astra ran the synthetic checks; Codex coordinated and prepared this follow-up.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 02:48 UTC · original

Another synthetic CLI summary case on head 023395ae4cec59763b37334c2e6b51058643794e: the duplicate counter can increment before --only stage filtering, so it can describe a shader as cached even when no requested-stage shader was compiled and the cache remains empty.

With fresh caches and one valid synthetic compute blob, --only PS reported 0 compiled / 0 cached and wrote no DXIL. With two identical copies, --only PS reported 0 compiled / 1 already cached but still wrote no DXIL. As a control, the same two copies with --only CS reported 1 compiled / 1 cached and wrote one file. All runs exited 0.

This finding concerns the summary, not missing requested-stage output or demonstrated GTA VI behavior. The worker-job duplicate test in the discussion covers a different path.

AI use: OpenAI Codex with GPT-6.2 Astra ran the synthetic checks; Codex coordinated and prepared this follow-up.

**@⁠andrewDoing** on GitHub · 2026-11-27 02:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7208450374) Another synthetic CLI summary case on head `023395ae4cec59763b37334c2e6b51058643794e`: the duplicate counter can increment before `--only` stage filtering, so it can describe a shader as cached even when no requested-stage shader was compiled and the cache remains empty. With fresh caches and one valid synthetic compute blob, `--only PS` reported 0 compiled / 0 cached and wrote no DXIL. With two identical copies, `--only PS` reported 0 compiled / 1 already cached but still wrote no DXIL. As a control, the same two copies with `--only CS` reported 1 compiled / 1 cached and wrote one file. All runs exited 0. This finding concerns the summary, not missing requested-stage output or demonstrated GTA VI behavior. The worker-job duplicate test in the discussion covers a different path. AI use: OpenAI Codex with GPT-6.2 Astra ran the synthetic checks; Codex coordinated and prepared this follow-up.
Author
Owner

@⁠LocranKing on GitHub · 2026-11-27 03:56 UTC · original

Paired measurements of PR #2906 (023395ae merged with nvidia-dev ecc0bb57) on a 6-core / 12-thread AMD Ryzen 5 5500 + RTX 3060 Ti (8 GB, driver 621.40), Windows 11 build 26300, DXC 1.9.2602.17.

On this 6-core CPU, PR #2906 was ~2.1× slower than nvidia-dev (ecc0bb57) in both warm startup preparation and cold --used-only worker precompilation:

1. Warm startup preparation (xcl run, identical seed-lockhart cache snapshot)

Cache snapshot had 1,296 used-pipelines, 1,572 used-shaders, and 3,206 cached driver blobs (XCL_DIRECT_DXIL=1, XCL_PREPARE_GRAPHICS=0).

tree worker configuration compute pipeline prep time total prep ready time
nvidia-dev (ecc0bb57, run 1) 8 worker processes 24 s 32.8 s
nvidia-dev (ecc0bb57, run 2) 8 worker processes 22 s 31.1 s
PR #2906 (023395ae + ecc0bb57) 3 worker processes (2 threads/worker, 698 unique pipelines) 50.8 s 59.4 s

Log progression on #2906 warm run:

  • 10.1 s: 26503 of 26503 records translated (note 5.0 s only reached 4061/26503 vs 20832/26503 on nvidia-dev)
  • 15 s -> 24/698, 20 s -> 54/698, 25 s -> 83/698, 30 s -> 116/698, 35 s -> 170/698, 40 s -> 304/698, 45 s -> 698/698, 59.4 s -> done in 50.8 s.
    With cores = 12 logical (6 physical), compute_worker_count(12, free_mb, 2) spawns only 3 workers (6 concurrent threads total), which spent ~35 s chewing through the heaviest LPT-first cached blobs before clearing the remaining entries.

2. Cold compute pipeline precompilation (xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only)

Isolated XCL_DXIL_CACHE containing translated/ from the snapshot, no driver/ blobs, and the first 120 lines of used-pipelines.txt / used-shaders.txt (XCL_DEVICE_TYPE=lockhart, XCL_DIRECT_DXIL=1):

tree wall time reported time summary output
nvidia-dev (ecc0bb57) 22.21 s 22.0 s compiled 92, already cached 0, pipelines made 126 (12 split, 49 pieces)
PR #2906 (023395ae + ecc0bb57) 47.2 s 47.0 s compiled 90, already cached 614, pipelines made 126 (12 split, 49 pieces)

Two anomalies visible in #2906's cold output:

  1. Between 5600/26503 (4 s) and 5800/26503 (15 s) there was an 11 s stall during precompile, and #2906 reported already cached 614 (vs 0 on nvidia-dev).
  2. Overall wall time was 2.14× slower (47.2 s vs 22.21 s) than nvidia-dev's 8-worker path on this 6C/12T CPU.
xcl-smoke v1
commit: 023395ae4cec59763b37334c2e6b51058643794e
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 90
exit: 0x0
frames shown: 2410 (PresentX 2410)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13915 MB

Not tested: 8-core/16-core CPUs, XCL_PIPELINE_THREADS overrides, full 26k-shader cold run.

**@⁠LocranKing** on GitHub · 2026-11-27 03:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7209396772) Paired measurements of PR `#2906` (`023395ae` merged with `nvidia-dev` `ecc0bb57`) on a **6-core / 12-thread AMD Ryzen 5 5500** + RTX 3060 Ti (8 GB, driver `621.40`), Windows 11 build 26300, DXC `1.9.2602.17`. On this 6-core CPU, **PR `#2906` was ~2.1× slower than `nvidia-dev` (`ecc0bb57`)** in both warm startup preparation and cold `--used-only` worker precompilation: ### 1. Warm startup preparation (`xcl run`, identical `seed-lockhart` cache snapshot) Cache snapshot had `1,296` `used-pipelines`, `1,572` `used-shaders`, and `3,206` cached driver blobs (`XCL_DIRECT_DXIL=1`, `XCL_PREPARE_GRAPHICS=0`). | tree | worker configuration | compute pipeline prep time | total prep ready time | |---|---|---:|---:| | `nvidia-dev` (`ecc0bb57`, run 1) | 8 worker processes | **24 s** | 32.8 s | | `nvidia-dev` (`ecc0bb57`, run 2) | 8 worker processes | **22 s** | 31.1 s | | **PR `#2906`** (`023395ae` + `ecc0bb57`) | **3 worker processes** (`2 threads/worker`, `698` unique pipelines) | **50.8 s** | **59.4 s** | Log progression on `#2906` warm run: - `10.1 s`: `26503 of 26503 records translated` (note `5.0 s` only reached `4061/26503` vs `20832/26503` on `nvidia-dev`) - `15 s` -> `24/698`, `20 s` -> `54/698`, `25 s` -> `83/698`, `30 s` -> `116/698`, `35 s` -> `170/698`, `40 s` -> `304/698`, `45 s` -> `698/698`, `59.4 s` -> `done in 50.8 s`. With `cores = 12` logical (`6` physical), `compute_worker_count(12, free_mb, 2)` spawns only **3 workers** (`6` concurrent threads total), which spent ~35 s chewing through the heaviest LPT-first cached blobs before clearing the remaining entries. ### 2. Cold compute pipeline precompilation (`xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only`) Isolated `XCL_DXIL_CACHE` containing `translated/` from the snapshot, **no `driver/` blobs**, and the first **120** lines of `used-pipelines.txt` / `used-shaders.txt` (`XCL_DEVICE_TYPE=lockhart`, `XCL_DIRECT_DXIL=1`): | tree | wall time | reported time | summary output | |---|---:|---:|---| | `nvidia-dev` (`ecc0bb57`) | **22.21 s** | 22.0 s | `compiled 92, already cached 0`, `pipelines made 126` (`12` split, `49` pieces) | | **PR `#2906`** (`023395ae` + `ecc0bb57`) | **47.2 s** | 47.0 s | `compiled 90, already cached 614`, `pipelines made 126` (`12` split, `49` pieces) | Two anomalies visible in `#2906`'s cold output: 1. Between `5600/26503 (4 s)` and `5800/26503 (15 s)` there was an **11 s stall** during `precompile`, and `#2906` reported `already cached 614` (vs `0` on `nvidia-dev`). 2. Overall wall time was **2.14× slower** (`47.2 s` vs `22.21 s`) than `nvidia-dev`'s 8-worker path on this 6C/12T CPU. ```text xcl-smoke v1 commit: 023395ae4cec59763b37334c2e6b51058643794e gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 90 exit: 0x0 frames shown: 2410 (PresentX 2410) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13915 MB ``` **Not tested:** 8-core/16-core CPUs, `XCL_PIPELINE_THREADS` overrides, full 26k-shader cold run.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 03:57 UTC · original

The FSPX admission change from #2822 needs one additional caller when combined with #2906. Otherwise packed FSPX compute shaders can reach guest entry but miss offline pipeline warming when multiple preparation workers are enabled. This concerns the FSPX inputs reported in #2057 and startup preparation tracked in #2088.

I tested #2906 head 023395ae and two local variants on native Windows with an RTX 5070. The synthetic title contained a single valid FSPX-only compute shader in shaders.rpf, named CS_Test. Each run used a new data directory and pipeline cache, XCL_PREPARE_ALL=1, and XCL_PREPARE_GRAPHICS=0.

Build One configured worker Two configured workers
Unmodified #2906 Preparation error, exit 2, zero PSOs Preparation error, exit 2, zero PSOs
#2906 + #2822 bulk stage admission Exit 0, one PSO Exit 0, zero PSOs
Same port, collector uses is_compute_container Exit 0, one PSO Exit 0, one PSO

The bulk-only port compiled the shader in both runs, so its successful guest exit did not show whether pipeline warming completed. The multi-worker collector separately called xbox::parse, which rejects FSPX-only containers. Reusing the existing is_compute_container helper made the collector schedule one job. Its worker completed successfully and wrote the same PSO filename as the single-worker control. The restored job count is distinct from the earlier Asset01 stage-name issue: CS_Test already passes the name filter.

These are local integration results using the repository’s synthetic guest and generated shader bytes. No GTA files, retail timing, or performance improvement were measured. AI use: OpenAI Codex with GPT-6.2 Astra adapted the existing admission change, built and tested the local variants, and independently reviewed the result; Codex coordinated and prepared this report.

**@⁠andrewDoing** on GitHub · 2026-11-27 03:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7209410150) The FSPX admission change from #2822 needs one additional caller when combined with #2906. Otherwise packed FSPX compute shaders can reach guest entry but miss offline pipeline warming when multiple preparation workers are enabled. This concerns the FSPX inputs reported in #2057 and startup preparation tracked in #2088. I tested #2906 head `023395ae` and two local variants on native Windows with an RTX 5070. The synthetic title contained a single valid FSPX-only compute shader in `shaders.rpf`, named `CS_Test`. Each run used a new data directory and pipeline cache, `XCL_PREPARE_ALL=1`, and `XCL_PREPARE_GRAPHICS=0`. | Build | One configured worker | Two configured workers | | --- | --- | --- | | Unmodified #2906 | Preparation error, exit 2, zero PSOs | Preparation error, exit 2, zero PSOs | | #2906 + #2822 bulk stage admission | Exit 0, one PSO | Exit 0, zero PSOs | | Same port, collector uses `is_compute_container` | Exit 0, one PSO | Exit 0, one PSO | The bulk-only port compiled the shader in both runs, so its successful guest exit did not show whether pipeline warming completed. The multi-worker collector separately called `xbox::parse`, which rejects FSPX-only containers. Reusing the existing `is_compute_container` helper made the collector schedule one job. Its worker completed successfully and wrote the same PSO filename as the single-worker control. The restored job count is distinct from the earlier `Asset01` stage-name issue: `CS_Test` already passes the name filter. These are local integration results using the repository’s synthetic guest and generated shader bytes. No GTA files, retail timing, or performance improvement were measured. AI use: OpenAI Codex with GPT-6.2 Astra adapted the existing admission change, built and tested the local variants, and independently reviewed the result; Codex coordinated and prepared this report.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-27 04:57 UTC · original · edited 2026-11-27 04:59 UTC

Cold startup-preparation timing of #2906 on an Ampere card, head 023395ae4cec59763b37334c2e6b51058643794e against its parent eae015021c639866ab061cdff2e9daf8ba9daac5 (nvidia-dev). One run of each, so treat the ratio as indicative.

Setup

  • NVIDIA GeForce RTX 3060, i9-14900KF (32 threads), 64 GB RAM, Windows 11 26200, Rust 1.100.0 MSVC, release. DXC 1.9.2609.5 (XCL_DXC_DIR).
  • xcl run on a retail title (same title, same used-shader manifest for both: "only the 2648 shaders earlier runs used"), 30 s after the preparation, A presses scripted.
  • Cold driver: each run used a freshly named copy of xcl.exe (new NVIDIA cache identity, as in #2129's -ClearNvCache mode) and XCL_PSO_DISK_CACHE=0. The DXIL translation cache was warm for both (filled once by an untimed run of the parent; the two trees hash the same translator sources).
  • XCL_PREPARE_WORKERS=4 for both, everything else default: so the parent ran its default pipeline threads per worker and the head its "2 threads/worker".

Results (times from the log's preparation lines)

parent eae01502 head 023395ae
preparation done at 7,879 s 3,721 s
of which graphics pipelines 434 s (553 made, 0 failed) 370 s (553 made, 0 failed)
compute phase (difference) ~7,444 s ~3,351 s
compute records handed to workers all 26,503 checked 1,042 unique
after preparation (30 s) 690 frames, 60 presents / 2 s, 0 removals, 0 crashes 753 frames, 60 presents / 2 s, 0 removals, 0 crashes

So on this machine the whole preparation took 2.1× less time, and the compute phase 2.2×.

Memory note, for the worker count. With XCL_PREPARE_WORKERS unset, the parent started 28 workers here; they grew to about 4–4.6 GB each and took commit to 109 of 114 GB before I stopped them. That is the bytes-vs-MiB mix-up ettehn pointed to above (#2705): the commit cap does not bite, so only the thread count limits the workers. I then pinned both trees to 4 workers. During the head's run each worker also sat at about 4.7 GB, so the 1.5 GiB-per-worker budget in compute_worker_count looks low for this pack on NVIDIA even once the unit is fixed.

Edit: the head's default worker count runs this machine out of RAM. A cold run of the head with XCL_PREPARE_WORKERS=8 (what compute_worker_count picks here: 32 threads / 2 / 2 threads per worker) reached 0.2 GB of free RAM at 81.5 GB commit during the compute phase, and my watchdog stopped it, so there is no 8-worker timing. 64 GB RAM, nothing else heavy running. With the 1.5 GiB budget per worker, the memory side of the formula would not have stopped it even with #2705 fixed.

Not tested

  • Repeat runs, a completed run at the head's own default (8 workers, see the edit above), AMD, warm-cache runs (the canary shortcut thehollowedone raised is not exercised with XCL_PSO_DISK_CACHE=0), the full test suite on this tree.

AI use
Claude Code (Claude Opus 5.5) set up and ran the benchmark, read the logs and wrote this report.

**@⁠Anon64** on GitHub · 2026-11-27 04:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2906#issuecomment-7210236996) · edited 2026-11-27 04:59 UTC Cold startup-preparation timing of #2906 on an Ampere card, head `023395ae4cec59763b37334c2e6b51058643794e` against its parent `eae015021c639866ab061cdff2e9daf8ba9daac5` (`nvidia-dev`). One run of each, so treat the ratio as indicative. **Setup** - NVIDIA GeForce RTX 3060, i9-14900KF (32 threads), 64 GB RAM, Windows 11 26200, Rust 1.100.0 MSVC, release. DXC 1.9.2609.5 (`XCL_DXC_DIR`). - `xcl run` on a retail title (same title, same used-shader manifest for both: "only the 2648 shaders earlier runs used"), 30 s after the preparation, A presses scripted. - Cold driver: each run used a freshly named copy of `xcl.exe` (new NVIDIA cache identity, as in #2129's `-ClearNvCache` mode) and `XCL_PSO_DISK_CACHE=0`. The DXIL translation cache was warm for both (filled once by an untimed run of the parent; the two trees hash the same translator sources). - `XCL_PREPARE_WORKERS=4` for both, everything else default: so the parent ran its default pipeline threads per worker and the head its "2 threads/worker". **Results** (times from the log's preparation lines) | | parent `eae01502` | head `023395ae` | |---|---:|---:| | preparation done at | 7,879 s | 3,721 s | | of which graphics pipelines | 434 s (553 made, 0 failed) | 370 s (553 made, 0 failed) | | compute phase (difference) | ~7,444 s | ~3,351 s | | compute records handed to workers | all 26,503 checked | 1,042 unique | | after preparation (30 s) | 690 frames, 60 presents / 2 s, 0 removals, 0 crashes | 753 frames, 60 presents / 2 s, 0 removals, 0 crashes | So on this machine the whole preparation took 2.1× less time, and the compute phase 2.2×. **Memory note, for the worker count.** With `XCL_PREPARE_WORKERS` unset, the parent started 28 workers here; they grew to about 4–4.6 GB each and took commit to 109 of 114 GB before I stopped them. That is the bytes-vs-MiB mix-up ettehn pointed to above (#2705): the commit cap does not bite, so only the thread count limits the workers. I then pinned both trees to 4 workers. During the head's run each worker also sat at about 4.7 GB, so the 1.5 GiB-per-worker budget in `compute_worker_count` looks low for this pack on NVIDIA even once the unit is fixed. **Edit: the head's default worker count runs this machine out of RAM.** A cold run of the head with `XCL_PREPARE_WORKERS=8` (what `compute_worker_count` picks here: 32 threads / 2 / 2 threads per worker) reached 0.2 GB of free RAM at 81.5 GB commit during the compute phase, and my watchdog stopped it, so there is no 8-worker timing. 64 GB RAM, nothing else heavy running. With the 1.5 GiB budget per worker, the memory side of the formula would not have stopped it even with #2705 fixed. **Not tested** - Repeat runs, a completed run at the head's own default (8 workers, see the edit above), AMD, warm-cache runs (the canary shortcut thehollowedone raised is not exercised with `XCL_PSO_DISK_CACHE=0`), the full test suite on this tree. **AI use** Claude Code (Claude Opus 5.5) set up and ran the benchmark, read the logs and wrote this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2906/head:github-bot/gh-2906'
git switch 'github-bot/gh-2906'

Merge

Merge the changes and update on Forgejo.
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2906'
git switch 'github-bot/gh-2906'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2906'
git switch 'github-bot/gh-2906'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2906'
git switch 'nvidia-dev'
git merge --squash 'github-bot/gh-2906'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2906'
git switch 'nvidia-dev'
git merge 'github-bot/gh-2906'
git push origin 'nvidia-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.