Repository navigation
D3D12.X: offload PSO builds, defer lazy compile-on-draw, and wire mmap ID3D12PipelineLibrary1 - #2001
raylitebull wants to merge 7 commits into
Conversation
|
Confirmed a bind-only escape from The small candidate below adds a passive Tested — native Windows 10 19045, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, debug;
Candidate fix and deterministic regression (36 additions, 1 deletion)diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs
index a4bc5d2..ee28774 100644
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -836,7 +836,7 @@ pub(super) unsafe fn on_set_pipeline_state(list: *mut c_void, pso: usize) {
let mut g = LISTS.lock().unwrap();
let s = g.get_or_insert_with(HashMap::new).entry(key).or_default();
// Keep the title-visible base PSO key when `bind_abi` re-binds its resolved background PSO.
- if s.bound_pso == 0 || pso == s.bound_pso || super::pso_async::resolve(s.bound_pso) != pso {
+ if s.bound_pso == 0 || pso == s.bound_pso || super::pso_async::peek(s.bound_pso) != pso {
s.bound_pso = pso;
}
let effective = s.bound_pso;
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index a21bb90..307d5e2 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -704,6 +704,33 @@ mod used_tests {
assert!(!parse_prewarm_used(None, Some("0")));
}
+ #[test]
+ fn switching_bound_pipelines_does_not_compile_the_unused_one() {
+ let list = 0x7E57_B401usize;
+ let a = 0x7E57_B402usize;
+ let b = 0x7E57_B403usize;
+ let ka = 0x5EED_B402u64;
+ let kb = 0x5EED_B403u64;
+ assert!(lazy_on_draw());
+ submit_lazy(a, false, Box::new(|| 0x6402), ka);
+ submit_lazy(b, false, Box::new(|| 0x6403), kb);
+ assert_eq!(resolve_for_bind(a), a);
+ unsafe { super::super::list_x::on_set_pipeline_state(list as *mut _, a) };
+ assert_eq!(resolve_for_bind(b), b);
+ unsafe { super::super::list_x::on_set_pipeline_state(list as *mut _, b) };
+ let queued = [a, b].map(|p| entry(p).unwrap().sent.load(Ordering::Acquire));
+ let used = [used::noted(ka), used::noted(kb)];
+ // Finish both synthetic jobs before assertions so the failing control leaves no worker behind.
+ let built = [resolve_wait_for(a, None), resolve_wait_for(b, None)];
+ super::super::list_x::on_release(list);
+ let _ = released(a);
+ let _ = released(b);
+ println!("bind A then B, no draw: queued={queued:?}, used={used:?}");
+ assert_eq!(built, [0x6402, 0x6403]);
+ assert_eq!(queued, [false, false], "bind bookkeeping queued an unused pipeline");
+ assert_eq!(used, [false, false], "bind bookkeeping polluted the used-pipeline ledger");
+ }
+
#[test]
fn lazy_on_draw_defers_build_past_bind_until_first_draw_or_dispatch() {
let compute_standin = 0x7E57_B301usize;
@@ -816,6 +843,14 @@ fn entry(pso: usize) -> Option<Arc<Pending>> {
PENDING.lock().unwrap().as_ref()?.get(&pso).cloned()
}
+/// The available pipeline identity, without scheduling a build or recording use.
+pub(super) fn peek(pso: usize) -> usize {
+ entry(pso).map_or(pso, |p| match p.real.load(Ordering::Acquire) {
+ 0 => pso,
+ r => r,
+ })
+}
+
/// The pipeline to use for `pso` now: the real one once built, else `pso` itself.
pub fn resolve(pso: usize) -> usize {
let Some(p) = entry(pso) else { return pso };Not tested: full workspace suite, this PR's pipeline-library changes, GPU output, retail smoke, or game-scale compilation-time/memory savings. This is a scheduling/usage-ledger finding, not a merge-readiness claim. No competing PR or source push. AI use: Codex with GPT-6 Astra traced the hook, wrote the candidate and regression, ran the Windows comparison, and drafted this report. |
|
Technical review findings: Blocking
Major
|
Both demand-lifecycle repairs are available as small commitsFor adoption on
The second repair keeps Combined validation: native Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug.
The control's mixed-waiter regression reports an active unbounded waiter but Both retain the identical CLAMP mismatch ( The same 26 explicit SKIPPED notices occur in each run: 19 native-wave64 subcases, three refused wave32 per-lane cases, two missing-debug-layer checks, one unavailable driver-cache-control check and one unavailable heap-window check. Data-dependent early returns do not establish retail coverage. All 314 source hashes match before/after execution and locally; the published tree matches the tested candidate exactly. XCL rebuilt for each snapshot. Not tested: retail smoke, current-main integration, real driver-admission effects, compilation throughput, stutter or memory savings. The two native-thread regression fixtures check production demand/priority behavior with synthetic jobs. Required merge checks remain outstanding. Earlier isolated evidence and patches are preserved below. AI use: Codex (GPT-6) prepared the fixes/tests, performed and verified the native Windows runs, and wrote this report. Earlier isolated comparisons and patchesPriority cleanup: workspace comparison and cherry-pickable fixThe verified priority-lifecycle repair below is now available as commit 8be0af7, based directly on Tested: native Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug.
Both retain Both runs emit the same 26 explicit SKIPPED notices: 19 unavailable native-wave64 subcases, three refused wave32 per-lane cases (f16 arithmetic, f16 packed, f32 conversions), two missing-debug-layer checks, one unavailable driver-cache-control check and one unavailable heap-window check. Data-dependent tests can return successfully without sample files, so raw pass counts are not retail coverage. All 314 source files matched before/after the Windows runs, locally, and in the published commit; XCL rebuilt each snapshot. Not tested: retail smoke, actual driver-load scheduling benefit, stutter/throughput/CPU-use improvements, or current-main integration. The native priority probe uses dedicated test-owned threads calling production AI use: Codex (GPT-6) prepared the fix/test, ran and verified the Windows comparisons, and wrote this report. Follow-up on
|
| Snapshot | Passed / failed / ignored / skipped | After first build / inside next unwanted job |
|---|---|---|
| Head + regression | 15 / 1 / 0 / 0 | Normal / normal for both worker modes |
| Head + candidate + same regression | 16 / 0 / 0 / 0 | Below-normal / below-normal, and lowest / lowest |
The regression uses test-owned native threads invoking production build() twice. It checks the actual Windows GetThreadPriority: initial bases -1 and -2, boosted priority 0 inside the first channel-gated job, then abandonment before releasing that job. Baseline records after=0 next=0 for both; candidate records after=-1 next=-1 and after=-2 next=-2. Both modes are checked before the final failure assertion. Pending entries are removed and threads joined before the result assertions. Existing 15 controls still pass. Both 314-file source manifests matched before/after and local snapshots; XCL recompiled both.
Not tested — actual shared-worker queue dispatch or driver compilation in this probe, GPU output, full workspace suite, retail smoke, stutter, CPU utilization or compilation throughput. This proves the priority leak and its cleanup fix, not a measured performance gain or resolution of the retail world-loading symptoms. No commit/push or competing PR; required merge checks remain separate.
AI use — Codex (GPT-6) identified the cleanup gap, wrote the candidate and regression, ran/verified the native comparison and prepared this update.
Independent candidate and regression
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index 58147a9..46e46a6 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -84,9 +84,8 @@ fn build(p: &Arc<Pending>, job: Job, base_priority: i32) {
// (under the lock: `want` does not raise this thread after it)
let mut d = p.demand.lock().unwrap();
d.worker_thread = 0;
- if d.wanted {
- unsafe { SetThreadPriority(GetCurrentThread(), base_priority) };
- }
+ // A timed-out waiter can clear wanted after this worker was boosted.
+ unsafe { SetThreadPriority(GetCurrentThread(), base_priority) };
}
BUILDING.with(|b| *b.borrow_mut() = None);
}
@@ -866,6 +865,55 @@ mod used_tests {
gate.1.notify_all();
}
+ #[test]
+ fn an_abandoned_wait_restores_worker_priority_before_its_next_job() {
+ use windows_sys::Win32::System::Threading::{GetCurrentThread, GetThreadPriority, SetThreadPriority, THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_NORMAL};
+ let mut failures = Vec::new();
+ for (i, base) in [THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_LOWEST].into_iter().enumerate() {
+ let standin = 0x7E57_B530usize + 2 * i;
+ let (started, building) = mpsc::channel();
+ let (go, finish) = mpsc::channel::<()>();
+ submit_lazy(standin, false, Box::new(move || {
+ started.send(unsafe { GetThreadPriority(GetCurrentThread()) }).unwrap();
+ let _ = finish.recv_timeout(Duration::from_secs(10));
+ 0
+ }), 0);
+ submit_lazy(standin + 1, false, Box::new(|| 0), 0);
+ let p = entry(standin).unwrap();
+ let q = entry(standin + 1).unwrap();
+ let job = p.job.lock().unwrap().take().unwrap();
+ let _ = q.job.lock().unwrap().take();
+ let guard = p.begin_wait();
+ let worker_p = p.clone();
+ // Dedicated test-owned thread, using the production build lifecycle twice.
+ let worker = std::thread::spawn(move || unsafe {
+ assert_ne!(SetThreadPriority(GetCurrentThread(), base), 0);
+ let initial = GetThreadPriority(GetCurrentThread());
+ build(&worker_p, job, base);
+ let after = GetThreadPriority(GetCurrentThread());
+ let (tx, rx) = mpsc::channel();
+ build(&q, Box::new(move || {
+ tx.send(GetThreadPriority(GetCurrentThread())).unwrap();
+ 0
+ }), base);
+ (initial, after, rx.recv().unwrap())
+ });
+ let during = building.recv_timeout(Duration::from_secs(10)).expect("boosted build started");
+ guard.abandon();
+ let abandoned = !p.demand.lock().unwrap().wanted;
+ let _ = go.send(());
+ let (initial, after, next) = worker.join().unwrap();
+ let _ = released(standin);
+ let _ = released(standin + 1);
+ println!("WORKER_PRIORITY base={base} initial={initial} during={during} abandoned={abandoned} after={after} next={next}");
+ assert_eq!(initial, base);
+ assert_eq!(during, THREAD_PRIORITY_NORMAL);
+ assert!(abandoned);
+ if after != base || next != base { failures.push(base); }
+ }
+ assert!(failures.is_empty(), "workers kept boosted priority after abandonment: {failures:?}");
+ }
+
#[test]
fn default_frame_budget_only_defers_graphics_and_never_leaves_skipped_psos_wanted() {
let cap = Duration::from_millis(500);Follow-up on 1f1d681: keep unbounded waits in the new demand count
Verified one remaining scheduling bug in exact 1f1d681439db77ea01a656dc8fc65aa4eabc7d1b. resolve_within uses begin_wait(), but the unbounded path in resolve_wait_with_budgets still calls p.want() directly. When a bounded waiter abandons the same pending pipeline, its guard sees zero counted waiters and clears wanted, even while the unbounded title thread remains blocked. wanted_here() then falsely tells the compile scheduler that nobody needs the build.
A possible policy transition is a graphics wait begun before the first Present (uncapped), followed by a second wait after the implicit frame cap activates. The test supplies these two budget modes directly; I have not observed this sequence in a retail title or proved a resulting watchdog/OOM.
Candidate: replace the unbounded path's p.want() with let _want_guard = p.begin_wait();. It joins the same existing lifetime/count mechanism, leaving timeout and frame policy unchanged. One runtime line changed, plus a 32-line regression in the same file (33 additions / 1 deletion overall).
Tested
Native Windows 10 Home19045, Ryzen7800X3D, Rust/Cargo1.98.1 x64 MSVC, debug. This is a real CPU-thread/worker test with a synthetic blocked job, not a GPU or driver compilation test. XCL_PSO_TITLE_BUILD=0 ensures the worker path.
cargo test --locked -p xcl --lib -- hle::d3d12x::pso_async --test-threads=1 --show-output
- Head + same regression: 15 passed / 1 failed / 0 ignored / 0 skipped. Recorded
initial=true unbounded_active=true wanted_after_timeout=false waiters=0. - Head + candidate + regression: 16 / 0 / 0 / 0. Recorded
initial=true unbounded_active=true wanted_after_timeout=true waiters=1; final count is zero after completion.
The worker sends its actual wanted_here() callback, then stays behind a channel gate. The test observes active demand before making the second wait expire on a1ms frame budget. It records that the first waiter is still blocked, then opens the gate, joins it, and removes the pending entry before assertions, including on baseline failure. It checks the scheduler's callback as well as the counter. Existing lazy-bind, default-frame-budget, orphan-release, prewarm, bounded-wait and worker-demand tests all pass with the candidate.
Both314-file manifests matched before/after and the local snapshots; XCL recompiled both. No source commit/push or competing PR.
Not tested — full workspace, real GPU compile admission, retail world loading/watchdogs, actual commit-memory or performance effects, and other platforms. This fixes the false demand state; it does not establish that the earlier retail symptoms are resolved. Existing full-suite/retail requirements remain separate.
AI use — Codex (GPT-6) identified the uncounted path, wrote the one-line candidate and controlled regression, ran/verified the native comparison, and prepared this update.
Candidate and regression
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index 58147a9..c3b3b11 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -866,6 +866,38 @@ mod used_tests {
gate.1.notify_all();
}
+ #[test]
+ fn a_timed_out_waiter_does_not_cancel_an_unbounded_waiters_demand() {
+ let standin = 0x7E57_B522usize;
+ let (started, building) = mpsc::channel();
+ let (go, finish) = mpsc::channel::<()>();
+ submit_lazy(standin, false, Box::new(move || {
+ started.send(wanted_here()).unwrap();
+ let _ = finish.recv_timeout(Duration::from_secs(10));
+ 0
+ }), 0);
+ let bind = std::thread::spawn(move || resolve_wait_with_budgets(standin, None, None, &FrameWaitBudget::new()));
+ let wanted = building.recv_timeout(Duration::from_secs(10)).expect("worker started");
+ let start = Instant::now();
+ while !wanted() && start.elapsed() < Duration::from_secs(5) { std::thread::yield_now(); }
+ let initial = wanted();
+ let timed = resolve_wait_with_budgets(standin, None, Some(Duration::from_millis(1)), &FrameWaitBudget::new());
+ let pending = entry(standin).unwrap();
+ let still_waiting = !bind.is_finished();
+ let wanted_after_timeout = wanted();
+ let waiters = pending.demand.lock().unwrap().waiters;
+ // Release the worker and join the waiter before asserting, including on the negative control.
+ let _ = go.send(());
+ let resolved = bind.join().unwrap();
+ let _ = released(standin);
+ println!("MIXED_WAIT initial={initial} unbounded_active={still_waiting} wanted_after_timeout={wanted_after_timeout} waiters={waiters}");
+ assert!(initial && still_waiting, "unbounded waiter must be active during the timeout");
+ assert_eq!((timed, resolved), (standin, standin));
+ assert!(wanted_after_timeout, "an unbounded waiter still needs the compile");
+ assert_eq!(waiters, 1);
+ assert_eq!(pending.demand.lock().unwrap().waiters, 0);
+ }
+
#[test]
fn default_frame_budget_only_defers_graphics_and_never_leaves_skipped_psos_wanted() {
let cap = Duration::from_millis(500);
@@ -1156,7 +1188,7 @@ fn resolve_wait_with_budgets(
} else {
enqueue(&p, true);
}
- p.want();
+ let _want_guard = p.begin_wait();
let mut done = p.done.lock().unwrap();
while !*done {
done = p.cv.wait(done).unwrap();Confirmed @gsucristo's blocking finding 2 on 7244baadcf009af2a79e94c9fd9c6e7b41d89ab9, with a small cancellation fix and deterministic reproducer.
The worker's orphan branch skips the job without calling complete, leaving an existing resolve_wait_for(..., None) waiter blocked on Pending::done. The candidate marks cancellation done and notifies waiters in released(), under the existing done mutex, after setting orphan. It does not depend on either worker queue progressing. An already-running build still reaches complete, sees orphan, and releases its result instead of publishing it. No failed-build counter is incremented just for cancellation.
The regression holds the worker queue while the waiter captures the pending entry, releases that entry, then opens the queue. It checks the waiter returns the existing stand-in fallback and the compiler closure never runs. On old code, a bounded test timeout captures the failure and the fixture explicitly wakes/joins the thread before failing; it does not leave a hung test process. A synthetic COM release counter separately verifies that complete still releases a late result exactly once and does not publish it.
Tested — native Windows 10 19045, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, debug. Thread scheduling / fake object tests; no GPU dispatch or real driver compilation.
XCL_DXC_THREADS=2 XCL_PSO_TITLE_BUILD=0
cargo test --locked -p xcl --lib -- pso_async --test-threads=1 --show-output
- Exact head + regression: 12 passed / 1 failed / 0 ignored, failure
released job was skipped but its waiter never completed(Err(Timeout)). - Same head + regression + cancellation change: 13 passed / 0 failed / 0 ignored.
- Zero skips. Both builds recompiled XCL; all 312 source hashes matched before/after.
This patch is independent of the earlier passive-bind lookup patch. It is offered here for the author's integration, with credit for the finding above; #978 already covers not executing released jobs, and is not duplicated.
Not tested — full workspace suite, the two fixes combined, actual title object-lifetime races, real COM/driver builds, dedicated preload-cancellation ordering, retail smoke or whether this stall occurs during world loading. A returned stand-in is the existing resolver fallback; the test does not establish that using an object after another thread releases it is valid. Required main/head retail smoke remains outstanding.
AI use — Codex (GPT-6) implemented the candidate and regression, ran the native tests, reviewed the cancellation/late-completion ordering and prepared this report.
Candidate and regression: one file, 50 additions / 2 deletions
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index a21bb90..c719e9c 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -485,6 +485,51 @@ mod used_tests {
use super::*;
use std::sync::mpsc;
+ #[test]
+ fn releasing_a_queued_pipeline_wakes_its_unbounded_waiter() {
+ let standin = 0x7E57_B620usize;
+ let ran = Arc::new(AtomicBool::new(false));
+ let job_ran = ran.clone();
+ submit_lazy(standin, true, Box::new(move || {
+ job_ran.store(true, Ordering::Release);
+ 0
+ }), 0x5EED_B620);
+ let p = entry(standin).unwrap();
+ // Hold dequeue/enqueue until resolve has retained this Pending. The nonzero
+ // key makes note_use publish that observation before it reaches the queue.
+ let queue = workers().q.lock().unwrap();
+ let (tx, rx) = mpsc::channel();
+ let waiter = std::thread::spawn(move || { tx.send(resolve_wait_for(standin, None)).unwrap(); });
+ let limit = std::time::Instant::now() + Duration::from_secs(5);
+ while !p.used.load(Ordering::Acquire) && std::time::Instant::now() < limit {
+ std::thread::yield_now();
+ }
+ let retained = p.used.load(Ordering::Acquire);
+ assert_eq!(released(standin), 0);
+ drop(queue);
+ let result = rx.recv_timeout(Duration::from_secs(1));
+ // Clean up even on the old code: never leave a hung thread behind a failing test.
+ *p.done.lock().unwrap() = true;
+ p.cv.notify_all();
+ waiter.join().unwrap();
+ assert!(retained, "waiter did not retain the pending pipeline");
+ assert_eq!(result, Ok(standin), "released job was skipped but its waiter never completed");
+ assert!(!ran.load(Ordering::Acquire), "released pipeline reached its compiler");
+
+ // Cancellation must still release a real result from a build already in flight.
+ static RELEASES: AtomicUsize = AtomicUsize::new(0);
+ unsafe extern "system" fn count_release(_: *mut std::ffi::c_void) -> u32 {
+ RELEASES.fetch_add(1, Ordering::SeqCst);
+ 0
+ }
+ RELEASES.store(0, Ordering::SeqCst);
+ let vtable = [0usize, 0, count_release as usize];
+ let object = [vtable.as_ptr() as usize];
+ complete(&p, object.as_ptr() as usize);
+ assert_eq!(RELEASES.load(Ordering::SeqCst), 1);
+ assert_eq!(p.real.load(Ordering::Acquire), 0);
+ }
+
/// While a bind waits for a pipeline still being built, the title is held (`title_held`):
/// `kernelx::Sleep` does not count that time.
#[test]
@@ -1095,12 +1140,15 @@ pub fn resolve_for_bind(pso: usize) -> usize {
/// the worker's result is then released when it arrives).
pub fn released(pso: usize) -> usize {
let Some(p) = PENDING.lock().unwrap().as_mut().and_then(|m| m.remove(&pso)) else { return 0 };
- let done = p.done.lock().unwrap();
+ let mut done = p.done.lock().unwrap();
if *done {
p.real.swap(0, Ordering::AcqRel)
} else {
- // the worker stores its result into a Pending nobody will read: mark it orphaned
+ // An in-flight result is still released by complete. A skipped queued job
+ // never calls complete, so cancellation must also wake existing waiters.
p.orphan.store(true, Ordering::Release);
+ *done = true;
+ p.cv.notify_all();
0
}
}…, and stream key hashing Address review findings on xcl-dev#2001: wake unbounded waiters on orphaned/released pending PSOs in workers, preload, and released(); synchronize StorePipeline against GetSerializedSize+Serialize with an RwLock; make shutdown flush() wait on save_lock for any active background save; remove any rejected .plib file on open_or_create; hash pointer-bearing pipeline stream subobjects by pointed-to content; and return ID3D12PipelineState directly in deliver_adopted without querying console IIDs.
7244baa to
4d53a2c
Compare
|
Thanks for all the detailed catches, Updated
Verified locally ( |
|
World-loading test of
For comparison, What I saw of the PR's own parts:
Tested: RTX 4080 16 GB (32-lane waves), i9-12900K, 64 GB (commit limit 68 GB), Windows 11 26300, release build; no input after the menus. AI use: Claude Code (Claude Opus 5.5): ran the tests and wrote this; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built. |
|
Regression run for this PR: head main this PR: No device removals or crashes; 101 % of main's frames, 93 % of its peak commit. Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings: Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
…n budget skips Address world-loading findings on xcl-dev#2001: (1) apply the implicit default 500 ms AfterFirstPresent frame-wait cap only to graphics pipelines so compute dispatches writing GPU sync/indirect buffers are not skipped mid-frame (explicit XCL_PSO_FRAME_WAIT_MS still applies to both); (2) do not mark deferred pipelines as wanted when the frame budget is already exhausted, and clear wanted on budget/timeout abandonment so skipped huge pipelines cannot bypass big_compile_turn's commit/slot gate and spike process commit; (3) take the shared lib_rw read lock in MmapPipelineLibrary::load_{compute,graphics,stream} so Load*Pipeline never races with Serialize.
|
Thanks for the detailed RTX 4080 world-load report,
Compiled cleanly in release ( |
PR #2001 verification on STOR-WINLABTested detached head Environment
Tested
Workspace suite
All 20 harnesses reported results. The counts above are libtest totals. The 23 emitted
Failures25 unrelated by code path. These DXIL and recompiler unit tests use the direct D3D12 test runner and bypass the changed XCL PSO hooks. The 21 tests below failed at
Four more direct-runner tests reported shader result mismatches.
1 confirmed pre-existing. Not tested
AI useT3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against |
|
raylitebull, PortBridge followed up on victory-fork's duplicate pipeline work by checking XCL's driver blob cache. The compute and graphics publish and removal routines are unchanged between your A CPU fixture forces four publishers of the same 16-byte key through those exact routines. Both caches charge 64 bytes with 16 present, then retain 48 bytes of charge after removal. Checking the vacant entry under the existing map lock makes both report 16 before removal and zero afterward. Under a 64-byte test budget, all four independent 16-byte keys then fit. Exact patch, method and result. The patch only changes in-memory publishing and accounting. The fixture mocks blob retrieval and does not measure driver work or startup time. |
|
Linux (Wine + vkd3d-proton) + NVIDIA test of Setup: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch (neither touches Tested
Read
let mut lib: Option<ID3D12PipelineLibrary1> = None;
(Interface::vtable(&dev1).CreatePipelineLibrary)(Interface::as_raw(&dev1), std::ptr::null(), 0, &ID3D12PipelineLibrary1::IID, &mut lib as *mut _ as *mut _).ok().ok()?;
let lib = lib?;Not tested: a world load (no run presented after 91 s); whether the library saves time here; AI use: Claude Code (Claude Fable 5.2) read the diff, wrote and ran the probe and the three lines, ran the title and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Test report for
AI use: Claude Code (Claude Opus 5.5) ran the runs, read the symbolized dumps and wrote this report. |
|
Regression run of Against the limits in CONTRIBUTING.md: 101 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
|
Retest at
Compared with
So on this card the title still stops at about the same point as Not tested: the suite on this head, AMD, a AI use: Claude Code (Claude Opus 5.5): ran the tests and wrote this. |
…, and stream key hashing Address review findings on xcl-dev#2001: wake unbounded waiters on orphaned/released pending PSOs in workers, preload, and released(); synchronize StorePipeline against GetSerializedSize+Serialize with an RwLock; make shutdown flush() wait on save_lock for any active background save; remove any rejected .plib file on open_or_create; hash pointer-bearing pipeline stream subobjects by pointed-to content; and return ID3D12PipelineState directly in deliver_adopted without querying console IIDs.
…n budget skips Address world-loading findings on xcl-dev#2001: (1) apply the implicit default 500 ms AfterFirstPresent frame-wait cap only to graphics pipelines so compute dispatches writing GPU sync/indirect buffers are not skipped mid-frame (explicit XCL_PSO_FRAME_WAIT_MS still applies to both); (2) do not mark deferred pipelines as wanted when the frame budget is already exhausted, and clear wanted on budget/timeout abandonment so skipped huge pipelines cannot bypass big_compile_turn's commit/slot gate and spike process commit; (3) take the shared lib_rw read lock in MmapPipelineLibrary::load_{compute,graphics,stream} so Load*Pipeline never races with Serialize.
1f1d681 to
6979522
Compare
|
Thanks for all the catches and test details, Updated
Verified locally ( |
|
Test report for exact head Tested
main: PR: Not tested: AMD, the head merged onto current AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety before it was built. |
…ait budget and mmap pipeline library
…ate used-only prewarm
…hics, and mesh PSO paths
Switching bound pipelines A -> B via SetPipelineState previously called side-effecting pso_async::resolve(s.bound_pso) on the outgoing binding A, enqueueing lazy compilation and recording usage for a pipeline that was never drawn. Add passive pso_async::resolve_if_ready for bind-time identity comparison in list_x::on_set_pipeline_state and add an A-to-B bind regression test.
…, and stream key hashing Address review findings on xcl-dev#2001: wake unbounded waiters on orphaned/released pending PSOs in workers, preload, and released(); synchronize StorePipeline against GetSerializedSize+Serialize with an RwLock; make shutdown flush() wait on save_lock for any active background save; remove any rejected .plib file on open_or_create; hash pointer-bearing pipeline stream subobjects by pointed-to content; and return ID3D12PipelineState directly in deliver_adopted without querying console IIDs.
…n budget skips Address world-loading findings on xcl-dev#2001: (1) apply the implicit default 500 ms AfterFirstPresent frame-wait cap only to graphics pipelines so compute dispatches writing GPU sync/indirect buffers are not skipped mid-frame (explicit XCL_PSO_FRAME_WAIT_MS still applies to both); (2) do not mark deferred pipelines as wanted when the frame budget is already exhausted, and clear wanted on budget/timeout abandonment so skipped huge pipelines cannot bypass big_compile_turn's commit/slot gate and spike process commit; (3) take the shared lib_rw read lock in MmapPipelineLibrary::load_{compute,graphics,stream} so Load*Pipeline never races with Serialize.
6979522 to
814d31a
Compare
|
Rebased
|
|
@raylitebull Setup: Fedora 44,
On Not tested: whether loading from the library saves time or changes where the title stops (1 run each); the offloaded builds and the deferred compile; the suite at this head; Windows; AMD and Intel. AI use: Claude Code (Claude Opus 5.5) ran the title and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Retail title world load on native Windows, RTX 5070 Ti: Setup: Windows 10 22H2, Ryzen 7 9800X3D, 32 GB RAM, RTX 5070 Ti 16 GB, NVIDIA driver 621.01. Release build (
Result:
Not tested: a second PR run that loads the saved library; repeat runs (one run each); AI use: Claude (Opus 5.5, claude.ai) planned the runs and wrote this comment from my run outputs (smoke manifests, report.json, xcl.log). I ran everything and checked the numbers. |
Offloads all PSO compilation off title threads with a shared per-frame wait budget (
pso_async), defers lazy PSO builds until firstDraw/Dispatch/ExecuteIndirect(XCL_LAZY_ON_DRAW), deduplicates used-only startup prewarm (XCL_PSO_PREWARM_USED), and wires a generational memory-mappedID3D12PipelineLibrary1cache (pso_library,pso_libinreal.rs, flushed on clean exit viapresent.rs) into compute, graphics, and mesh PSO creation paths.Part of #1833 (addresses Gaps #1–#5: off-thread PSO builds, bounded per-frame bind wait, deferred compile-on-draw, deduplicated used-only prewarm, and persistent memory-mapped
ID3D12PipelineLibrary1reuse).What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs,list_x.rs,frame.rs, &mod.rs:resolve_waitnever compiles synchronously on calling title threads unlessXCL_PSO_TITLE_BUILD=1; integrates#2176(Pending::spared,image_skip(),image_only(),resolve_sparedrouted throughenqueue(p, false)on the urgent/normal worker pool and honored insideresolve_wait_with_budgets) and#2178(let _ = p.job.lock().unwrap().take()orphan drain alongside*p.done = true+notify_all()); checksframe_rem.is_zero()beforebegin_wait()and uses an RAIIWaitWantGuard(resolve_wait_with_budgetsunbounded path also holdsp.begin_wait()so bounded timeouts never clear an active unbounded waiter'swantedflag); limits the implicit defaultAfterFirstPresent(500 ms)frame budget to graphics PSOs (!p.compute) so compute dispatches are never deferred unlessXCL_PSO_FRAME_WAIT_MS=<ms>(Always) is explicitly set; unconditionally restores workerbase_priorityinbuild()underdemandlock.lazy_on_draw/resolve_for_bind(XCL_LAZY_ON_DRAW, default on whenXCL_LAZY_PSO != 0) defers building lazy pipelines pastSetPipelineState(passiveresolve_if_readylookup) until first draw/dispatch.prewarm_used_enabled(XCL_PSO_PREWARM_USED/XCL_PSO_PRELOAD) deduplicates duplicate shader keys.crates/xcl/src/hle/d3d12x/pso_library.rs: generational memory-mappedID3D12PipelineLibrary1(MmapPipelineLibrary) passing explicit(std::ptr::null(), 0)viaID3D12Device1_Vtbl::CreatePipelineLibraryfor Wine/vkd3d-proton compatibility, synchronizingLoad*+StorePipeline(lib_rw.read()) vs serialization (write) viaRwLock, waiting for in-flight saves duringflush(), and removing rejected/corrupt.plibfiles onopen_or_create.crates/xcl/src/hle/d3d12x/real.rs&present.rs:pso_libwiring into compute, graphics, stream, and mesh PSO paths (flush_pipeline_libraryon clean close),Entry::Vacant-guardedinsert_cached_blobacrossCOMPUTE_BLOBS/GRAPHICS_BLOBSso racing duplicate publishes charge the byte budget once and free cleanly to zero, deterministicstream_keycontent hashing for pointer-bearing subobjects, PCID3D12PipelineStateadoption (deliver_adopted), and debounced background save scheduler (should_background_save).pso_async::,pso_library::,pso_lib::tests,compute_blob_tests,graphics_blob_tests).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly ontof087b998(814d31a8).cargo test -p xcl --lib pso_async::: 19 passed, 0 failed (including#2176a_bind_does_not_wait_for_a_pipeline_that_writes_only_imagesand#2178a_released_queued_pipeline_is_not_built_by_normal_workers).cargo test -p xcl --lib pso_library::: 3 passed, 0 failed.cargo test -p xcl --lib pso_lib::tests: 2 passed, 0 failed.cargo test -p xcl --lib compute_blob_tests: 2 passed, 0 failed.cargo test -p xcl --lib graphics_blob_tests: 5 passed, 0 failed.Regression run
scripts/smoke.ps1pair on814d31a8vsf087b998has not been run locally. AMD and NVIDIA reviewers are invited to test on814d31a8vsf087b998(includingscripts/smoke.ps1, cold/warmXCL_PSO_LIBRARY=1world loads,XCL_LAZY_PSO=1, and Linux/vkd3d-proton.plibcreation) and post results in the comments.Not tested
scripts/smoke.ps1pair on814d31a8, fullcargo test --workspacesuite on814d31a8, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton runtime.AI use
f087b998, and unit tests; the author reviewed the diff and test output.