xcl run: shader preparation in worker processes, only what earlier runs used; upstream main; sampler fix #2614
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2624"
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?
Imported from ivall/xcl. Originally posted by theaustinayers on 2026-11-26T02:56:41Z.
Brings
nvidia-devup to upstream main (through #2371) and adds the faster shader preparation before a title starts.What is in it
b49be183, includes #2338, #174, #2371), with the fork's fixes kept.crates/xcl/src/shaders.rs): the stages are translated in the host; a pack's compute pipelines are built by worker processes, each on its own slice of the records. The driver builds about two pipelines at a time for one process, so one process stood for minutes on each stretch of large compute programs. Workers: logical processors less four, 3 GB of free commit each (XCL_PREPARE_WORKERS;1= one process as before). A worker that fails is logged and the title starts; a worker ends when the host does.shaders.rs,hle/d3d12x/pso_async.rs): a run keeps the shaders of the pipelines it uses inused-shaders.txtbeside the DXIL cache. With that list the preparation translates only those records, and the pipeline pass builds only the compute pipelines an earlier run used.XCL_PREPARE_ALL=1prepares every record.XCL_PREPARE=0skips preparation: the title builds what it uses as it goes.hle/d3d12x/present/preparation.rs): each pass has its own heading and count, a worker reports every record, the host logs progress every 5 s.gpu/recomp/mod.rs): an S# set before a branch or a loop is recognised as a static sampler after it. Before, those samples went through sampler-heap entry 0 (point, wrap, mip 0): banded gradients, stepped glows.XCL_ZERO_SAMPLER_LINEAR=1is a diagnostic for that entry.XCL_WAVE64_SPIN=1restores the counters).Tested
cargo test --release -p xcl --lib -- --test-threads=4atfbfac4d0: 1538 passed, 0 failed, 25 ignored; 59 tests that open the hardware GPU not run. The four tests added after it (the_shaders_of_a_used_set_are_kept_for_the_next_run,the_key_of_one_shader_is_the_key_of_a_set_of_it,preparation_workers_leave_two_processors_and_follow_the_commit_left,static_sampler_set_before_a_branch_is_a_constant_after_it) pass at the head.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by GodlyBDS on 2026-11-26T03:29:37Z.
RTX 3090 Ti / 621.40 / Windows 10 / 32 GiB follow-up on
e877812e. I used two local startup compatibility changes already tested on the older NVIDIA branch (Agility host-path scope and the XG extra argument), and the same per-executable 1 GiB shader heap reserve. The release build and six focused startup tests passed. This arm uses on-demand compilation (XCL_PREPARE=0, background PSO preload off) and starts from 8,426 prior native entries. The translated cache is regenerated so that the refreshed shader paths use their current outputs.The independent timing of PSO worker gate waits is in #2628. AI use: OpenAI Codex (GPT-6) ran the comparison and drafted the report.
Long-run update. One recording thread completed 37 large, cache-missing compute PSO builds in sequence between 773.010 and 1,443.620 s. Their logged driver durations total 670.124 s of that 670.610 s interval. The runtime stack samples caught the thread in
nvgpucomp64.dll. There were no Presents in that interval and the run remained active. The verified seed held 8,426 native entries and the live cache had 10,565 files at this sample. The foreground sequence is separate from the worker-gate pressure described on #2628. This supports warming the demanded native PSOs on this GPU. It does not show that precompilation resolves the full world transition.Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-26T04:02:09Z.
Blocker for 16 GiB / capped Wine hosts (source-verified at exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6): the default worker budget has a byte/MB mismatch.crates/xcl/src/host.rs:13-22documents and returnssystem_commit()total/limit in bytes (K32GetPerformanceInfo× PageSize).crates/xcl/src/shaders.rs:1683-1694forwardslimit.saturating_sub(used)unchanged toworkers_for(cores, free_mb), which divides by 3072 assuming its input is MiB. On this laptopnproc=16; for an illustrative 6 GiB free commit, the intended three-GiB-per-worker rule is 2 workers, but the head's expression selects 12 (all 16-4 allowed CPU slots). Under the local 9 GiB Wine cgroup and 16 GiB physical RAM, this can trigger the external 2 GiB MemAvailable guard or an OOM before the title starts.XCL_PREPARE_WORKERS=1avoids this risky default for local trials, not a shipping fix. Please make the argument explicitly bytes and divide by3 * 1024 * 1024 * 1024(or convert bytes to MiB before calling), add a regression with 6 GiB in bytes, and respect a smaller applicable process/cgroup memory limit if the application is launched within one; global commit alone does not enforce a 9 GiB scope cap.I attempted the focused Windows-MSVC Wine test
preparation_workers_leave_two_processors_and_follow_the_commit_left, but the head does not reach the test on this build setup: transitivewindows-future 0.3.2fails compilation againstwindows-core 0.62.2/windows-threading(IMarshal,marshaler,submitmissing), exit 101. Local log.compat-xcl/logs/verify-pr2624-wine-worker-budget.log. The existing syntheticworkers_forcases pass fake numbers labeled MB and would not catch the bytes passed from the real caller. No worker processes or retail title were launched; the source-level unit mismatch is independent of the dependency build failure. Machine: RTX 4060 Laptop 8 GiB, Wine 11.0, 16 GiB host RAM.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T04:50:56Z.
Review: COMMENTED
With
XCL_PREPARE_WORKERS=2,XCL_ADAPTERunset, and a title config such asd3d12_adapter = "1"on a two-GPU host, the parent capturesprogress.adapterbut this childCommanddoes not pass it on. Each worker enters the CLIshaders --precompilepath withstartup=None, soPipelines::for_adapter("auto")selects the default adapter; the title runtime still selects adapter 1. That means the workers can warm driver PSOs for the wrong device, and matching-DXIL cache entries can later be rejected and rebuilt on the title's adapter. Could the spawn pass the resolved adapter to children (for example viaXCL_ADAPTERonly when no explicit environment override exists) and test the config-only secondary-adapter case? This is source review; I did not run a two-GPU preparation test, and this point concerns the worker pipeline path rather than all translation-only preparation.Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-26T05:13:08Z.
Independent NVIDIA test report on exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6(clean detached checkout, no local changes), compared againstnvidia-dev(c044dc6d).Tested
32.0.16.2140/ 621.40), AMD Ryzen 5 5500 (6c/12t), 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4(debug):nvidia-dev(c044dc6d): 1560 passed, 6 failed, 47 ignored (xcl --lib: 1490 passed, 2 failed, 27 ignored), 28SKIPPED.#2624(82e4a9bb): 1721 passed, 6 failed, 48 ignored (xcl --lib: 1594 passed, 2 failed, 28 ignored), 28SKIPPED.nvidia-dev(+161 passing tests). All 6 failures matchnvidia-dev:hle::d3d12x::texture_upload::tests::{gpu_parts_of_a_texture_go_up_and_the_rest_stays, pieces_hold_the_texels_of_their_levels}(texture_upload.rs:990:17:attempt to multiply with overflowin debug)d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(expected AS-slot refusal in translation_errors: ["MS: no NGG hardware variant"])gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standingpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(both test runs fail withdisabled:)SKIPPEDGPU tests on this adapter: 21 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1no heap windows, 1no heap windows (opt-in: XCL_HEAP_WINDOWS=1), 1 no D3D12 debug layer (0x887A002D), 1 cannot disable driver cache without Developer Mode (0x887A002D).used-shaders.txt= 11 shaders from the priorXCL_PREPARE=0run):0 of 8 workers failed), checked 26,503 records and finished compute pipeline preparation in 6 s (total_elapsed_s=72.5including the 60 s run), presentation window worked cleanly.Regression run
scripts/smoke.ps1 -Seconds 60, release builds ofnvidia-dev(c044dc6d) and#2624(82e4a9bb):nvidia-dev (
c044dc6d):PR (
XCL_PREPARE=0):PR (with worker preparation over
used-shaders.txt, 8 workers, 6 s prep):Not tested
XCL_PREPARE_ALL=1full-pack compute precompile pass; AMD / Intel / Linux GPUs;XCL_SAMPLE_*tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world.AI use
smoke.ps1commands on this machine and drafted this report from the captured outputs.Imported from ivall/xcl. Originally posted by itsSio on 2026-11-26T05:29:30Z.
Dual-PC NVIDIA full-workspace test run (debug) and RTX 5080 retail smoke (release) at exact head
82e4a9bbf3be583418b9df7825dd1430fd8b06d6, covering the full suite, hardware-GPU tests, integration tests, and non-5090 NVIDIA hardware listed under Not tested.Tested
82e4a9bbf3be583418b9df7825dd1430fd8b06d6(basenvidia-dev), clean checkouts on both PCs,XCL_ADAPTER=NVIDIA,cargo build --workspacebefore runningcargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture.32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build.1594 passed, 2 failed, 28 ignored; raw lines also print 3 single-test child reruns and a duplicategpu_two_pass_cacheprint, excluded from totals).SKIPPED: 27 lines (no-wave64 group, 3 refused wave32 per-lane f16 forms, no heap windows).32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build.1594 passed, 2 failed, 28 ignored).SKIPPED: 30 lines (18 distinct tests: PC 1 skips pluspso_measurement_compiles_an_exact_synthetic_record,uploads_start_from_each_subresources_state, and 2lower::wave64 tests).#2624tests pass on both PCs:the_shaders_of_a_used_set_are_kept_for_the_next_run,the_key_of_one_shader_is_the_key_of_a_set_of_it,preparation_workers_leave_two_processors_and_follow_the_commit_left,static_sampler_set_before_a_branch_is_a_constant_after_it.nvidia-dev, reproduced on both PCs):texture_upload::tests::pieces_hold_the_texels_of_their_levels&gpu_parts_of_a_texture_go_up_and_the_rest_stays(texture_upload.rs:990:17, debug multiply overflow in test LCG).d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly(:96, expected AS-slot refusal, got["MS: no NGG hardware variant"]).gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standin(:535,TRANSLATED_COMPUTEcleanup vslate_release).gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(:649, two-pass state releaseleft 3, right 0vslate_release).e2e::test_title_runs_and_game_folder_is_untouched,e2e.rs:168):NVIDIA Corporation\andNVIDIA Corporation\umdlogs\directories.#2624(82e4a9bb) failed 4/4 runs;nvidia-dev(c044dc6d) passed 3/3 runs (where the VFS redirects those driver writes to the overlay because D3D12 init happens after VFS install, whereaspreparation::before_guestopens D3D12 before VFS install while cwd is the game root). Passing on PC 2 (RTX 2080 SUPER does not createumdlogs).XCL_PREPARE=0,XCL_DXC_DIR= DXC1.9.2609.5):Not tested
XCL_PREPARE=1) andused-shaders.txtreuse on a retail title, visual verification of the static sampler fix in 3D world rendering, AMD / Intel GPUs, and retail smoke on the RTX 2080 SUPER.AI use
Ran via Samaritan:
e2eA/B check againstc044dc6d, and the release build, and traced thebefore_guestcwd vs VFS ordering behind theumdlogsfailure.Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T06:20:05Z.
+1 to @pickles976's byte/MB finding above (7182236787). I didn't see it before posting, sorry for the repeat. One new data point: it is still there at the current
nvidia-devheadaf2cecc4(shaders.rs:1727passessystem_commit()bytes toworkers_for, which divides by 3072). So on a 16-thread CPU the default is still 12 workers, whatever commit is free. We'll setXCL_PREPARE_WORKERSexplicitly when we run the branch.AI use: Claude Code (Claude Opus 5.5) checked the source at
af2cecc4and wrote this.Imported from ivall/xcl. Originally posted by pr1sm-dev on 2026-11-26T06:27:38Z.
@pickles976 confirmed by reading the current
nvidia-devheadaf2cecc:prepare_workers(crates/xcl/src/shaders.rs:1727-1728) still passeshost::system_commit(), which is in bytes (host.rs:11-12), toworkers_for(cores, free_mb), which divides by 3072 as MiB (shaders.rs:1732-1733). So the commit bound never applies, and the count is always the logical processors less four (capped at 32).I'm taking the fix, as a small PR against
nvidia-dev: convert at the call site, leaveworkers_forand its tests as they are, and add a regression test with byte values (6 GiB free on 16 threads → 2 workers). A process or cgroup memory cap that the commit figures do not show stays out of scope; I'll say so in the PR.AI use: Claude Code (Claude Opus 5.5) read the source and wrote this comment.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T08:53:17Z.
nvidia-devaf2cecc4, all cold, RTX 5090. Preparation works and removes the graphics stall on a relaunch. The wall left is about 20 split programs' whole forms, which the worker processes do not build.RTX 5090 (621.24), Ryzen 7 9800X3D (16 threads), Windows 11, release,
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1 XCL_NETWORK=0,XCL_PREPARE_WORKERS=6(set by hand, see the byte/MB note above), 600 s of title time, the retail title. Each arm used a fresh exe name (empty NVIDIA cache) and a freshXCL_DXIL_CACHE. One run per arm:mainb49be18.used-shaders.txt,used-pipelines.txtandused-graphics-pipelines.bin.None of the three reached the world in 600 s. Each one sat on the world loading screen from about +110 s, while large compute pipelines kept compiling.
Where N2's time went. Joining
driver compile start/finishwith the binds:used-pipelines.txt, and Pass 2 had built their pieces.The reason is in
shaders.rs(af2cecc4, around line 2172):p.make_one(&c.dxil, …, true, None)for a program with adispatch_chainruns onlyif startup.is_some(). Pass 2's workers runprecompilewithstartup = None, so they build the pieces but never the whole form. Building it whenXCL_PRECOMPILE_PARENTis set too (or passing a flag to the workers) looks like it would take most of that remaining wait into preparation.Not tested: the default worker count; more than one run per arm; whether the title reaches the world with whole forms prepared; AMD.
nvidia-devis the whole branch, so M vs N differences are not only #2624's.AI use: Claude Code (Claude Opus 5.5) ran the three arms. Gemini (Antigravity) joined the trace lines and found the
startupgate. Claude Code checked the gate in the source and wrote this.Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-26T09:32:54Z.
Confirming @KDenKC's finding about the preparation's
startupgate on an RTX 4070 Ti 12 GB (af2cecc4, shader heap at 1 GiB withxcl nvprofile).Chain::wholebuilding whole forms cold, 15–25 s each, 750 KB – 1.1 MB of DXIL (symbolized thread dumps at 180 and 300 s).startup.is_some() || std::env::var_os("XCL_PRECOMPILE_PARENT").is_some()in the compute branch ofprecompile. The first preparation with it took 754 s (12 workers, 0 failed). On the next launch it took 17 s, and the title went through the load with no freeze and no removal to the 438 s cap.One run per arm, so take it as an indication. The 754 s is a one-time cost per cache. (Claude Code, Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T10:28:23Z.
Follow-up to 7187143204: with the preparation workers also building whole forms, the compute wall moves into preparation, and the title loads further before the next wall: graphics pipelines no earlier run reached.
Same setup as N2 there (RTX 5090,
af2cecc4, a fresh exe name, a cache holding only N1's threeused-*files,XCL_PREPARE_WORKERS=6, 600 s). One local change, a suggestion rather than a PR from us:We also added a worker variant of the
gpu_compute_e2eoffline split-pipeline test (a worker must leave the whole form's blob for a second process). It failed without the change and passed with it.used-pipelines.txtused-graphics-pipelines.bin(N1 never got that far). The gap before each one was ~5 ms, so translation was warm and the time is the driver's compile.Not tested: that N4; more than one run; the default worker count; AMD.
AI use: Codex (GPT-6.1-Sol) wrote the change and its test. Claude Code (Claude Opus 5.5) ran the arm. Gemini (Antigravity) compared N2 and N3 in the traces. Claude Code checked the numbers and wrote this.
Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-26T13:35:05Z.
@KDenKC, since you posted the gate change as a suggestion rather than a PR, I opened it as #2794 against
nvidia-dev, with your numbers credited. It adds a worker variant of the offline split-pipeline e2e test: one more pipeline than pieces, each with a driver blob, and the test fails without the change. If you'd rather open your own with your worker test, say so and I'll close mine. (Claude Code, Claude Opus 5.5)Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-26T13:43:42Z.
@joeypercia thanks, please keep #2794. We posted it as a suggestion so that someone could open it. Your worker variant of the e2e test is the same check we ran (one more blob than pieces; it fails without the change).
AI use: Claude Code (Claude Opus 5.5) wrote this.
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-26T19:39:12Z.
Edit: this was already reported by @pickles976 above (https://github.com/xcl-dev/xcl/pull/2624#issuecomment-7182236787) and is fixed by #2705, which makes the same change. I missed both; my Mac test of the fix is on #2705. The rest of this comment stays as written for the measurements.
The preparation worker count never applies its 3 GB-per-worker limit:
prepare_workerspasses the commit left in bytes toworkers_for, which takes MB.On
nvidia-dev(eae01502),crates/xcl/src/shaders.rs:free_mb / 3072is then in the millions, so the count is always the logical processors less four (capped at 32), whatever memory is left. On a 32-thread machine with 20 GB of commit left that is 28 workers where the rule gives 6.Measured on my Mac (M5 Pro, 18 logical processors, 48 GB RAM + 6 GB swap, CrossOver 26.3 + D3DMetal): the host read 21,051 MB of commit left of a 55,296 MB limit and started 14 workers. With the fix it starts 6 or 7, depending on the memory left at that moment.
Fix (one helper and a test,
d4f8569on my fork):The test fails without the shift (left 14, right 7) and passes with it.
Tested (macOS, CrossOver, not Windows): the shader-preparation commits from this PR and #2555 plus this fix, on top of
main6d12f58and the Mac fixes, asmac/integration. Whole suite one test per process: no change on the 1,516 tests in common with the base, and the new tests pass. Test title 50/50 with exit 0, with and without a synthetic compute pack; workers start, build, exit, and end with the host.XCL_PREPARE_WORKERS=1keeps the single-process path.Not tested: Windows, a retail title, a large pack (for the speed-up).
Two smaller things I noticed, not changed:
XCL_PREPARE_ALL=1and aused-pipelines.txtpresent, the host takes every record but the workers still get--used-only, becausepipelines_in_workersonly looks at the used list.used-shaders.txtandused-pipelines.txtlive in the shared DXIL cache folder, so one title's run (or a test run) changes what the next title prepares.AI use: Claude Code with Claude Opus 5.5 found the bug while porting these commits, wrote the fix and test, ran the tests on my machine and drafted this comment. I checked it before posting.