Repository navigation
Shaders: startup preparation builds a split program's whole, not its chain - #3442
Conversation
|
Test results wanted. This PR should cut the driver work of a cold shader preparation. Each split compute program now gets one driver compile, not 2 + its pieces. I can only measure it on one NVIDIA card here, and the NVIDIA driver's own shader cache makes a "cold" run less cold than it looks. Runs on other GPUs, especially AMD and Intel, would help most. What to run (on your own game dump; the same title, settings and machine for both sides):
What to report for each side:
Expected: the PR's side writes fewer Please post one comment and edit it if you rerun (see CONTRIBUTING, "Reviews and test reports"). Written with Claude Code (Claude Opus 5.5). |
|
The stock integration test I put a one-file test update on our fork. It checks the exact single ABI On RTX 5070 (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0 MSVC and DXC 1.8.2502.11, the complete Codex with GPT-6.2 Sol implemented the integration test update and ran the checks. |
f157425 to
178241b
Compare
178241b to
148031e
Compare
148031e to
f6bace4
Compare
…chain The mandatory preparation path (prepare_compiled_compute: xcl run's startup preparation and its workers, the PSO corpus and milestones) built every split compute program three ways: the whole DXIL under the ABI root (.pso), every piece under the chain root(s) (.chain.pso), and the whole DXIL again under each chain root. Since ec80c07 the runtime first loads the ABI whole blob (CachedWhole) and builds no chain when it loads, so the pieces and the chain-root whole were never used. In a cold full preparation of a retail game, size-weighted, the chain-root wholes are ~40 % of the compute driver work and the pieces ~12 %: ~52 % in all (51-53 % for size^1.5 to size^1.7). Now the whole is built first, and the chain only when the runtime would not find the whole (chain_needed): it was refused or over the cap, or its driver blob is not on disk. A record whose whole failed is prepared when its pieces are built; the chain-root whole is not tried then (the same DXIL under another root). The non-mandatory --pipelines path (make_selected) is unchanged. The e2e test a_preparation_worker_also_builds_a_split_programs_whole_form (xcl-dev#2794) expected the old pieces plus whole. It becomes a_preparation_worker_keeps_a_split_programs_abi_whole, by andrewDoing: the program splits into >= 2 pieces, the worker writes exactly its ABI whole, a warm worker run builds nothing, and a fresh runtime process loads that blob and dispatches it correctly. His part was written with OpenAI Codex (GPT-6.2 Sol). Co-Authored-By: andrewDoing <18390227+andrewDoing@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f6bace4 to
3012206
Compare
|
Thanks @andrewDoing, that's a better test than mine.
AI use: Claude Code (Claude Opus 5.5) drafted this reply. |
Extend recorded_split_selects_cached_whole_or_pieces: for the miss and stale cases (whole blob absent, or the driver rejects it) the hook already selects the chain root and does not keep a whole blob; now the registered chain plan is dispatched and its memory result must equal the whole program's. This covers the edge PR xcl-dev#3442 lists as untested: a runtime that cannot load the whole now builds the pieces cold, and those pieces run the program correctly. Proven here: the decision test a_split_programs_chain_is_prepared_only_without_its_whole, pipeline_cap_tests (8 passed, 1 adapter SKIPPED), and the A/B preparation counts below. Still needs a GPU run: the dispatch assertion itself, because this container's vkd3d-proton/RADV page-faults at 0x110 compiling XCL's split-protocol piece DXIL (simple DXC pieces with the chain root signature compile; the synthetic split e2e dies the same way). On a driver where pieces build, run the test with XCL_SAMPLE_RUNTIME_COMPUTE and XCL_SAMPLE_CACHE_CASE=miss|stale. Preparation A/B on WARP (CPU-only, XCL_SPLIT_WAVE64=1, 1 pipeline thread), 5 split records + 1 unsplit control, fresh XCL_DXIL_CACHE and fresh VKD3D_SHADER_CACHE_PATH per side: main e9e608f: rc 5 (vkd3d page fault building a piece), 6 .pso + 5 partial .chain.pso, 25.0 s wall - the double build is cut short by the driver. this branch: rc 0, 6 .pso + 0 .chain.pso, 24.9 s wall. The over-cap branch (pieces instead of the whole) could not be completed on this stack for the same piece-compile crash; it is covered by the decision test and needs the GPU run.
…its chain (xcl-dev#3442 by KOLESNiii)
|
Test report: split-program preparation A/B on Linux/Wine + vkd3d-proton (AMD) — extra data point, not a merge check Setup. Our tree is a Linux/Wine stack (main
B matches your claim: one ABI What we could not complete on this driver: the over-cap branch (pieces instead of the whole; the decision test covers the policy), and the runtime fallback execution. Your "not tested" item — a runtime that rejects the whole blob — we took seriously: we extended How our tree differs from main (mostly orthogonal to this PR): it is the curated Linux stack with a ported HLE layer; translator deltas (watertight BVH, a barrier proof that lowers proven-uniform CS barriers, CLAMP/OMOD/DX9 multiply, #3455 cherry-picked as Not tested here: the Windows suite (per the queue's rule a Wine run is an extra data point, not a merge check), NVIDIA/Intel, a full retail preparation, and the GPU over-cap path. AI use: omp harness with nanogpt/deepseek/deepseek-v4.1-flash-1017; subagents ran the builds and the A/B on the machine above. No game data is included. |
|
Test report: full startup shader preparation, cold cache, with #3442 + the #3263 stack + the #3269 stack together One run of a build that combines these three PRs. It shows what they do together; it does not say how much each one contributes. Build:
This PR in the build: Run: retail game, Compared with: the same retail game and settings on 4465c886 alone (the base above, without the three PRs and without the heap switches), run earlier today with a warm cache: it started with 48,305 translations, 44,556 DXIL files and 13,051 driver blobs, and reused about half of its driver blobs.
Graph. Progress of every full preparation run on this PC. This build is the solid blue line, the base the dashed pink one; in the lower panel blue reaches 100 % at ~1.4 h, pink at ~3.4 h. Data and script: CSVs + Not tested / limits
Hardware: NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1. Tool and model: Claude Code (Claude Opus 5.5): two sessions on this machine ran the queued runs; this one extracted the numbers from their logs and wrote this report. |
|
merge-check Regression runBoth from scripts/smoke.ps1 -Seconds 60, each from its own copy of one warm DXIL cache and its own data root, with main (1bd9cee): Found on the way (not this PR)
|
|
Test report: cold mandatory compute preparation, used-only set of a retail game, A/B on the same main (not a merge-check) Setup
Command, per side, the path
Results
My script counted The gain is larger on current main than on an older base. A first run against main Not tested
AI use: Claude Code (Claude Opus 5.5) wrote the A/B scripts, read the logs and wrote this report. The runs were done on the PC above. Posted at the user's request. |
|
Test report: cold mandatory compute preparation A/B on AMD (RX 6700 XT, RDNA2, Windows), a 40-record sample of a retail game (not a merge-check) Short version: no change at default settings, about half the compute driver time with Setup
Result (one run each)
Not tested
A question from reading the code (not measured): at default settings on AMD the runtime has no blob on disk, so AI use: Claude Code (Claude Fable 5.2) built both sides, ran the measurement, wrote this report and posted it from my account at my request. |
Keeps upstream's DXIL IR cuts (xcl-dev#3500-xcl-dev#3503/xcl-dev#3495-xcl-dev#3499: sampler waterfall, descriptor windows, split-wave64 mask exchange, per-lane exec, direct PS masks, quad shuffles, packed/normalized buffer decode, commit-aware compiles), xcl-dev#3269 fixed-point optimizer, xcl-dev#3154 compact compute prologue, xcl-dev#2123 split atomic add, xcl-dev#2070 offline 64 MB stacks, xcl-dev#3442 split-whole, xcl-dev#1319 root-constant bounds, xcl-dev#3356 late Reset releases, xcl-dev#1322 empty-BVH/NaN rays, xcl-dev#2753 3-D texture sizing, XMA/VFS/TLS/loader fixes. Resolutions: - real.rs: union of T-156 res_release pinning with upstream's InListReset and abi_rs_for_stages; dropped upstream's warm_graphics (T-095 removed that path); kept ComputeBuild::IndirectChain for our split-chain variant. - dispatch_chain.rs: kept our IndirectBuild split-chain architecture (the T-095 port removed the preload/whole-worker machinery upstream builds on); ported upstream's huge-PSO refusal log. - pso_async.rs: took upstream's commit-aware build_pieces/build_scoped and WORKER_STACK, removed the preload/backlog subsystem our port does not have (and its tests), kept our profile_is_series_s. - late_release.rs: took upstream's Dead enum, Busy/InListReset and hold_pipeline/hold_heap/hold_unmap, with our vram release path (no recycle pool). - emit.rs: upstream's additions moved into emit/memory.rs (ADD_TID_ENABLE), emit/exp.rs (misc-vector layer/viewport), emit/mimg.rs (SampleCmp with bias gradients), emit/valu.rs (abs/neg on shift/align), emit.rs out_struct. - bind.rs: root-constant bounds clamp + its test; kept our bool execute_indirect API. - bvh.rs: our grow/tri_ret/watertight model plus upstream's empty-root bounds and NaN-ray refusal. - kernel.rs: upstream's mask/waterfall/rodata cuts plus our lanes_upper. - shaders.rs: upstream's worker stack helpers and mesh/GS precompile paths, with our PipelineJob record identity. - eh.rs: upstream's CLWB TF guard + test, our termination test. - lower.rs test: 574bda4 makes wave32 SALU words compute S_WQM without quad lanes; assert that and keep the wave64 refusal.
xcl-dev#3442 (main) made startup preparation build only a split program's ABI whole when its driver blob is kept on disk, and tested it with a scratch cache_dir on an NVIDIA adapter, where the driver-blob cache is on. amd-dev's 0481ad6 gates the same function on whole_form_kept() (XCL_PSO_DISK_CACHE or XCL_PSO_LIBRARY), both off on AMD by default: there the title never takes the ABI whole, so preparation builds the pieces, and the chain-root wholes only for programs dispatched indirectly. The merge kept both, correctly: xcl-dev#3442's path when wholes are kept, amd-dev's otherwise. But xcl-dev#3442's test never set up the kept condition, so on AMD it took amd-dev's path and found the chain blobs. The test now forces the pipeline library on (its existing test hook; the driver-blob cache has none) for xcl-dev#3442's cases, and adds amd-dev's case without kept wholes, asserting the blobs it builds per indirect prewarm. That case is skipped where the driver-blob cache is on. No production code changes.

Startup preparation compiled every split compute program's whole DXIL twice, and its pieces, although the runtime only uses the first of those builds.
Why
Where a cold full preparation's compute driver work goes (retail game, RTX 2070 SUPER). All 2,730 compute translations of the title's direct-DXIL cache, banded by the size of the whole program's DXIL. Driver time is weighted as size^1.6, the exponent fitted to 1,340 cold compiles on this card (size^1.5 to size^1.7). On
main, startup preparation builds every split program three ways: whole (ABI root), every piece, and the whole again under the chain root.Script and data:
bands.pyover the translated cache, with the per-band results for size^1.5, ^1.6 and ^1.7; more context in #2088 (comment).The mandatory path (
Pipelines::prepare_compiled_compute:xcl run's startup preparation and its workers, also the PSO corpus and milestones) built, for every program that direct translation split into a dispatch chain:.pso),.chain.pso),.chain.pso).Since ec80c07 the runtime first loads the ABI whole blob (
CachedWholeintranslated_compute_pso_once). When that blob loads, it builds no chain, so 2. and 3. were never used. A chain's own whole is still built lazily by the runtime if a chain ever needs it. In a cold full preparation of a retail game, size-weighted, the chain-root wholes are ~40 % of the compute driver work and the pieces ~12 %: ~52 % in all (see Why below).Now the whole is built first, and the chain only when the runtime would not find the whole (
chain_needed): when the whole was refused or overXCL_PIPELINE_MAX_KB, or its driver blob is not on disk. In that case the pieces are built as before, and the record counts as prepared once they are. The chain-root whole is not tried then, because it is the same DXIL under another root and would fail the same way. The non-mandatory--pipelinespath (make_selected) is unchanged.What is in it
crates/xcl/src/shaders.rs:prepare_compiled_computebuilds the whole first;chain_neededmakes the decision;whole_blob_pathgives the blob path the runtime loads;a_split_programs_chain_is_prepared_only_without_its_whole(the decision);startup_preparation_builds_a_split_programs_whole_and_no_chain(GPU). With the whole kept, preparation writes exactly the whole.pso, for direct and indirect prewarm alike. With the whole over the cap, it writes exactly the pieces'.chain.pso.crates/xcl/tests/gpu_compute_e2e.rs:a_preparation_worker_also_builds_a_split_programs_whole_form(Shaders: a title's preparation workers build split programs' whole forms #2794) asserted the old behaviour, the worker's piece blobs besides the whole. It is replaced by @andrewDoing'sa_preparation_worker_keeps_a_split_programs_abi_whole, which:.pso;CachedWhole) is tested from a prepared blob.README.md: one sentence on what startup preparation builds for split programs.Tested
NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, Windows 11 Home build 26300, rustc 1.100.1, debug.
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on 3012206 (debug): 2739 passed, 0 failed, 49 ignored (41 test binaries).SKIPPEDon this adapter (28), the same kinds as on the earlier head: no wave64 (most of them), f16/f32 per-lane forms refused, no heap windows (opt-inXCL_HEAP_WINDOWS=1), no GPU_UPLOAD heaps.cargo test -p xcl --test gpu_compute_e2e -- --test-threads=1on 3012206: 9 passed, 0 failed, 0 ignored; 1 SKIPPED (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). @andrewDoing'sa_preparation_worker_keeps_a_split_programs_abi_wholepassed.cargo test -p xcl --lib shaders::pipeline_cap_tests:: -- --test-threads=1: 7 passed, 0 failed, 0 ignored, no SKIPPED.The new GPU test fails without the fix (main's
prepare_compiled_computebody put back). It finds the whole.pso, two piece.chain.psofiles and the chain-root whole.chain.pso, where it expects only the whole.pso.Cold mandatory preparation (
xcl shaders <pack> --precompile --only cs --pipelines --records <6 records>withXCL_PRECOMPILE_PARENTset, the pathxcl run's preparation workers take) of 6 records of a retail game, each side into a new, emptyXCL_DXIL_CACHE, release builds. Records: 5 split programs (each a ~1.39 MB whole and 18 pieces) and 1 unsplit program as a control..pso, 95.chain.pso.pso, 0.chain.psoOn main, each split program got the whole, 18 pieces and the whole again (5 × 19 = 95
.chain.pso). Here each record gets one.pso. The wall times are not cold times: the NVIDIA driver's own shader cache was on and already held these programs from an earlier full preparation (6 wholes in 60 s is well under 6 × ~34 s cold). The claim rests on the counts (101 → 6 driver builds, 33.1 → 11.2 MB of blobs) and on the cold cost of an avoided whole below.What one avoided chain-root whole costs, measured on main with the driver's shader caches turned off (
xcl shaders --measure-pso 2e1d03fbed9d95eb --repeat 1,ShaderCacheControl, one compile at a time): 33.9 s for a 1,387,508-byte whole. Under 12-way preparation, the pieces plus the chain-root whole finished a median of 428 s after the ABI whole, for programs of ≥ 1 MiB.Regression run
main (0fe06eb):
this PR's head (3012206):
Both:
scripts/smoke.ps1 -Seconds 60,XCL_PREPARE=0,XCL_PRESS_AT=25:A, release builds, run through the local exclusive queue. With preparation off, these runs check that nothing else breaks; they do not run the changed preparation path.Note: #3219 (test-only) asserts the old set of files that preparation writes. Whichever of the two merges second needs its test updated.
Not tested
XCL_PREPARE=0), and a warmxcl runafter a full preparation, which would showcompute split: 0 programs splitfor the prepared records. A full preparation takes hours here.AI use
shaders.rs, and this description. The investigation that found the double build was Claude Code, Claude Opus 5.5 as well.a_preparation_worker_keeps_a_split_programs_abi_whole: written by @andrewDoing with OpenAI Codex (GPT-6.2 Sol). Taken in unchanged and co-authored in the commit.🤖 Generated with Claude Code