perf(shaders): accelerate precompilation, warm cache & fix preparation timer #2928
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2928
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2928"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@POMXARK on GitHub · 2026-11-27 00:28 UTC · original
POMXARK:perf/shader-precompile-and-prep-ui→main· +925 −55 · 5 files · 6 commits · openSpeeds up offline/startup shader precompilation, eliminates warm-cache re-work, fixes the preparation progress timer, and validates warm-index DXIL containers before skipping.
What is in it
crates/xcl/src/shaders.rs:recomp::translatecalls (seen_programs) and repeated HLSL compiles/disk checks (seen_hlsl_jobs, e.g. shared mesh passthrough shaders) insideprecompile().precompile-index-v1-<scope>.bin) that validates only its referenced.dxilentries viarecomp::dxc::validated_cache_keys, skippingxbox::parse+ translation on valid hits while automatically recompiling corrupt/missing entries.XCL_DIRECT_DXIL=allfor standaloneVertex/Pixelshaders inprecompile()viapso::console_to_dxil_in, matching runtime behavior.dxc::set_memory_reserve(2)duringprecompile()so both CLI and pre-entry launch preparation benefit cleanly and restore the prior reserve on exit.crates/xcl/src/gpu/recomp/dxc.rs:validated_cache_keys(reusingcached_file/valid_dxil_containerwithout scanning unrelated files),cache_key_for,pub fn toolchain_identity(), thread-localIDxcUtilsreuse incompile_linked(), bounded canonical-path caching innormalized_cache_dir, and zero-syscall directory creation on hot write paths.crates/xcl/src/hle/d3d12x/present/preparation.rs:"No shader progress for 0 s"text with realElapsed, throughput (records/s), andETA, surfacing"No shader progress for N s"only whenquiet >= 5.crates/xcl/tests/shaders_e2e.rs:shaders_precompile_recovers_corrupt_same_length_cached_dxilverifying recovery when a cached.dxilis overwritten with same-length zero bytes while a warm index is present.Tested
32.0.16.2124/621.24), AMD Ryzen 7 5700X (8C/16T),rustc 1.91.1 (ed61e7d7e 2025-11-07), DXC/DXIL1.8.2502.11, debug tests & release build (--locked).cargo test -p xcl --lib dxc -- --test-threads=4: 45 passed, 0 failed, 3 ignored (dump_dxc_lowering,blob_dxc_cost,dxc_time_levels)cargo test -p xcl --lib preparation -- --test-threads=4: 5 passed, 0 failed, 0 ignoredcargo test -p xcl --lib shaders -- --test-threads=4: 17 passed, 0 failed, 0 ignoredcargo test -p xcl --test shaders_e2e -- --test-threads=4: 9 passed, 0 failed, 0 ignored (includesshaders_precompile_recovers_corrupt_same_length_cached_dxil)--precompile --limit 300, NVMe SSD):18.33 s(main) ->15.40 s(6c1a9ffwarm-index + container validation).dxil/ 9.3 MB):15.24 s(main) ->0.63 smedian (0.677 / 0.631 / 0.632 s)XCL_DIRECT_DXIL=all:18.57 s -> 12.68 s(-31.7%)--precompile --limit 1500, 2,711 hits across 2,988.dxil/ 242.5 MB on HDD):110.79 s(main) ->4.01 scold OS page cache /0.72 s(0.722 / 0.714 s) warm OS page cache (compiled 0, already cached 2711, errors 0).Regression run
main (
af2cecc408) and pre-cache runs timed out at 120s startup timeout while compiling the 26,503-shader pack on cold cache (XCL printed no log pathbefore entering the guest). Fullscripts/smoke.ps1run pending cold shader cache completion (ortest-onlylabel).Not tested
cargo test --workspace -- --test-threads=4(only targeteddxc,preparation,shaders, andshaders_e2esuites were run).AI use
@ettehn on GitHub · 2026-11-27 00:33 UTC · original
Reproduced a false warm-cache hit on exact clean head
1d3b766db198b67732f2e6cc379e57ddaa220cddon Windows 11 26200.9974 / RTX 5070 Ti Laptop (621.24), debug, Rust 1.97.1 MSVC, DXC/DXIL 1.8.2502.11. I used one synthetic pixel shader built with the existingshaders_e2econtainer fixture and ranxcl shaders <fixture folder> --precompilewith an isolated XCL cache.Every run exited 0 with zero reported shader errors.
existing_cache_keyschecks the filename and minimum length, then the index-hit branch skips the normal container validation. The same-length damage case is a useful CLI regression if the warm index is meant to preserve corrupt-cache recovery. Test scope was standalone precompile with a synthetic graphics shader. OpenAI Codex (6.2sol) assisted with verification.@ettehn on GitHub · 2026-11-27 00:37 UTC · original · edited 2026-11-27 00:41 UTC
Follow-up with a tested fix on top of
1d3b766: load the index first, collect its referenced DXIL keys, then accept a key only when the existingcached_filevalidator accepts its container. This keeps the early skip of parsing and translating a shader record on a sound hit. It reads each referenced DXIL container at startup and leaves unrelated cache entries unread.Warm-cache timing added: on the same Windows machine, offline
--precompile --limit 300(default HLSL path, no PSO builds), 4 interleaved warm runs per binary, same seeded cache with 337 DXIL files (9.75 MB). Median wall time: 1,372.75 ms original vs 1,397.55 ms with validation (+24.8 ms, +1.8%). The ranges were 1,369.9–1,380.7 ms and 1,394.8–1,409.6 ms. Every run reported 0 compiled, 475 cached, 0 errors. This measures the small sample with a warm OS file cache; the full pack and cold-storage I/O are still unmeasured.I added an end-to-end test using the existing synthetic pixel shader fixture. It checks a cold compile, a valid warm hit, then overwrites the cached DXIL with zeros without changing its length. The test fails on the original head (
compiled 0, already cached 1) and passes with validation (compiled 1, already cached 0, original DXIL bytes restored). On Windows / RTX 5070 Ti Laptop,shaders_e2epassed 9/9 and thecache_tests precompile_indexlibrary filters passed 36/36 with the local fix. OpenAI Codex (6.2sol) assisted with the patch and verification.@andrewDoing on GitHub · 2026-11-27 00:58 UTC · original
I reproduced a valid-file warm-index mismatch on
1d3b766db198b67732f2e6cc379e57ddaa220cdd, separate from the corrupt-file case. A clean build precompiled a synthetic pixel shader; the same source with #2930's emitter change then reported a warm hit but did not create the new DXIL key that its cold run produced. The two minimal-test DXIL payloads happened to be identical, so this demonstrates missed preparation, not incorrect pixels.Including the existing
XCL_TRANSLATOR_SOURCE_IDin the index scope addressed that cross-build case. Two runtime options also matter: a branching PS underXCL_RECOMP_NO_STRUCTURED=1and a barrier-containing mesh shader underXCL_SAFE_BARRIER=0selected new DXIL keys, but a source-ID-only index still reported the old entries warm.A local candidate scopes the index by translator source identity and the effective safe-barrier setting, and reuses the existing conservative cache policy for other diagnostic overrides. It leaves runtime shader-cache eligibility unchanged. A standalone synthetic regression passed 19 CLI invocations across two independently built emitter revisions, including unset versus explicit
1, and0versus whitespace-padded0. Same-configuration repeats remained warm. An independent agent reran the 19 checks and reviewed the candidate. Retail behavior and performance remain unmeasured.AI use: OpenAI Codex with GPT-6.2 Astra constructed the probes, tested the candidate and independently reviewed it; Codex coordinated and prepared this report.
@POMXARK on GitHub · 2026-11-27 01:20 UTC · original
@ettehn Thanks for catching and reproducing this! Pushed
6c1a9ff(6c1a9ffb31137dcbd2b09b6f5ae4e0da3cbd635b) with that exact fix:Validate only referenced warm-index DXIL entries (
dxc.rs/shaders.rs)existing_cache_keys(which only checked filename +len >= 36) withrecomp::dxc::validated_cache_keys(dir, &referenced).precompile()now loadsprecompile-index-v1-<scope>.binfirst and validates only the keys referenced by the index via the existingcached_file(valid_dxil_container) check, leaving unrelated files in the cache directory untouched. Any corrupt or zero-filled.dxilof identical byte length is rejected from warm-hits and cleanly recompiled/overwritten.Regression tests & verification (Windows 11, RTX 5080,
rustc 1.91.1)shaders_precompile_recovers_corrupt_same_length_cached_dxilincrates/xcl/tests/shaders_e2e.rs(cold compile -> valid warm hit -> overwrite.dxilwith same-length zero bytes -> verifycompiled 1, already cached 0, errors 0and restoredDXBC/DXIL bytes).validated_cache_keys_and_memory_reserve_swap_behave_cleanlyindxc.rsto reject same-length zeroed files and ignore unreferenced cache keys.cargo test -p xcl --lib dxc -- --test-threads=4: 45 passed, 0 failed, 3 ignoredcargo test -p xcl --lib preparation -- --test-threads=4: 5 passed, 0 failedcargo test -p xcl --lib shaders -- --test-threads=4: 17 passed, 0 failedcargo test -p xcl --test shaders_e2e -- --test-threads=4: 9 passed, 0 failedMeasured warm-I/O validation cost
.dxilfiles / 9.3 MB):0.677 s/0.631 s/0.632 stotal wall time (compiled 0, already cached 475, dominated by ~0.55 s initial RPF9 read) vs15.24 sunindexed warm baseline (01_xclon the same 300-record cache)..dxilfiles / 242.5 MB, 38.1 KB index):4.01 s(compiled 0, already cached 2711, errors 0)0.722 s/0.714 smain):110.79 s@andrewDoing on GitHub · 2026-11-27 01:23 UTC · original
I retested the valid-file index cases from my earlier comment on updated head
6c1a9ffb31137dcbd2b09b6f5ae4e0da3cbd635b. The new damaged-file validation addresses a separate case; these intact entries still produced stale warm-index hits:XCL_RECOMP_NO_STRUCTURED=1on the synthetic branching pixel shader: the warm run reported 1 cached, while a fresh or index-bypassing run generated a different DXIL key.XCL_SAFE_BARRIER=0on the synthetic mesh shader: the warm run reported 2 cached, while a fresh or bypass run generated a different compute key and reused the passthrough key.All 11 fresh-process checks exited successfully. This shows preparation can skip the newly selected cache key; it does not establish a rendered-pixel error or GTA VI loading impact.
AI use: OpenAI Codex with GPT-6.2 Astra ran the checks; Codex coordinated and prepared this follow-up.
@POMXARK on GitHub · 2026-11-27 01:40 UTC · original
@andrewDoing Thank you for catching that! That cross-build and option-scoping bug is fixed in
fe16099(fe16099b195d971ab89a96def5a0ad214fb13401):Translator source identity in index scope (
shaders.rs)precompile_index_scopenow hashesenv!("XCL_TRANSLATOR_SOURCE_ID")alongsideCARGO_PKG_VERSION,dxc::toolchain_identity(), window count, split flags,direct_gfx, and effectivesafe_barrier, so emitter changes automatically isolate oldprecompile-index-v1-*.binfiles and trigger fresh DXIL generation.Runtime option scoping & diagnostic bypass (
pso.rs,shaders.rs)safe_barrier(XCL_SAFE_BARRIER:raw.map_or(true, |v| v.trim() != "0")) in the index scope so"0"/" 0 "and unset/"1"/" 1 "use distinct scopes without false misses on whitespace/explicit defaults.pso::precompile_index_allowed()reusingpso::cache_allowed(Stage::Pixel, ...)so when any diagnostic override is present (XCL_RECOMP_NO_STRUCTURED,XCL_RECOMP_WHY,XCL_X64_ALL_MASKS,XCL_WAVE64_SPIN,XCL_DXIL_NO_OPT,XCL_DEBUG_*),use_record_indexis forced tofalse.Tests added & verified on Windows 11 / RTX 5080 (
rustc 1.91.1)shaders::tests::precompile_index_round_trips_and_ignores_corrupt_tail(translator source ID flip,safe_barrier_enabledpadding/toggle, all 9cache_allowedenv vars).shaders_precompile_scopes_safe_barrier_and_bypasses_diagnostic_overridesincrates/xcl/tests/shaders_e2e.rs.cargo test -p xcl --lib dxc -- --test-threads=4: 45 passed, 0 failed, 3 ignoredcargo test -p xcl --lib preparation -- --test-threads=4: 5 passed, 0 failedcargo test -p xcl --lib shaders -- --test-threads=4: 17 passed, 0 failedcargo test -p xcl --test shaders_e2e -- --test-threads=4: 10 passed, 0 failed@andrewDoing on GitHub · 2026-11-27 01:41 UTC · original
A separate synthetic concurrency check on current head
6c1a9ffb31137dcbd2b09b6f5ae4e0da3cbd635b: two CLI processes preparing different shaders into the same initially empty cache both returned success, but the resulting shared record index contained only one of the two entries. This happened in 3/3 concurrent pairs. Sequential preparation retained both entries.Both DXIL files from every concurrent pair were byte-identical to the sequential controls. A serial revisit restored the two index entries with one cached shader and zero compiles per run. The demonstrated effect is a lost index shortcut, not lost DXIL or demonstrated extra DXC compilation. Retail timing remains unmeasured.
The experiment used two repository-derived synthetic pixel shaders and separate temporary caches per trial. In the current implementation each process loads an index snapshot and later saves its full updated snapshot to the shared path.
AI use: OpenAI Codex with GPT-6.2 Astra built and ran the synthetic checks; Codex coordinated and prepared this follow-up.
@andrewDoing on GitHub · 2026-11-27 01:43 UTC · original
Retested the valid-file cases from my earlier reports on updated head
fe16099b195d971ab89a96def5a0ad214fb13401. The new scope and eligibility changes passed 19 synthetic CLI invocations: five across emitter builds, six for the branching pixel shader with the structured-flow override, and eight for the mesh safe-barrier settings. Warm runs produced the independently established cold keys, and equivalent barrier settings shared the expected index. No title or gameplay performance was measured.The concurrent-writer case in my other comment is separate. On this head 3/3 concurrent pairs still retained only one of two index records; both DXIL files remained intact, and serial recovery recompiled neither shader.
AI use: OpenAI Codex with GPT-6.2 Astra ran the checks; Codex coordinated and prepared this follow-up.
@andrewDoing on GitHub · 2026-11-27 01:51 UTC · original
Follow-up to my concurrent-index report: I tested a local Windows candidate on
fe16099bthat acquires a persistent sidecar file lock, reloads the latest index under the lock, merges only newly learned records, and replaces the index from a completed same-directory temporary file. Compilation remains outside the lock.All three concurrent two-process trials retained both index entries and produced DXIL byte-identical to the sequential control. A focused Rust serialization/merge regression passed. In separate controls, a held lock, a handle denying replacement, and an inaccessible sidecar each left the previous index intact; preparation still completed and a later run recovered both entries. The lock attempt is best-effort and timed out after about 250 ms in the held-lock test. A separate process-death test confirmed the OS releases the lock when its owner exits.
This addresses the index shortcut only. It does not establish a retail timing benefit, and power-loss durability was not tested.
AI use: OpenAI Codex with GPT-6.2 Astra implemented and independently reviewed the candidate and ran the synthetic tests; Codex coordinated and prepared this follow-up.
@POMXARK on GitHub · 2026-11-27 02:17 UTC · original
@andrewDoing Thank you again for isolating the concurrent-writer race and testing that approach! Pushed
9b91851(9b918518e4ca7f6a02e4ffae13a9e5a3c77a2645) closing this race:Bounded cross-process lock + reload-merge + non-destructive replace (
dxc.rs,shaders.rs)recomp::dxc::lock_cache_file_timeout(path, 250)reusing the per-path Windows named mutex (best-effort 250 ms wait so a stuck lock cannot stall preparation; OS automatically releases mutex ownership if an owner exits).save_precompile_indexnow only tracks and merges newly learned entries from the current run (index_statestarts empty), reloads the latest on-diskprecompile-index-v1-<scope>.binunder the lock, writes a unique same-directory temp file, and replaces atomically viaMoveFileExW(..., MOVEFILE_REPLACE_EXISTING)without deleting the prior file first (if replacement fails, the previous index stays intact). Compilation and DXIL writes stay outside the index lock.Tests verified on Windows 11 / RTX 5080 (
rustc 1.91.1)shaders::tests::precompile_index_round_trips_and_ignores_corrupt_tailto verify disjoint additions merge cleanly onto an existing index.shaders_precompile_concurrent_processes_preserve_both_index_entriesincrates/xcl/tests/shaders_e2e.rs(3 trials of two concurrentxcl shaders --precompileprocesses into an empty cache, asserting both succeed and subsequent warm runs of both hitcompiled 0, already cached 1).dxc45/45 (3 ignored),preparation5/5,shaders17/17,shaders_e2e11/11 (78/78 PASS).@andrewDoing on GitHub · 2026-11-27 02:22 UTC · original
Retested the concurrent-writer case from my earlier comment on updated head
9b918518e4ca7f6a02e4ffae13a9e5a3c77a2645. In 3/3 synthetic two-process pairs, the index contained both expected record hashes immediately after the children exited and before any serial revisit. Both DXIL files matched the sequential control byte-for-byte. The earlier heads retained only one record in the same check.One test-oracle suggestion: checking only that subsequent serial runs report
0 compiled, 1 cacheddoes not by itself prove both initial records survived. In the earlier failing trials, intact DXIL files allowed those serial runs to hit and repair the missing index entry. Inspecting both record hashes before either revisit distinguishes the cases.In a separate Windows sharing-violation control, the prior index remained intact and both DXIL outputs were retained. This is synthetic cache evidence, not a retail timing measurement.
AI use: OpenAI Codex with GPT-6.2 Astra ran the controls and independently reviewed the test oracle; Codex coordinated and prepared this follow-up.
@ettehn on GitHub · 2026-11-27 02:24 UTC · original · edited 2026-11-27 02:30 UTC
One Windows path regression in
9b91851’s new index replacement. I built the exactload_precompile_index,save_precompile_index, and mutex helpers in a small standalone Rust 1.97.1 harness on Windows 11. Two saves with disjoint entries worked at 110 characters. At 326 characters, a normal absolute path created the directory and temporary file via Rust std, but bothMoveFileExWcalls returned Windows error 3 and no index was saved. The same directory worked through its canonical extended-length path.Replacing only the raw Win32 call with
std::fs::rename(&tmp, path)and retaining temp cleanup on error saved both entries through the ordinary 326-character path. With a destination handle denying replacement, the call still failed and the previous index stayed byte-identical. Retrying after closing the handle merged the third entry. No pre-delete is needed. This was an isolated index I/O test, without the full CLI or a retail title. Windows path limits · Rust renameConcurrent long-path check. I tested ten fresh pairs of independent writer processes per variant. One process used an ordinary absolute path (314–315 characters) and the other used the canonical extended-length spelling of the same index. Both spellings contended on the same mutex. On
9b91851, the ordinary-path writer failed with Windows error 3 in 10/10 pairs and only the extended-path writer’s record survived. With thestd::fs::renamechange, both saves succeeded and both exact records were present immediately after exit in 10/10 pairs, before any serial revisit. This used the same standalone index harness.OpenAI Codex (6.2sol) assisted with verification.
_Originally posted by @ettehn in #2928
@andrewDoing on GitHub · 2026-11-27 02:36 UTC · original
I reproduced @ettehn’s Windows long-path finding through
xcl shaders <input> --precompileon9b918518. I used one synthetic pixel shader and setXCL_DXIL_CACHEseparately for each process.\\?\prefixAll three processes exited successfully and reported zero shader errors. The long-path run preserved the compiled shader but silently missed the index write. The extended-path revisit shows why the CLI summary alone cannot verify index persistence. This test covered the existing PR head. @ettehn’s proposed replacement was tested separately in the index harness.
AI use: OpenAI Codex with GPT-6.2 Astra ran the CLI checks; Codex coordinated and prepared this follow-up.
@POMXARK on GitHub · 2026-11-27 02:42 UTC · original
@ettehn @andrewDoing Thank you both for the follow-up verification and catching these! Pushed
65091a5a7af87d5d0b5bf11f35a34bd17e948661addressing both points:1. Long-path index replacement (
crates/xcl/src/shaders.rs) — @ettehnMoveFileExWinsave_precompile_indexwithstd::fs::rename(&tmp, path)(cleaning&tmpand leaving any existing index intact if replacement fails, without pre-deleting).shaders::tests::precompile_index_saves_and_merges_over_long_pathexercising round-trip save and disjoint merge on a path exceeding 260 characters.2. Direct on-disk index oracle in parallel E2E (
crates/xcl/tests/shaders_e2e.rs) — @andrewDoingshaders_precompile_concurrent_processes_preserve_both_index_entriesto parse theXCLPIDX1index file from disk right after both concurrent child writers exit and assert both distinct entry hashes are present (entries.len() == 2) before any sequentialwarmrevisit runs.Tests verified on Windows 11 / RTX 5080 (
rustc 1.91.1)cargo test -p xcl --lib dxc -- --test-threads=4: 45 passed, 0 failed, 3 ignoredcargo test -p xcl --lib preparation -- --test-threads=4: 5 passed, 0 failedcargo test -p xcl --lib shaders -- --test-threads=4: 18 passed, 0 failed (includesprecompile_index_saves_and_merges_over_long_path)cargo test -p xcl --test shaders_e2e -- --test-threads=4: 11 passed, 0 failed (includes updatedshaders_precompile_concurrent_processes_preserve_both_index_entries)cargo build --release --locked -p xclPASS@andrewDoing on GitHub · 2026-11-27 02:46 UTC · original
On head
65091a5a7af87d5d0b5bf11f35a34bd17e948661, I reproduced a Windows case where an existing record index could be replaced even though the writer could not read it for the merge.I used the unmodified
xcl shaders --precompileCLI, two distinct synthetic shaders, and a fresh temporary DXIL cache per trial. After preparing shader A, I opened its index with read, write, and delete sharing and took an exclusive Windows byte-range lock on its first byte. I confirmed an independent read failed with the lock held. I then prepared shader B into the same cache, released the lock, and read the index before revisiting either shader.In 3/3 trials, B's preparation succeeded with zero reported errors. A's record hash
50400740f07017b0disappeared. The complete 28-byte index matched a separate cold B-only reference byte-for-byte, containing onlyf6376fb69eb5f730. Both DXIL files remained present. A separate trial denying read sharing while permitting delete sharing also lost A's record. This demonstrates loss of a cache-index entry under a forced read failure. I did not observe shader corruption or measure title performance.The save path currently treats every index read error as an empty map. For publication, treating only
NotFoundas empty and skipping the save on other I/O errors would preserve the existing index until it can be read again. The ordinary startup lookup can still treat unreadable data as a cache miss.AI use: OpenAI Codex with GPT-6.2 Astra adapted and ran the Windows probes, checked the independent reference, and drafted this report.
@andrewDoing on GitHub · 2026-11-27 02:46 UTC · original
Retested the long-path and concurrent-writer cases on updated head
65091a5a7af87d5d0b5bf11f35a34bd17e948661. The full CLI wrote one index record on a 304-character ordinary Windows path, then merged a second. Both record hashes and DXIL keys matched the short-path control before a warm revisit; the revisit hit. Three concurrent pairs also preserved both expected records before revisits, with DXIL files byte-identical to the sequential control.This confirms the tested long-path and normal concurrent-writer fixes; the forced read-failure case in my separate follow-up remains distinct. No retail title or timing was tested.
AI use: OpenAI Codex with GPT-6.2 Astra ran the synthetic CLI checks; Codex coordinated and prepared this follow-up.
@andrewDoing on GitHub · 2026-11-27 02:49 UTC · original
Follow-up to the forced index-read failure on
65091a5a7af87d5d0b5bf11f35a34bd17e948661: I tested a local candidate where the writer treatsNotFoundas an empty index but skips publication for other read errors. Normal lookup remains best-effort.In 3/3 Windows byte-range-denial trials, shader B still compiled while the existing A index remained byte-identical. After the lock was released, a B revisit produced both exact reference records. In 3/3 normal concurrent-writer pairs, both records were present immediately and both DXIL files matched the sequential controls. This is synthetic cache testing; retail performance and power-loss durability remain unmeasured.
AI use: OpenAI Codex with GPT-6.2 Astra implemented and tested the local candidate; Codex coordinated and prepared this follow-up.
@ettehn on GitHub · 2026-11-27 04:06 UTC · original
I measured one remaining warm-index cost on
65091a5a.--precompile --limit 1still reads the DXIL for every key referenced by the whole index before selecting the input record. With one synthetic pixel shader selected, I populated both build-scoped indexes with the same selected record and 4,096 additional synthetic index entries, each pointing to an existing valid 2,828-byte DXIL file. Windows 11 26200, MSVC Rust 1.97.1 debug, SDK DXC 1.8.2502.11. Six interleaved fresh processes per variant with a warm OS file cache.65091a5a, eager validationAll runs reported
compiled 0, already cached 1, errors 0. Read counts are Windows logical process I/O, including the index, input, and DXIL. The local patch memoizes validation in a per-keyOnceLock<bool>and calls the same existing container validator only when a selected record needs the key. The 11shaders_e2etests passed, including same-length corruption recovery and concurrent index writers. This measures a small precompile slice against a larger warm index. Full-pack throughput and retail impact remain unmeasured.OpenAI Codex assisted with the local patch and verification.
@LocranKing on GitHub · 2026-11-27 05:25 UTC · original
Tested PR #2928 (
65091a5a) againstmain(8b957bec) onshaders.rpf(9cc6a39e) using an RTX 3060 Ti (8 GiB, driver621.40) / Ryzen 5 5500 (6C/12T) withXCL_DEVICE_TYPE=lockhart,XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXIL=all,XCL_DIRECT_SPLIT_INSTRUCTIONS=0, and DXC1.9.2602.17(21d28f72).Precompile A/B (
xcl shaders shaders.rpf --precompile --limit N)Each arm used an isolated
XCL_DXIL_CACHEdirectory in order (cold --limit 300->warm --limit 300->cold --limit 1500->warm --limit 1500):main(8b957bec) wall / reportedmaincounts (compiled / cached / err / skip)65091a5a) wall / reportedcompiled / cached / err / skip)--limit 30017.070 s/16.7 s337 / 138 / 0 / 713.792 s/12.0 s337 / 138 / 0 / 7--limit 3000.801 s/0.7 s0 / 475 / 0 / 70.664 s/0.6 s125 / 350 / 0 / 7--limit 1500215.502 s/215.4 s1264 / 1447 / 0 / 31202.950 s/202.9 s1389 / 1322 / 0 / 31--limit 15002.082 s/2.0 s0 / 2711 / 0 / 310.763 s/0.7 s289 / 2422 / 0 / 31Notes
--limit 300improved17.07 s -> 13.79 s, cold--limit 1500improved215.50 s -> 202.95 s, and warm--limit 1500dropped2.082 s -> 0.763 s(~2.7xfaster).XCL_DIRECT_DXIL=all: Incrates/xcl/src/shaders.rs, whendirect_gfx(XCL_DIRECT_DXIL=all) is active,Vertex/Pixelentries take theconsole_to_dxil_in(...)branch which setsrecord_indexable = falseand incrementscompiledunconditionally onOk(_)instead of distinguishing cache hits from fresh compiles. That explains why the warm--limit 300and--limit 1500runs still reportedcompiled 125andcompiled 289(350 + 125 = 475and2422 + 289 = 2711) despite finishing in0.6 s/0.7 s.--precompile --pipelines, startup-screen cancellation (launchprep timer), or live in-game frames on PR #2928.@POMXARK on GitHub · 2026-11-27 11:17 UTC · original
Thanks for the reviews @andrewDoing @ettehn @LocranKing — pushed updates addressing all three items:
Preserve index on non-
NotFoundread errors (@andrewDoing):Split out
try_load_precompile_indexincrates/xcl/src/shaders.rs.save_precompile_indexnow propagates non-NotFoundstd::fs::readerrors instead of falling back to an empty map, preventing an unreadable or Windows-locked existing index from being overwritten/truncated.load_precompile_indexkeeps best-effort behavior at startup. Addedsave_precompile_index_preserves_existing_file_on_read_error(including a Windowsshare_mode(0)lock case).Lazy per-key DXIL validation (
@ettehn):Removed the eager
validated_cache_keysscan across the wholeinitial_indexbefore--limitselection. Addedrecomp::dxc::validate_cached_keyand memoized per-keyOnceLock<bool>cells insideprecompile()so.dxilcontainers are validated on demand only for records actually visited during the run (still catching same-length corruption).Accurate
compiledvsalready cachedcounts underXCL_DIRECT_DXIL=all(@LocranKing):Added
pso::console_to_dxil_in_status(propagating RAMShaderCache, on-disktranslated/v2, and DXC.dxilcache-hit status) and wired it into both the compute and direct graphics arms inshaders::precompile(), plus e2e coverage inshaders_precompile_direct_dxil_warm_reports_cached_and_limit_skips_unselected_keys.Verified on Windows (
cargo check -p xcl --all-targets,precompile_index3/3,validated_cache_keys1/1,shader_cache_tests23/23,shaders_e2e12/12 — all passing).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.