Repository navigation
Conversation
|
Diff review (head Layout-scoped library folders, stale-vs-absent receipts, incremental
Additional medium/minor observations:
AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
|
merge-check tests: I reran the full workspace suite on the RTX 3080. It finished with 2,909 passed, 1 failed and 51 ignored. The log also recorded 28 runtime skips and eight notices for skipped optional retail game sample checks. All 17 focused library, receipt, counter and VFS checks passed. Both link tests previously reported failing with DXC 1.7 passed here with DXC 1.9.2609. The failure was in gpu_two_pass_cache_e2e. The stale-mesh case rejected the stale blob and rebuilt the pipeline as expected. After releasing the pipeline objects, the test found one live two-pass state where it expected zero. I reran that test in isolation on both the merge and the pinned main revision. It passed both times, so the cause of the full-suite failure remains open. review: Source review identified a write-ordering issue. The periodic flush clears the dirty count before it finishes publishing. Shutdown can see that cleared count while a write is in flight, and an older snapshot can finish publishing after a newer one. I didn’t observe a lost write in the startup runs. performance: I ran four 60-second retail game startups in order: main cold, main repeat, merge cold, merge repeat. Each revision had its own XCL cache and all four runs shared the NVIDIA driver cache. On the merge, the repeat recorded 4,056 runtime-library hits. Driver calls with a recorded return fell from 4,120 to 268, compared with 4,100 to 4,323 on main. Frames shown were 1,104 / 1,077 on main and 1,151 / 1,015 on the merge. All four runs reached the same profile prompt and exited cleanly with zero device removals. This confirms pipeline reuse during startup. The runs did not reach gameplay. verdict: not yet. The write-ordering issue remains open, and the two-pass release assertion failed once in the full suite. I’ll rerun the full suite on the next revision that addresses either issue and check the same assertion under the original conditions. hardware / tool and model: RTX 3080 (driver 32.0.16.1692), Ryzen 7 5700X, Windows 11 25H2 build 26200.9457, Rust 1.100.0 MSVC, DXC 1.9.2609. OpenAI Codex GPT-6.2 Sol ran the tests. Independent Codex agents checked the source and run evidence. Their exact models were not recorded. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
|
Review (head 05c33e9, diff read, not a merge-check):
Fine: names are hashes of the exact DXIL and state, and D3D12 checks the desc on load, so a stale entry can only miss. A AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
05c33e9 to
034e714
Compare
|
Rebased onto
AI use: Antigravity (Gemini 4 Neon) implemented these fixes, ran the suite and smoke pair, and drafted this reply. |
|
I checked the runtime-library size cap on Could the read paths share a check that skips the payload entirely at zero cap, rejects oversized files using metadata from the opened handle, and bounds the read in case the file grows? Status could get the size from metadata alone. I’d cover three boundaries in a focused test: zero cap, a file exactly at the cap, and one byte over. I verified the ordering in source. I haven’t measured peak memory or startup time on this revision. OpenAI Codex GPT-6.2 Sol reviewed the code, an independent Codex agent checked the call sites, and GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
034e714 to
ae8b643
Compare
|
Good catch, @Gevroska — pushed
AI use: Antigravity (Gemini 4 Neon) implemented these fixes, ran the suite and smoke pair, and drafted this reply. |
|
Test report for #3633 at head Tested
Not tested
AI use
Update: head
Update: head
|
|
Thanks for the update. I checked With the cap set to zero, the reader consumed zero bytes. A 32-byte file was accepted at a 32-byte cap and rejected at 31. In the case where the input grew beyond its initial size, the reader consumed 17 bytes at a 16-byte cap, returned I also checked that direct activation, warm-library inspection and publication all use the capped reader. This addresses my earlier concern about reading the whole file before applying the cap. I haven’t rerun the full workspace suite or measured startup time on this revision. OpenAI Codex GPT-6.2 Sol ran the tests. An independent Codex agent verified the extracted code and all seven outcomes. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
ae8b643 to
d997979
Compare
bmjask
left a comment
There was a problem hiding this comment.
Review of d9979794: 6 finding(s) (1 critical, 3 high, 2 medium), most severe first.
- Critical
crates/xcl/src/shaders/pipeline_library.rs:314: The newread_cached_blobcallspipeline.GetCachedBlob()through the windows-rs PC vtable, but on the hand-out-once path the object is the one handed out earlier, which the title-facing create path has since adopted, swapping its vtab.... (inline) - High
crates/xcl/src/shaders/pipeline_library.rs:198:warm_library::reusenow stores READY on every preparation, including titles with no corpus or with Stale/Absent libraries, soactivate's hard Err ondriver != ready.drivernow fails device creation (real.rs:1025 uses?) for any t.... (inline) - High
crates/xcl/src/shaders/warm_library.rs:97: A corpus with noidentityfile now getscorpus: [0; 32]. (inline) - High
crates/xcl/src/hle/d3d12x/real.rs:9627:finish_two_passtakes the mesh pass's gated compile slot (take_cold_slot, held untildrop(slot)) before it blocks inone_build(&compute_name), but the thread holding that compute name incompute_containerneeds a slot from the .... (inline) - Medium
crates/xcl/src/shaders/pso_corpus.rs:1643: see below. - Medium
crates/xcl/src/shaders/pipeline_library.rs:359:store_runtimeputs the name intoknownbefore the store succeeds and never takes it out on failure, and it treats E_INVALIDARG from StorePipeline as "kept already" even when that run's load of the name failed. (inline)
On lines outside the diff:
- Medium
crates/xcl/src/shaders/pso_corpus.rs:1643: Prepared libraries move from.xcl/pso-corpus/to.xcl/pipeline-libraries/<windows>/, and the oldcompute.plib/graphics.plibare no longer passed asprevioustopipeline_library::begin, so every existing prepared title rebuilds its whole corpus on upgrade even though entries are name-addressed and safe to import. A user with a fully prepared title (hundreds of driver builds, over 10 minutes) upgrades, the first launch finds no receipt in the new folder, reports Absent, and rebuilds everything. Passing the legacy files aspreviouswould import every unchanged name.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| runtime.mark_full(bytes.len() as u64); | ||
| state.disabled = true; | ||
| crate::xlog_warn!( | ||
| "Pipeline library: {} would exceed XCL_RUNTIME_LIBRARY_MB ({} > {} bytes); keeping the previous on-disk library", |
There was a problem hiding this comment.
Critical: The new read_cached_blob calls pipeline.GetCachedBlob() through the windows-rs PC vtable, but on the hand-out-once path the object is the one handed out earlier, which the title-facing create path has since adopted, swapping its vtable pointer for XCL's ext class. real::read_pso_cached_blob exists for exactly this and calls orig_fn(pso, slot_of(pso, "GetCachedBlob")) on adopted objects. If a title creates the same compute or graphics pipeline twice, the first with_name hands out object X, which gets adopted. The second with_name loads X again (D3D12 returns the same object) and calls GetCachedBlob at the PC slot index on the ext vtable, which is the wrong method or XCL's hook. The result is garbage, a crash, or a None blob that forces a full driver recompile. Using read_pso_cached_blob would fix it, and the unit test never adopts its objects, so it can't catch this.
| let Some(ready) = super::warm_library::take_ready() else { return Ok(()) }; | ||
| let ready = super::warm_library::take_ready().or_else(|| { | ||
| // (no preparation ran: the runtime library still keeps what the title builds, in data_dir) | ||
| let data_dir = &crate::state::boot()?.data_dir; |
There was a problem hiding this comment.
High: warm_library::reuse now stores READY on every preparation, including titles with no corpus or with Stale/Absent libraries, so activate's hard Err on driver != ready.driver now fails device creation (real.rs:1025 uses ?) for any title whose runtime adapter differs from the one preparation picked. Preparation takes candidates(...).next() for its driver identity. If at runtime the first candidate fails create_device(12_0) and the loop moves to the next adapter (or falls back to Auto/WARP), the driver identity differs, activate returns Err, and the title can't start, even with no prepared libraries at all. Before, that error was only possible when the libraries were Current. Treating a driver mismatch as "no libraries" (log and continue) would avoid it.
| .filter(|r| r.version == VERSION).map(|receipt| (receipt, false)); | ||
| fn prepared(corpus: Option<&Corpus>) -> Prepared { | ||
| Prepared { | ||
| corpus: corpus.and_then(Corpus::identity).unwrap_or_default(), |
There was a problem hiding this comment.
High: A corpus with no identity file now gets corpus: [0; 32]. Before, expected() and expected_for_adapter() returned None, so such a corpus was never reusable and publish wrote no receipt. Now publish writes a receipt with a zero corpus, and every later identity-less corpus matches it as Library::Current. If you stage a corpus without an identity file, launch once (receipt written with corpus 0), then restage it with more recipes still without an identity, prepare_for_launch sees Current, skips preparation and reports all recipes complete. The new pipelines are never prepared, and XCL_PREPARE_CACHE_ONLY=1 lets the launch through anyway. Keeping "no identity" as not reusable would fix it.
| let compute_name = driver_cache::name_for_root_node(&tp.cs, 0, false, &tp.samplers, node_mask); | ||
| // Serialize concurrent builds of a shared compute pass across distinct (MS/GS, PS) pairs, | ||
| // except when a dispatch-chain fallback is available (stay non-blocking like CachedWhole). | ||
| let _one_compute_build = tp.cs_chain.is_none().then(|| crate::shaders::pipeline_library::one_build(&compute_name)); |
There was a problem hiding this comment.
High: finish_two_pass takes the mesh pass's gated compile slot (take_cold_slot, held until drop(slot)) before it blocks in one_build(&compute_name), but the thread holding that compute name in compute_container needs a slot from the same pool to finish. On xcl-pso workers, several two-pass pipelines that share one tp.cs hold the medium or huge slots while waiting on compute name C, and the thread building C waits in driver_compile_identified for a slot. Nobody progresses until XCL_ONE_BUILD_WAIT_S (60 s) runs out, then every waiter builds C itself: a 60 s stall followed by the duplicate compile one_build is meant to prevent. Waiting on one_build before taking the slot would avoid the deadlock.
| Some(blob.saturating_add(name_bytes).saturating_add(ENTRY_OVERHEAD)) | ||
| } | ||
|
|
||
| impl Runtime { |
There was a problem hiding this comment.
Medium: store_runtime puts the name into known before the store succeeds and never takes it out on failure, and it treats E_INVALIDARG from StorePipeline as "kept already" even when that run's load of the name failed. A transient StorePipeline error (e.g. E_OUTOFMEMORY) leaves the name in known, so it's never stored for the rest of the run and is rebuilt next launch. An entry whose load keeps failing (desc mismatch) hits E_INVALIDARG on store, is counted as kept, and is never replaced, so that pipeline is rebuilt in the driver every run.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
bmjask
left a comment
There was a problem hiding this comment.
Review of d9979794: 5 finding(s) (3 high, 2 medium), most severe first.
Correction: my previous review on this PR was written against ae8b643f, but it was attached to d9979794 by mistake because the PR was force-pushed while that review was running. This review is the one actually done at d9979794. Still present from the earlier one: activate's hard error on a driver mismatch now fails device creation for any title that ran preparation, not only titles with a prepared corpus (pipeline_library.rs ~213), and the two-pass mesh pass holding a compile slot while it waits on the compute pass's one_build (real.rs ~9627). The other earlier findings (the adopted-object GetCachedBlob, the zero-identity corpus, the legacy-path migration, store_runtime's known on failure) weren't flagged at this head and may have been addressed. New at this head:
- High
crates/xcl/src/hle/d3d12x/real.rs:4900:end_titlenow runsflush_runtime(wait forflush_lock, serialize up to 2 GiB, write withsync_all) inside the 15 s end watchdog and beforesuspend_other_threads, fence signalling anddrain_gpu, so a large flush can use the wh.... (inline) - High
crates/xcl/src/hle/d3d12x/real.rs:6406:one_buildis taken beforedriver_compile_identified's compile gate, so a background xcl-pso worker that holds a name while parked inbig_compile_turn(waiting for commit headroom or a slot) blocks a title thread's synchronous creat.... (inline) - High
crates/xcl/src/shaders/pipeline_library.rs:388: Not certain about this one, because it depends on whether D3D12 counts the library's reference publicly:store_runtimeStorePipelines every runtime-built pipeline into runtime.plib, which keeps a reference for the process lifetime, so .... (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:446: The cap is only enforced per pipeline within NEAR_CAP_MARGIN (16 MiB) of it, and the read-lock path stores with no size check, so a large or concurrent store can push the library past the cap. (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:376: Incan_store_locked, a GetCachedBlob failure for a single pipeline callsmark_full(), latching the whole runtime library as full for the rest of the process even though it's under the cap. (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| let watchdog = rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap_or(0); | ||
| crate::log::flush(); | ||
| // (before the threads stop: one of them may be storing into the runtime library) | ||
| crate::shaders::pipeline_library::flush_runtime(); |
There was a problem hiding this comment.
High: end_title now runs flush_runtime (wait for flush_lock, serialize up to 2 GiB, write with sync_all) inside the 15 s end watchdog and before suspend_other_threads, fence signalling and drain_gpu, so a large flush can use the whole budget and skip the device-hang mitigation. If runtime.plib is ~1.5 GB on a slow disk, or the periodic flusher is mid-write, end_title waits, then serializes and fsyncs for more than 15 s. xcl-end-watchdog then calls end_process_now before the title's threads are suspended and its fences signalled (the end-of-run device hang that ordering exists to prevent), leaving the temp file half-written. On WM_CLOSE the window shows Not Responding meanwhile. Flushing after the hang mitigation, or bounding the flush by the remaining budget, would avoid it.
| *ppv = pso.into_raw(); | ||
| return (S_OK, std::time::Duration::ZERO, true); | ||
| // Skip single-flight waiting for CachedWhole probes so callers fall back to dispatch_chain::build immediately. | ||
| let _one_build = compute_uses_one_build(mode, !ppv.is_null()) |
There was a problem hiding this comment.
High: one_build is taken before driver_compile_identified's compile gate, so a background xcl-pso worker that holds a name while parked in big_compile_turn (waiting for commit headroom or a slot) blocks a title thread's synchronous create of the same pipeline for up to XCL_ONE_BUILD_WAIT_S (60 s). If a pso_async worker starts an ahead or unwanted build of compute X, takes one_build(X) and then waits at the gate for commit headroom (the code notes gate waits of 129 s), the title thread's CreateComputePipelineState for X sits in OneBuildFlights::enter for 60 s before compiling. Before this PR it compiled X at once, ungated. Taking one_build after the gate, or letting a title thread jump ahead of a parked background holder, would avoid the minute-long stall.
| } | ||
| } | ||
|
|
||
| fn store_into_runtime(runtime: &Runtime, name: &str, pipeline: &ID3D12PipelineState) -> bool { |
There was a problem hiding this comment.
High: Not certain about this one, because it depends on whether D3D12 counts the library's reference publicly: store_runtime StorePipelines every runtime-built pipeline into runtime.plib, which keeps a reference for the process lifetime, so pso_release's n == 0 path (forget_pso, the TWO_PASS compute-pass drop, pso_async::released for stand-ins) may never run for those pipelines. The code's own comment ("a load may give back the very object stored") says the library holds it. In a streaming title that creates and releases pipelines as it loads areas, the title's last Release would return 1, not 0. TRANSLATED_GRAPHICS, PSO_RS, dispatch chains and TWO_PASS entries (with their compute passes) then accumulate, and memory grows over a long session. Running the cleanup when the title's own count reaches 0 (tracked separately), not the COM count, would avoid depending on it.
| if !runtime.known.lock().unwrap().insert(name.into()) { return } | ||
| let slot = crate::gpu::shader::fnv64(name.as_bytes()) as usize % self.names.len(); | ||
| let _same_name = self.names[slot].lock().unwrap(); | ||
| let near_cap = runtime.cap.saturating_sub(runtime.library.serialized_size()) <= NEAR_CAP_MARGIN; |
There was a problem hiding this comment.
Medium: The cap is only enforced per pipeline within NEAR_CAP_MARGIN (16 MiB) of it, and the read-lock path stores with no size check, so a large or concurrent store can push the library past the cap. flush_runtime_on then sets disabled for good, and every pipeline added since the last flush is never written. With the library at 2031 MiB of a 2048 MiB cap (17 MiB left, more than the margin), two threads storing 12 MiB compute blobs at once take it to ~2055 MiB, so the next flush sees current > cap, marks it full, disables it, and the pipelines from the last 30 s+ are lost. Writing what fits (or checking size on every store) would keep them.
| self.mark_full(current); | ||
| return false; | ||
| } | ||
| let Some(est) = estimated_store_bytes(name, pipeline) else { |
There was a problem hiding this comment.
Medium: In can_store_locked, a GetCachedBlob failure for a single pipeline calls mark_full(), latching the whole runtime library as full for the rest of the process even though it's under the cap. Near the cap, one pipeline whose GetCachedBlob fails (an error or empty blob for that PSO) makes estimated_store_bytes return None, full is set, and every later store_runtime returns early, with tens of MiB still free. Skipping just that pipeline would avoid it.
d997979 to
a2eaffc
Compare
|
Thanks @bmjask for both thorough reviews! I verified every finding from both passes (reviews First review (
|
bmjask
left a comment
There was a problem hiding this comment.
Review of a2eaffc4: 4 finding(s) (1 critical, 1 high, 2 medium), most severe first.
Re-review at a2eaffc4. The 60 s stall from one_build being taken before the compile gate, and the two-pass slot/one_build deadlock, are no longer flagged. The end-of-title flush now has a 5 s limit, and cap enforcement was reworked, but both still have problems (first two below). The activate driver-mismatch error no longer fails device creation, but it now drops the runtime library too (last item).
- Critical
crates/xcl/src/hle/d3d12x/real.rs:4902: When the 5 s shutdown flush times out, its xcl-plib-end-flush thread may still be inside GetSerializedSize/Serialize, a multi-GBvec!allocation, orwrite_atomic, andsuspend_other_threadsthen suspends it like any other thread whi.... (inline) - High
crates/xcl/src/shaders/pipeline_library.rs:578: A fast-path size reservation is made before taking the store read lock, and the write-lock path then setsestimated_sizeto the exact current size, which wipes out reservations already granted to other threads, so the guarantee against.... (inline) - Medium
crates/xcl/src/hle/d3d12x/present.rs:741: WM_CLOSE callsflush_runtime()with no time limit on the window thread before ExitProcess, unlike end_title's 5 s limit. (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:221: When the prepared libraries' driver identity differs from the runtime device's (not cache-only),activatereturns beforeopen_runtime, so runtime.plib is dropped too, although it lives in the per-title data folder andopen_shareda.... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| // (before the threads stop: one of them may be storing into the runtime library; bounded | ||
| // so a large or contested flush still leaves the 15 s watchdog plenty of budget for | ||
| // suspending threads, signalling fences, and draining the GPU) | ||
| crate::shaders::pipeline_library::flush_runtime_timeout(std::time::Duration::from_secs(5)); |
There was a problem hiding this comment.
Critical: When the 5 s shutdown flush times out, its xcl-plib-end-flush thread may still be inside GetSerializedSize/Serialize, a multi-GB vec! allocation, or write_atomic, and suspend_other_threads then suspends it like any other thread while it may hold the process heap lock or D3D12's library lock. With a large runtime.plib (hundreds of MB to 2 GB) or a slow disk, the flush takes over 5 s, end_title moves on, and the flush thread is suspended inside HeapAlloc or the D3D12 serialize lock. drain_gpu or log::flush then block on that lock, and the process hangs until the 15 s watchdog calls end_process_now, so the final log and report are lost. Excluding the flush thread from suspension (and abandoning its temp file), or not starting the flush when it can't finish in the budget, would avoid it.
| if runtime.known.lock().unwrap().contains(name) { return } | ||
| // Skip only this pipeline if its cached blob cannot be read; do not latch `runtime.full`. | ||
| let Some(est) = estimated_store_bytes(name, pipeline) else { return }; | ||
| let outcome = if runtime.try_reserve_fast(est) { |
There was a problem hiding this comment.
High: A fast-path size reservation is made before taking the store read lock, and the write-lock path then sets estimated_size to the exact current size, which wipes out reservations already granted to other threads, so the guarantee against concurrent overflow doesn't hold. Near the cap, thread X wins try_reserve_fast (estimated_size += est) and blocks on store_lock.read() while Y holds store_lock.write(). In can_store_locked and after its store, Y sets estimated_size = serialized_size(), so X's est disappears. X then stores, and more threads pass try_reserve_fast against the undercount. Their combined stores go past the cap, and the next flush_runtime_on sees current > cap, sets disabled = true, and every pipeline added since the last flush is lost for the session. Adding outstanding reservations back when resetting estimated_size would keep it correct.
| match msg { | ||
| WM_CLOSE => { | ||
| crate::xlog_info!("XCL window closed – ending the game process"); | ||
| crate::shaders::pipeline_library::flush_runtime(); |
There was a problem hiding this comment.
Medium: WM_CLOSE calls flush_runtime() with no time limit on the window thread before ExitProcess, unlike end_title's 5 s limit. If the user closes the window while the periodic flusher holds flush_lock for a 2 GB serialize, or runtime.plib has grown a lot, the window procedure blocks for the whole serialize, fsync and MoveFileEx, so Windows shows the window as not responding for many seconds, or indefinitely on a stuck disk. Using the same bounded flush as end_title would fix it.
| if cache_only && has_prepared { | ||
| return Err(reason.into()); | ||
| } | ||
| crate::xlog_warn!("{reason}; continuing without pipeline libraries"); |
There was a problem hiding this comment.
Medium: When the prepared libraries' driver identity differs from the runtime device's (not cache-only), activate returns before open_runtime, so runtime.plib is dropped too, although it lives in the per-title data folder and open_shared already rejects one from another driver. If preparation resolves the adapter (config auto / XCL_ADAPTER) to a different adapter or driver identity than the device actually created (a hybrid-GPU laptop, a driver update between preparation and launch), activate logs "continuing without pipeline libraries" and never opens runtime.plib. Every pipeline the title builds that run is then neither loaded nor kept, on every launch while the mismatch lasts. Opening the runtime library independently of the prepared ones would keep it.
a2eaffc to
13e9c70
Compare
|
Thanks @bmjask for the re-review! All 4 findings from review
Verification on
|
bmjask
left a comment
There was a problem hiding this comment.
Review of 13e9c709: 5 finding(s) (2 high, 3 medium), most severe first.
Re-review at 13e9c709. None of the four findings from the a2eaffc4 review (flush thread suspended after the 5 s shutdown timeout, fast-path reservations wiped by the write-lock path, unbounded WM_CLOSE flush, activate dropping runtime.plib on a driver mismatch) was flagged again at this head, so they may be addressed. Please confirm. The findings below are new.
- High
crates/xcl/src/hle/d3d12x/real.rs:8316: see below. - High
crates/xcl/src/shaders/pipeline_library.rs:349: If the real serialized size goes past the cap after a store whose size was underestimated,flush_runtime_ondisables writes for the session and drops every pipeline added since the last flush, and this repeats on every launch. (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:235: On a device without pipeline-library support,open_active_for_devicereturns Ok(None) even with XCL_PREPARE_CACHE_ONLY=1 and prepared libraries present. (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:738:one_buildserializes same-name builds whenever a runtime library exists, even when the holder's result can't land in it (the runtime isfull, the store was skipped, or StorePipeline failed). (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:188: runtime.plib never evicts. (inline)
On lines outside the diff:
- High
crates/xcl/src/hle/d3d12x/real.rs:8316:translated_graphics_pso_oncestores the built pipeline in runtime.plib under the with-rect-GS name even whenretry_without_rect_gsdropped the GS, so the entry describes a different pipeline than its name.cache_eligiblealready keeps this PSO out of the RAM/disk blob caches, but this store only checkscacheable && hr >= 0. Later lookups in the same run hand the GS-less blob to a desc with the GS: the driver refuses it and the pipeline is rebuilt, or, if the driver doesn't check the GS, it's a wrong-pipeline hit. In later runs, LoadPipeline with the GS desc misses, StorePipeline returns E_INVALIDARG, and the entry stays dead and is rebuilt on every run. The stream path already leaves rect_gs out oflibrary_name. Skipping the store whendropped_rect_gs(or!build.cache_eligible && !reused) would fix it.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| let added = runtime.added.swap(0, Ordering::AcqRel); | ||
| if added == 0 { return false } | ||
| let current = runtime.library.serialized_size(); | ||
| if current > runtime.cap { |
There was a problem hiding this comment.
High: If the real serialized size goes past the cap after a store whose size was underestimated, flush_runtime_on disables writes for the session and drops every pipeline added since the last flush, and this repeats on every launch. Near the cap, the slow path admits a store using the estimate (blob + name + 4096). The real entry also carries the root signature, input layout and desc subobjects, so serialized_size ends up slightly over the cap. The next flush sees current > runtime.cap, sets disabled = true and writes nothing. The next launch reopens the same file just under the cap, rebuilds the same pipelines, overshoots again and loses them again. Flushing what fits (or stopping admission with a margin) instead of disabling would avoid it.
| ) -> std::result::Result<Option<Active>, String> { | ||
| let has_prepared = ready.graphics.is_some() || ready.compute.is_some(); | ||
| let use_prepared = check_activation_driver(ready.driver, runtime_driver, has_prepared, cache_only)?; | ||
| if !NativeLibrary::supported(device) { |
There was a problem hiding this comment.
Medium: On a device without pipeline-library support, open_active_for_device returns Ok(None) even with XCL_PREPARE_CACHE_ONLY=1 and prepared libraries present. The old activate returned an error here. Cache-only promises a run with nothing to build, but now the launch carries on, logs an info line, and builds every pipeline in the driver, so a measured cache-only run silently measures cold builds. check_activation_driver covers only the driver-mismatch case, so nothing else restores the guard.
| /// then in the runtime library, so the waiter loads its cached blob instead of recompiling. | ||
| /// Several threads of a title asked for one mesh pipeline at once and each built it, 4 - 6 s | ||
| /// apiece. Only with a runtime library. | ||
| pub(crate) fn one_build(name: &str) -> OneBuild { |
There was a problem hiding this comment.
Medium: one_build serializes same-name builds whenever a runtime library exists, even when the holder's result can't land in it (the runtime is full, the store was skipped, or StorePipeline failed). Each waiter then wakes, misses in with_name, takes the flight and does its own full compile while the rest keep waiting. With runtime.plib at XCL_RUNTIME_LIBRARY_MB, N threads requesting the same pipeline (e.g. a small compute shader with no RAM blob) compile one after another instead of in parallel, stalling title threads for up to N compile times. Skipping one_build when runtime.full is set, or letting a waiter that misses build without taking the flight, would avoid it.
| None => NativeLibrary::empty(device).ok()?, | ||
| }; | ||
| let initial_size = library.serialized_size(); | ||
| let full = initial_size >= cap; |
There was a problem hiding this comment.
Medium: runtime.plib never evicts. Entries whose names changed (after translator or setting changes, which the PR says happen routinely) stay forever, so the file eventually reaches the 2048 MiB cap, full is set at open, and from then on no new pipeline is kept: every new pipeline is rebuilt on every run, while each launch still loads the full 2 GiB of mostly dead entries into RAM. The README says not to delete these folders, so the user has no way out. Rebuilding the file from the names hit in the last run when it nears the cap, or starting fresh when the translator identity changes, would keep it useful.
13e9c70 to
69c106e
Compare
|
Thanks @bmjask for another sharp pass! All 5 findings from review
Verification on
|
bmjask
left a comment
There was a problem hiding this comment.
Review of 69c106e0: 2 finding(s) (1 high, 1 medium), most severe first.
Re-review at 69c106e0. None of the five findings from the 13e9c709 review (runtime.plib store after the rect GS is dropped, flush disabling writes after an underestimated store, the cache-only guard on devices without library support, one_build serializing when the runtime is full, runtime.plib never evicting) was flagged again at this head, so they may be addressed. Please confirm. The two findings below are new.
- High
crates/xcl/src/shaders/warm_library.rs:259: If the staged corpus has no identity file,publish()deletes receipt.json, so on the next launchprepared_state()finds no receipt and reports the libraries Absent. (inline) - Medium
crates/xcl/src/hle/d3d12x/real.rs:9578: Infinish_two_pass, the mesh pass'sone_buildguard lives until the function returns, so it stays held while the thread waits up to 60 s for the shared compute pass'sone_buildand then builds the compute pass, even though the mesh.... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| } else { | ||
| // Without a corpus identity file we cannot prove a future corpus matches this one, so | ||
| // never leave a receipt that would mark later runs Current. | ||
| let _ = std::fs::remove_file(dir.join(RECEIPT)); |
There was a problem hiding this comment.
High: If the staged corpus has no identity file, publish() deletes receipt.json, so on the next launch prepared_state() finds no receipt and reports the libraries Absent. The just-prepared graphics.plib/compute.plib are never used, and full preparation runs again on every launch. For a title whose .xcl/pso-corpus has no identity file, launch 1 prepares and publishes with no receipt. Launch 2 gets read(dir) == None, so Library::Absent("no prepared libraries") triggers discover(), and preparation (graphics worker, every recipe translated) starts over. This repeats on every launch and never reaches Current. With XCL_PREPARE_CACHE_ONLY=1 the title is refused with 'no native pipeline libraries' even right after a successful preparation. Writing a receipt keyed on a fallback identity (or keeping the old one) would let the result be used.
| let gdisk = disk_key.and_then(|(hash, bytes)| driver_cache::graphics_path(hash, bytes)); | ||
| let stream_desc = D3D12_PIPELINE_STATE_STREAM_DESC { SizeInBytes: stream.0.len(), pPipelineStateSubobjectStream: stream.0.as_ptr() as *mut c_void }; | ||
| let library_mesh = disk_key.and_then(|(hash, bytes)| { | ||
| let _one_build = disk_key.map(|(hash, bytes)| crate::shaders::pipeline_library::one_build(&driver_cache::graphics_name(hash, bytes))); |
There was a problem hiding this comment.
Medium: In finish_two_pass, the mesh pass's one_build guard lives until the function returns, so it stays held while the thread waits up to 60 s for the shared compute pass's one_build and then builds the compute pass, even though the mesh pipeline is already built. It isn't stored in runtime.plib until the end. With threads A and B creating the same two-pass pipeline M, A builds the mesh and waits on one_build(C), held by thread D. B waits on one_build(M) for the whole compute wait plus compile, with M's mesh blob already in hand. If A parks in take_cold_slot for the compute pass, release_one_build_on_park drops the mesh flight too: B wakes, finds no M in the library and compiles the mesh pass again, the double compile one_build is meant to prevent. Storing the mesh and dropping its guard before entering the compute pass would fix both.
69c106e to
e39ea9f
Compare
|
Thanks @bmjask! Both findings from review
Verification on
|
bmjask
left a comment
There was a problem hiding this comment.
Review of e39ea9ff: 4 finding(s) (1 high, 3 medium), most severe first.
Re-review at e39ea9ff. The two findings from the 69c106e0 review (receipt deleted for an identity-less corpus, the two-pass mesh guard held across the compute wait) weren't flagged again at this head, so they may be addressed. The first item below looks like a regression introduced by the new storability check.
- High
crates/xcl/src/hle/d3d12x/real.rs:8336: The newgraphics_build_storable_in_librarycheck needscache_eligible || reused, but a library hit is built withreused: false, cache_eligible: false(line 8296), so graphics pipelines imported from the previous library during prep.... (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:233:runtime.stampis written only when the library starts fresh or has no stamp, so it records the build that created runtime.plib, not the builds that filled it, andshould_reset_full_runtimethen throws away full libraries filled entir.... (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:499: When thetry_locksucceeds andadded == 0, or the end flush finishes within the timeout,flush_runtime_timeoutreturns[0, 0], so the periodic xcl-pipeline-library thread isn't excluded fromsuspend_other_threadseven though it.... (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:803:one_buildmakes a title thread wait up to 60 s (XCL_ONE_BUILD_WAIT_S) for any other thread building the same name, including a pso_async preload worker at THREAD_PRIORITY_LOWEST, and the flight is released only if that worker parks in .... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| driver_cache::note(true, loaded.take()); | ||
| } | ||
| if cacheable && hr >= 0 && !ppv.is_null() && !(*ppv).is_null() { | ||
| if graphics_build_storable_in_library(cacheable, &build) && !ppv.is_null() && !(*ppv).is_null() { |
There was a problem hiding this comment.
High: The new graphics_build_storable_in_library check needs cache_eligible || reused, but a library hit is built with reused: false, cache_eligible: false (line 8296), so graphics pipelines imported from the previous library during preparation are no longer stored in the new graphics.plib. In an incremental preparation after a translator or settings change, prepare_graphics -> translated_graphics_pso_once -> load_graphics hits from_previous and returns Loaded::Pipeline, and the store is skipped (on main, cacheable && hr >= 0 stored it). finish() then writes a graphics library holding only the newly built pipelines, so every unchanged graphics pipeline is lost and rebuilt by the next preparation or at runtime. Each preparation drops what the previous one imported. The stream and two-pass paths still store library hits, so only plain graphics is affected. Treating a library hit as storable (or marking it reused) would fix it.
| }; | ||
| let initial_size = library.serialized_size(); | ||
| let full = initial_size >= admit_cap(cap); | ||
| let write_stamp = started_fresh || saved_stamp.is_none(); |
There was a problem hiding this comment.
Medium: runtime.stamp is written only when the library starts fresh or has no stamp, so it records the build that created runtime.plib, not the builds that filled it, and should_reset_full_runtime then throws away full libraries filled entirely by the current build. Build A creates runtime.plib (stamp A). The user updates to build B and plays until the library reaches the cap, so every new entry is a B pipeline. On B's next launch the saved stamp A differs from B, open_runtime logs 'contains entries from an older build' and starts empty, and up to 2 GiB of valid B pipelines are rebuilt. Updating the stamp whenever a flush writes entries would keep it accurate.
| /// (avoiding suspending a thread holding the process heap lock or D3D12 library lock). | ||
| pub(crate) fn flush_runtime_timeout(timeout: std::time::Duration) -> [u32; 2] { | ||
| let Some(runtime) = ACTIVE.get().and_then(|a| a.runtime.as_ref()) else { return [0, 0] }; | ||
| if let Ok(state) = runtime.flush_lock.try_lock() { |
There was a problem hiding this comment.
Medium: When the try_lock succeeds and added == 0, or the end flush finishes within the timeout, flush_runtime_timeout returns [0, 0], so the periodic xcl-pipeline-library thread isn't excluded from suspend_other_threads even though it can start a flush right after the check. In end_title, a title thread stores one more pipeline just after the check, and the periodic thread's 30 s tick starts Serialize (allocating up to 2 GiB and holding the D3D12 library lock). suspend_other_threads suspends it while it holds the heap lock, and drain_gpu / log::flush hang until the 15 s watchdog aborts the process: the freeze the keep-list was added to prevent. Always excluding the periodic thread, or stopping it before the final flush, would close it.
| /// then in the runtime library, so the waiter loads its cached blob instead of recompiling. | ||
| /// Several threads of a title asked for one mesh pipeline at once and each built it, 4 - 6 s | ||
| /// apiece. Only while a non-full runtime library can store the result. | ||
| pub(crate) fn one_build(name: &str) -> OneBuild { |
There was a problem hiding this comment.
Medium: one_build makes a title thread wait up to 60 s (XCL_ONE_BUILD_WAIT_S) for any other thread building the same name, including a pso_async preload worker at THREAD_PRIORITY_LOWEST, and the flight is released only if that worker parks in big_compile_turn. If a preload worker that already has a slot starts a 20–30 s compute or mesh compile of X at lowest priority, it never parks. When the render thread then creates X, it blocks in FLIGHTS.enter for up to 60 s and then builds X anyway, where before it compiled at normal priority straight away. Not waiting on low-priority holders (or boosting the holder while a title thread waits) would avoid the stall.
e39ea9f to
7b4b8ad
Compare
|
Thanks for the thorough re-review @bmjask (cc @Prime1997) — all four findings from the
Re-verification on
|
bmjask
left a comment
There was a problem hiding this comment.
Review of 7b4b8ad0: 4 finding(s) (1 critical, 3 medium), most severe first.
Re-review at 7b4b8ad0. Of the four findings on e39ea9ff, the regression that dropped library-hit graphics pipelines during preparation, the shutdown-suspend gap for the periodic flusher, and the low-priority one_build holder weren't flagged again. The runtime.stamp fix overcorrects (second item below). The first item widens the earlier 'one_build serializes when the runtime is full' finding from 13e9c709 to every build that isn't stored.
- Critical
crates/xcl/src/shaders/pipeline_library.rs:1031:NativeLibrary::serializeallocatesvec![0; GetSerializedSize()]with an infallible allocation on the periodic flusher thread, for a library of up to 2 GiB, so if commit is short Rust aborts the whole title process. (inline) - Medium
crates/xcl/src/shaders/pipeline_library.rs:454: Every successful flush now rewritesruntime.stampto the current build, so a library filled mostly by older builds is labelled current as soon as one entry is added and is never reset. (inline) - Medium
crates/xcl/src/hle/d3d12x/real.rs:8274:one_buildmakes every concurrent creator of a name wait for the holder's build even when that build will never be stored in runtime.plib, so the waiter wakes, misses the library and builds the same pipeline again, and N callers build o.... (inline) - Medium
crates/xcl/src/hle/d3d12x/real.rs:9692: The two-pass mesh pipeline is now stored in the library (preparation BUILD or runtime.plib) before the compute pass is built, so the old guarantee that a mesh entry exists only if its compute pass succeeded is gone. (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| unsafe { self.library.GetSerializedSize() as u64 } | ||
| } | ||
|
|
||
| pub(crate) fn serialize(&self) -> Result<Vec<u8>> { |
There was a problem hiding this comment.
Critical: NativeLibrary::serialize allocates vec![0; GetSerializedSize()] with an infallible allocation on the periodic flusher thread, for a library of up to 2 GiB, so if commit is short Rust aborts the whole title process. Only the read path was made fallible (try_reserve_exact). A title near its commit limit with a 1.8 GiB runtime.plib hits the 30 s periodic flush_runtime, the 1.8 GiB zeroed Vec fails, and handle_alloc_error aborts the game mid-session, on top of the 1.8 GiB D3D12 already holds for the opened library. Using try_reserve_exact here too and skipping the flush on failure would avoid it.
| Ok(()) => { | ||
| state.consecutive_failures = 0; | ||
| runtime.size.store(bytes.len() as u64, Ordering::Relaxed); | ||
| if runtime.write_stamp.swap(false, Ordering::AcqRel) { |
There was a problem hiding this comment.
Medium: Every successful flush now rewrites runtime.stamp to the current build, so a library filled mostly by older builds is labelled current as soon as one entry is added and is never reset. Build v1 fills runtime.plib to 1.95 GiB. After an update to v2, one run adds 50 MiB, the flush writes stamp=v2, and the library is full. Every later v2 launch sees full with a matching stamp, so should_reset_full_runtime is false and full latches. No new pipeline is stored again (and one_build turns off), although ~97% of the entries are dead v1 names. Recording the share of entries per build (or the stamp of the oldest data still present), rather than the last writer, would make the reset decision correct both ways.
| let cacheable = graphics_blob_cacheable(cacheable, ©, final_gs.is_some()); | ||
| let library_name = driver_cache::graphics_name(disk_key.0, disk_key.1); | ||
| let library_pso = if !cacheable || ppv.is_null() { | ||
| let _one_build = (cacheable && !ppv.is_null()).then(|| crate::shaders::pipeline_library::one_build(&library_name)); |
There was a problem hiding this comment.
Medium: one_build makes every concurrent creator of a name wait for the holder's build even when that build will never be stored in runtime.plib, so the waiter wakes, misses the library and builds the same pipeline again, and N callers build one after another instead of in parallel. This happens for a rect-list PSO where retry_without_rect_gs drops the GS (graphics_build_storable_in_library is false), a failed build (hr < 0), estimated_store_bytes returning None, and TransientError/UnusableExisting. A second thread waits through the first thread's whole 4–6 s build (up to XCL_ONE_BUILD_WAIT_S = 60 s), then compiles it itself. Waking waiters with 'not stored, build now' when the holder knows its result won't be stored would restore the parallelism.
| // Mesh pass is done: store it into the pipeline library and drop its `one_build` guard | ||
| // immediately so threads waiting on the mesh name reuse it right away and a later compile-gate | ||
| // park in the compute pass cannot prematurely drop an unstored mesh flight. | ||
| let mesh_library = crate::shaders::pipeline_library::store( |
There was a problem hiding this comment.
Medium: The two-pass mesh pipeline is now stored in the library (preparation BUILD or runtime.plib) before the compute pass is built, so the old guarantee that a mesh entry exists only if its compute pass succeeded is gone. When the driver rejects the compute pass (hc < 0), finish_two_pass returns E_INVALIDARG, but the mesh entry is already in graphics.plib.pending or runtime.plib and marked handed. Preparation publishes an entry for a pipeline that can't be created, runtime.plib spends capped space on pipelines that always fail, and later requests load the mesh blob and fail again at the compute pass. Storing the mesh only after the compute pass succeeds would keep them paired.
Prepared pipeline libraries were discarded whole when anything in their receipt changed (a translator source byte, a setting, the pipeline layout, the staged corpus or the window count), and nothing a title built while it ran was kept. On a retail title with a prepared library, a 240 s run still made 144 driver builds of over a second (690 s): 74 % of that time was the mesh pass of two-pass pipelines, refused blob then the same 330 KB pipeline built by four or five threads at once; 1 130 of the 1 739 drawn pipelines were in no staged corpus and were built every run. A library entry is named after the exact translated DXIL and state, so a changed input can only make a name miss. So: - prepared libraries from a staged corpus live in .xcl/pipeline-libraries/<windows>/ (layouts coexist) with a v3 receipt keyed by driver; corpus, translation, settings and layout only mark them stale, and preparation imports unchanged names from the previous library and builds the rest; staged recipes build for the runtime layout; XCL_PREPARE_CACHE_ONLY=1 names what changed - runtime.plib lives under XCL's per-title data folder (<XCL_DATA_ROOT | %LOCALAPPDATA%\XCL>\<title>\pipeline-libraries\<windows>\runtime.plib) so running a title never writes into the game folder and smoke runs stay isolated; it keeps every pipeline built at runtime (graphics, graphics streams, both two-pass passes, compute), is written atomically under a dedicated flush_lock (no exit data-loss or out-of-order overwrite, never blocking pipeline loads during serialization or I/O), cleans up stale dead-PID runtime.tmp* files on startup, stops retrying after persistent write errors, and resets above XCL_RUNTIME_LIBRARY_MB (1024 MiB default, 0 disables) - one thread builds a given pipeline while others wait (skipping ComputeBuild::CachedWhole probes so dispatch-chain fallback stays non-blocking) and then receive the library entry's cached driver blob for a distinct COM object without recompiling, even for small shaders - a library hands each name's COM object out once per process (D3D12 loads one name as one object, while XCL keys pipeline state by object) and returns its cached driver blob on subsequent lookups - a Pipelines: log line counts prepared / runtime library / blob / built / built after a refused blob per kind (counting graphics streams under Stream and skipping failed fresh builds); refused blobs are logged with their HRESULT; XCL_PIPELINE_MEASURE=1 marks a run that built anything - XCL_RDNA_FLOAT, XCL_WATERFALL_COLLAPSE and XCL_PER_LANE_MAX_INSTS join the settings key; the v1/v2 receipt migration and legacy ids go Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
7b4b8ad to
c301772
Compare
|
Thanks for the sharp review @bmjask (cc @Prime1997) — all four findings from the
Re-verification on
|
Prepared native pipeline libraries were thrown away whole whenever anything in their receipt changed: a translator source byte, a setting, the pipeline layout, the staged corpus, or the memory-window count. Nothing the title built while it ran was kept, so a title rebuilt the same pipelines in the driver every run. On a retail title with a prepared library (240 s run, RTX 5070 Ti, 16 windows), 144 driver builds took over a second each (690 s total), and 1 130 of the 1 739 drawn pipelines were in no staged corpus (same shaders, other blend or depth state), so they were rebuilt on every run.
A library entry's name is already the hash of the exact translated DXIL and state it was built from (
driver_cache::graphics_name,name_for_root_node), and runtime and preparation store and load through the same names. A changed input can only make a name miss, never load the wrong pipeline, so the receipt need not discard the library. This PR keeps the libraries and builds only what is missing:.xcl\pso-corpuslive under<game>\.xcl\pipeline-libraries\<windows>\(4,8,16-heap, ...), so layouts coexist. The receipt (v3) keys on the driver; corpus, translation, settings, and layout identities only mark the libraries stale, so the next preparation imports every unchanged name from the previous library (falling back to legacy.xcl\pso-corpus\{compute,graphics}.plibonce on first upgrade) and builds the rest. A corpus without anidentityfile uses a deterministic content-derived fallback identity from its staged files so it still publishes a reusable receipt while different corpora never collide. Staged recipes build for the runtime layout.XCL_PREPARE_CACHE_ONLY=1still refuses absent, stale, mismatched-driver, or unsupported-device prepared libraries and names what changed, while non-cache-only runs skip mismatched prepared libraries and still openruntime.plib.runtime.plibin XCL's per-title data folder keeps every pipeline built at runtime. Graphics (trackingdropped_rect_gsexplicitly soretry_without_rect_gsfallbacks are skipped whilefrom_previouslibrary hits remain storable during incremental preparation), graphics streams (which previously had no library lookup or store), both passes of two-pass pipelines (stored only once both passes succeed so a failing compute pass never leaves an orphaned mesh entry), and compute are stored in<XCL_DATA_ROOT | %LOCALAPPDATA%\XCL>\<title>\pipeline-libraries\<windows>\runtime.plib— never inside the game folder, so title folders stay read-only/untouched andscripts/smoke.ps1A/B runs stay isolated. It is flushed atomically every 30 s while it grows (paced by size) and at shutdown (bounded to 5 s in bothWM_CLOSEandend_title, setting a shutdown stop flag for the periodic flusher and always returning the periodic flusher's thread ID alongside any timed-out end-flush thread ID soend_titlenever suspends a flush thread while it may hold the process heap or D3D12 lock duringdrain_gpuandlog::flush) under a dedicatedflush_lockheld end-to-end acrossadded.swap(0)+ fallibletry_reserve_exactSerialize()(returningE_OUTOFMEMORYinstead of aborting the process under tight commit) +write_atomic(), without holding any load-blocking lock during serialization or disk I/O. Startup cleans up stale dead-PIDruntime.tmp*files, and persistent write failures stop retrying after 3 consecutive errors (or immediately onERROR_WRITE_PROTECT). D3D12 retains the opened bytes in RAM and each flush serializes a temporary copy (~1–2x the file size in commit);XCL_RUNTIME_LIBRARY_MBdefaults to2048MiB (0disablesruntime.plib) and is enforced on both store/save and load viatry_reserve_fastheld understore_lock.read()plus exactstore_lock.write()checks against an admission ceiling (cap - 2 MiBwith64 KiBper-entry overhead) so D3D12 metadata/subobject overhead cannot push a flush overcap, without latching full on a single unreadable or oversized blob. A siblingruntime.stamprecords per-build byte counts (<layout:translation:settings> <bytes>) so under-cap libraries and full libraries built mostly by the current build survive unchanged while a full library carrying more than half older-build bytes resets fresh. Allruntime.plibread paths (activate,warm_library::inspect,warm_library::publish) shareread_runtime_file, which skips the file at zero cap, rejects oversized files from the opened handle's metadata before reading, and bounds reads withRead::take(cap + 1)if a file grows concurrently;warm_library::statusinspects metadata only.XCL_ONE_BUILD_WAIT_S, default 60 s) and then reuse its cached driver blob directly from the library (Loaded::Blob) to create a distinct COM object without recompiling, even for small shaders belowCOMPUTE_BLOB_MIN_DXIL(16 KiB).ComputeBuild::CachedWholeprobes, chained two-pass compute passes, and full runtime libraries skipone_build;finish_two_passreleases the meshone_buildflight (viarelease_deferred()) and compile slot before entering computeone_buildwhile deferringstore(&mesh_pso)until the compute pass also succeeds;big_compile_turnreleases anyone_buildflight owned by a background worker when it parks; normal-priority callers take over a flight held by a below-normal preload worker immediately rather than waiting behindTHREAD_PRIORITY_LOWESTbackground work; and if a holder finishes without storing a usable entry inruntime.plib(e.g.dropped_rect_gs,hr < 0, unreadable blob,UnusableExisting,TransientError, or over-cap), all waiters wake immediately and build in parallel instead of serializing on a miss.Loaded::Pipeline); later lookups read its cached blob through the adoption-awarereal::read_pso_cached_blobhelper (Loaded::Blob) so callers build a distinct COM object without recompiling even after the first object's vtable was swapped byadopt. TransientStorePipelineerrors stay retryable andE_INVALIDARGafter a failed load is not marked handed out.Pipelines:log line counts prepared / runtime library / blob / built / built after a refused blob per kind (classifyinggraphics stream*labels underStreamand not counting failed fresh builds asBuilt). Refused blobs log their HRESULT.XCL_PIPELINE_MEASURE=1marks any run that built in the driver as invalid.XCL_RDNA_FLOAT,XCL_WATERFALL_COLLAPSE, andXCL_PER_LANE_MAX_INSTSjoin the settings key (alongsideXCL_WAVE64_IDIOMSfrommain). The v1/v2 receipt migration and legacy identities are removed; old.plibfiles in.xcl\pso-corpus\are imported once on first preparation for a layout and can be deleted afterward.Why this is one PR (2 725 insertions / 487 deletions including ~1 100 lines of unit tests): keeping prepared libraries alone still leaves every unrecorded pipeline to rebuild every run; the runtime library deadlocks without hand-out-once, double-compiles concurrently without
one_build+Loaded::Blob, and cannot be verified without thePipelines:accounting.What is in it
crates/xcl/src/shaders/warm_library.rs: layout-scoped prepared folders, legacy.xcl/pso-corpus/*.plibfallback import (previous_library), per-titledata_dirpath forruntime.plib, v3 receipt (with deterministic content-derived fallback identity when a staged corpus has noidentityfile),Library::{Current, Stale, Absent}, capped runtime reads ininspect/publish, metadata-onlystatuscrates/xcl/src/shaders/pso_corpus.rs: prepare staged recipes for the runtime layout into its library folder, passingwarm_library::previous_libraryon first upgradecrates/xcl/src/shaders.rs:prepare_for_launchlibrary reuse,XCL_PIPELINE_LIBRARY_PREVIOUSviawarm_library::previous_library,cache_only_missreasons,xcl cache status, updated settings keycrates/xcl/src/shaders/pipeline_library.rs:runtime.plibactivation indata_dir, non-fatal driver mismatch fallback (unlessXCL_PREPARE_CACHE_ONLY=1with prepared libraries), shared cappedread_runtime_file, fallibletry_reserve_exactNativeLibrary::serialize, adoption-awareread_cached_blob/cached_blob_size, atomic fast-path + exact write-lock cap enforcement (2048MiB default, single unreadable/oversized blob skips without latching full), per-build byte accounting inruntime.stampwith auto-reset when a full library is majority older-build, retryable transientStorePipelineerrors and failed-loadE_INVALIDARGhandling,Loaded::{Pipeline, Blob},flush_lock-serializedflush_runtimeand boundedflush_runtime_timeout(with shutdown flag and always-excluded periodic flusher TID) + persistent-error stop + dead-PIDruntime.tmp*cleanup, park-releasing / priority-aware / parallel-unshared-wakeupone_build, unit testscrates/xcl/src/shaders/pipeline_stats.rs(new): per-kind counts (graphics stream*->Stream, failed fresh builds excluded),Pipelines:summary,XCL_PIPELINE_MEASURE=1, refused-blob HRESULT loggingcrates/xcl/src/hle/d3d12x/real.rs:pub(crate)adoption-awareread_pso_cached_blob/pso_cached_blob_size, explicitdropped_rect_gsflag inGraphicsPsoBuild,one_build(skippingComputeBuild::CachedWholeand chained two-pass compute, releasing meshone_buildviarelease_deferred()+ compile slot before computeone_buildwhile storingmesh_psoonly after compute succeeds, releasing heldone_buildonbig_compile_turnpark),Loaded::{Pipeline, Blob}integration across compute / graphics / graphics stream / two-pass, runtime store, boundedflush_runtime_timeout(5 s)inend_title, driver compile countingcrates/xcl/src/hle/d3d12x/present.rs: boundedflush_runtime_timeout(5 s)onWM_CLOSEcrates/xcl/src/launcher.rs,crates/xcl/src/state.rs:title_data_dirhelper forxcl cache statusand sharedprocess_is_runningfor stale temp cleanupcrates/xcl/build.rs,crates/xcl/src/gpu/recomp/pso.rs: legacy v1/v2 receipt identities removedREADME.md: prepared vs runtime library locations, legacy.xcl\pso-corpus\*.plibone-time import, RAM/commit cost,XCL_RUNTIME_LIBRARY_MB(2048MiB default, store/save + load enforcement), and accounting knobsTested
cargo build --release -p xcl: ok, 39 warnings (matchesmain5eaadb54cbaseline)..\scripts\test.ps1(cargo build --workspace,cargo bench -p xcl --bench '*' -- --test,cargo test --workspace -- --test-threads=4) onc301772a1: 2999 passed, 0 failed, 52 ignored; 24SKIPPEDGPU tests (22no wave64, 2no heap windows).gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsande2e(verifying the game folder stays untouched) both passed.try_alloc_zeroed_returns_oom_instead_of_aborting;one_build_wakes_waiters_in_parallel_when_holder_does_not_store;one_build_normal_priority_does_not_wait_on_low_priority_holder;identityless_corpus_uses_content_fallback_identity_and_detects_changes;dropped_rect_gs_build_is_not_stored_under_rect_gs_library_name;cache_only_fails_without_library_support_and_one_build_skips_when_full;full_runtime_library_resets_only_when_build_stamp_changed(covering both majority-old reset and majority-current keep);with_name_and_store_runtime_hand_out_pipeline_once_then_cached_blob(exercises realreal::adoptbefore second lookup);store_pipeline_does_not_hold_public_refcount_and_adopted_release_reloads_blob;activation_driver_mismatch_warns_and_continues_unless_cache_only;previous_library_prefers_layout_folder_and_falls_back_to_legacy_corpus;two_pass_releases_compile_slot_before_one_build_wait;one_build_releases_when_holder_parks_and_does_not_clobber_new_holder;flush_runtime_timeout_returns_within_budget_when_blocked;store_runtime_retries_after_transient_error_and_does_not_mark_failed_load_handed;cap_reservation_prevents_concurrent_overflow_and_oversized_entry_does_not_latch_full(including 4-thread concurrent store race near tight cap);store_and_flush_enforce_cap_and_preserve_reloadable_library;read_runtime_file_enforces_zero_cap_exact_cap_over_cap_and_growth;status_reports_sizes_from_metadata;flush_runtime_orders_concurrent_flushes_does_not_block_loads_and_stops_on_errors;cleanup_stale_runtime_temps_removes_dead_pid_temps_only;parse_runtime_cap_handles_defaults_zero_and_overflow;kind_of("graphics stream*")->Kind::Streamand failed fresh builds excluded;ComputeBuild::CachedWholeskippingone_build.ea3b5e4d, 60 s runs, fresh isolatedXCL_DATA_ROOTandXCL_DXIL_CACHE, 4 windows, no staged corpus): cold run wrote16.1 MB(16 124 048B)runtime.plib+ per-buildruntime.stamp(16 124 048B attributed to current build;3 934graphics +205compute =4 139pipelines) under<XCL_DATA_ROOT>\<title>\pipeline-libraries\4\with<game>\.xclunchanged; warm repeat in the same isolated data folder served3 932graphics +195compute (4 127total,0 msbind waits) fromruntime.plib, updatedruntime.plibandruntime.stampto17 534 786B, with1 653frames shown (60 60 60),14 668 MBpeak commit,0device removals, and0crashes (<game>\.xclunchanged).Regression run
Both 60 s runs used fresh, isolated
XCL_DATA_ROOTandXCL_DXIL_CACHEfolders on the same retail title (ea3b5e4d) and left the game folder untouched:Note on memory:
runtime.plibstays mapped in RAM for the life of the device and each flush serializes a temporary copy, so longer sessions with larger runtime libraries increase peak commit by roughly 1–2x the size ofruntime.plib(bounded on both write and load byXCL_RUNTIME_LIBRARY_MB, 2048 MiB default; serialization allocates fallibly viatry_reserve_exact).Not tested
no wave64, 2no heap windows).ExitProcessdoes not trigger the shutdown flush (the periodic flush covers those).AI use
origin/main(5eaadb54c), addressed all review findings (per-titledata_dirstorage, non-blockingflush_lock+ fallibletry_reserve_exactNativeLibrary::serialize+ bounded 5 s shutdown flush with shutdown stop flag and always-excluded periodic flusher TID + stale temp cleanup + persistent error stop, adoption-awareread_pso_cached_blob/pso_cached_blob_size, non-fatal activation driver mismatch fallback, explicitdropped_rect_gsflag so incremental library hits stay storable, identity-less corpus fallback identity, legacy.xcl/pso-corpus/*.plibone-time import,finish_two_passearlyrelease_deferred()+ post-compute paired mesh store +big_compile_turnpark release + priority-aware and parallel-unshared-wakeupone_build, retryable transientStorePipelineerrors and failed-loadE_INVALIDARGhandling, atomic fast-path + exact write-lock cap enforcement at2048MiB default, per-build byte accounting inruntime.stampwith majority-stale full-library auto-reset, shared cappedread_runtime_fileand metadata-onlywarm_library::status, empirical D3D12StorePipelinerefcount verification), added unit tests, ran the full test suite and isolated smoke pair on the hardware named, and updated this description.