Repository navigation
Shaders: speed up translated pipeline compiles and add PSO measurements - #1524
Conversation
|
Verdict from the DXC/PSO lane — this is potentially the most watchdog-relevant PR of the wave, and it is currently unreviewable on purpose: the template body is empty, and for a perf PR the numbers are the whole argument. What #534 proved tonight is that cold-translation time during loads is a direct watchdog input (warm cache + preload cleared load 1; cache misses in load 2 got killed), so "build 64 pipelines at once with a serial lane for ≥ 4 MiB giants" is precisely the right shape of fix — but the thread needs: ① the |
Runtime-indexed uint4 values became local arrays in DXIL and made large NVIDIA pipeline compiles substantially slower. Select components explicitly in format helpers and BVH barycentric selection instead.\n\nOn a 579 KB translated compute program this removed 101 local arrays; five cache-disabled driver runs improved from a 24.2 s median to 18.6 s. GPU tests cover packed formats, all four 32-bit components, selectors 0/1/4/7, stores, and BVH intersections.\n\nAssisted-by: OpenAI Codex (GPT-5)
Large driver compiles contend for CPU and commit when background PSO workers enter the driver together. Gate translated pipelines above a configurable DXIL threshold while allowing small and title-waited work through. Use actual shader bytecode sizes, gate cold retries after rejected cache blobs, keep a conservative one-wide default, and put 4 MiB pipelines in a separate lane so they cannot starve ordinary large work. Assisted-by: OpenAI Codex (GPT-5)
Make compile-time investigations reproducible by selecting a console record by hash, exporting its HLSL deterministically, and timing only cache-disabled driver PSO creation with the runtime root signature and samplers. Assisted-by: OpenAI Codex (GPT-5)
71940c5 to
3a06645
Compare
Large driver compiles now log a numbered start and finish line, with the translated program's hash and whether a driver blob was supplied for compute pipelines, so a slow compile seen in a title log can be matched to the record that --measure-pso exports and times. XCL_PSO_TRACE=1 logs every driver compile, not only large ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed Commit 1 (
|
|
Status update (head
@pickles976, on your review: the description was filled in before your comment, and some of what you describe is not in this PR. It has no 64-wide build and no change to the translation-cache keys (the memory-window/heap-window work was left out). To your points:
|
|
Test report on AMD (RDNA2, Windows driver) for 3a06645, unmodified. This PR's Not tested lists AMD. These are the cache-off before/after numbers @gsucristo asked for to justify commit 1 (DXIL size and cold compile time on a few large compute shaders), and part ① of @pickles976's ask. The head has moved to ee7f2f3 since. Its two new commits only add PSO log lines in Short version: on this driver, Tested
Not tested
AI use
|
|
RodrigoTorreao's numbers settle my measurement ask — and they deserve the arithmetic stated out loud, because this is the watchdog case in miniature: one ray-tracing compute pipeline taking 230 s cold is, by itself, larger than the entire observed watchdog budget band on cold runs (5 min deaths ≈ 300 s). A single helper pattern — dynamic vector indices in the format/BVH helpers — converting 230 s to 63 s is the strongest proof yet that cold translation latency is a real modulator of which runs die early, even though the fully-precompiled run (24,699 programs, xcl#662) proved latency is not the primary gate. Consequences for the queue: ① commit 1 is justified on AMD data even though the PR description said "Not tested: AMD" — third-party measurement is the right way to fix that label, and ② if RT compute pipelines are entered during world entry (they are for this title's ray grid), this one 230 s stall sits exactly where the watchdog fires — worth the author's confirmation of the phase these builds land in, because if they land inside the blocked window, the fix order changes: commit 1 before the cache work, not after. My policy-version-in-cache-key note stands regardless (it protects the 63 s from silently regressing to 230 s on a driver update). |
|
Tested PR #1524 at head Tested
Findings on
Not tested
AI use
|
|
@pickles976 on the phase question (18:21Z): on this machine, the ray-tracing builds were not inside the blocked window of a cold first world load. This is a cold watchdog A/B of Setup
Not tested
AI use
|
Conflicts: pso.rs keeps both console_hlsl (for --export-hlsl) and main's direct DXIL routing/XCL_DXIL_DUMP; console_translation stays pub(crate) for --measure-pso. main.rs usage lists both --export-hlsl/ --measure-pso and --direct. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes on the huge-pipeline gate and its log lines (PR 1524): - the start line names the console record by fnv64 of its shader container (`record HASH`), the hash --measure-pso and --export-hlsl --record-hash take; it was a DefaultHasher key over the DXIL, which no tool can look up (MatyEjsr, RodrigoTorreao) - XCL_PSO_TRACE=1 no longer calls small compiles "huge, ungated here"; the setting is read once - driver_cache::keep and the compute PSO log get the time spent in the driver alone, not the wait for a slot, so a fast compile that queued is not kept as a slow one (gsucristo) - the mesh pass of a two-pass pipeline logs its own shader bytes, not those plus the compute pass's; StreamOut counts shader bytes as subobjects are written instead of re-parsing (no silent 0) - tests: the bypass test holds both lanes and uses sizes relative to XCL_HUGE_PSO_BYTES (no deadlock with a small threshold); the concurrency test meets on a barrier instead of a sleep - README: the giant lane can run next to the ordinary slot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- measure_pso releases its root signature on every path, checks DXC and turns the driver caches off before translating, and its GPU test skips (instead of failing) without DXC, a usable device or cache control (Developer Mode) - --export-hlsl skips non-compute records silently unless one is asked for by --record-hash; a requested record's failure stops the scan - a single shader file is an input for --export-hlsl / --measure-pso instead of being summarised and returning - both use heap windows with XCL_HEAP_WINDOWS=1, as --precompile - --export-hlsl, --record-hash and --measure-pso without a value (or with another flag in its place) are errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report and review of Tested
Issues found (each checked in the code at
Several of these overlap with gsucristo's review above (2, 3, the peak-commit concern). I agree with the request to split: commit 1 can land on its own now; the compile lanes need 1–4 fixed; the export/measure tool is a separate PR. Not tested
Edited: added the full suite run. AI use
|
|
Test report — RTX 3060 Ti (Windows 11), branch merged with current
0x887A002D = DXGI_ERROR_SDK_COMPONENT_MISSING — this driver/D3D12 runtime doesn't support disabling the shader cache. The new test hard-requires that call to succeed, so it fails on hardware where the feature is absent; it probably needs the same |
|
For anyone measuring this PR's pipeline times: a cold compile needs all three cache layers off or cleared. Otherwise a repeat run reuses earlier work and the numbers look far better than a first launch. 1. XCL's own caches (environment variables for the run):
2. The GPU driver's shader cache:
3. Windows' DirectX shader cache:
Please say in your report which of these you turned off. A "cold" number with any layer still warm isn't comparable, and a warm driver cache explains most 1 ms PSO times. AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask. |
|
Update, head Thanks @MatyEjsr, @RodrigoTorreao and @gsucristo for the reviews and measurements. Fixes in
@gsucristo (724b9e2 / 3a06645)
Performance, stated as measured (all from @RodrigoTorreao, RX 6750 XT; I have not repeated these on NVIDIA):
@pickles976: given that A/B, I'm not claiming this PR moves the first-load watchdog. On that load, the builds in flight are mid-size non-RT compute that commit 1 doesn't change. Whether RT builds land in a later load's blocked window is untested; nothing reached a second load. The ray-tracing cost reduction stands on its own. On cache scoping: Full suite on RTX 4090 at 4143a09: 870 passed, 0 failed, 42 ignored (SKIPPED: 2 no wave64, 1 no heap windows). @MatyEjsr, a re-check of the log line, and @RodrigoTorreao, a |
|
Independent AMD check of the log-to-CLI workflow at Tested
Not tested Cache-disabled timings with Developer Mode on, retail records or title smoke, or other adapters. AI use OpenAI Codex (GPT-6 family, exact variant unavailable) ran the tests and CLI checks, verified the artifacts, and drafted this report. |
|
Tested PR head Tested
Not tested
|
|
NVIDIA data point for the merged lanes, from a retail run (not Driver compile times from the
For comparison, our earlier run of the same title on an older tree had single driver compiles of 88.5 s and 113.3 s at world load. No device removal; the run ended in the title's watchdog ( AI use: Claude Code (Claude Opus 5.5) ran the box, computed the table from the log and wrote this note. |
…pub(crate) Fixes compilation errors on MSVC Windows target: - D3D12.X: restores pub(crate) unsafe fn create_raw_fence in real.rs required by sparse::readback_after_execute (xcl-dev#1732). Creates an unproxied raw ID3D12Fence bypassing title vtable hooks so internal queue worker threads under Wine/vkd3d-proton signal native fences without hitting proxy mismatches. - KernelX: restores pub(crate) visibility for commit_sparse in kernelx.rs (xcl-dev#549, xcl-dev#1298), required by DirectStorage's lazy MEM_RESERVE sparse window allocation in dstorage.rs and placeholder mappings. - Recompiler: adds #[cfg(test)] gate above mod tests in emit.rs to silence unused PRELUDE_MEM import warnings in non-test release builds (xcl-dev#1524). Assisted-by: Antigravity
…driver gave up callback Eliminates compiler warnings for unused items: - D3D12.X: removes rb_fence and rb_value from sparse::State and test fixtures (xcl-dev#1732). Readback fences are now managed per-queue in RB_QUEUES by async readback workers, making the fields on State obsolete. - D3D12.X: hooks note_driver_gave_up in real::translated_compute_pso_once when driver_compile_identified returns E_OUTOFMEMORY after DRIVER_GAVE_UP_AFTER (xcl-dev#1665, xcl-dev#1524), ensuring failed massive compute pipelines are persisted in used-pipelines.txt (!<key>) and eliminating dead code warnings. Assisted-by: Antigravity
|
@vladbondarenko97 thanks for the NVIDIA retail-run distribution (1,494 driver compiles; the ≥ 512 KB bucket at a 12.4 s median, 46.0 s max, against 88.5 s / 113.3 s single compiles on the older tree). Agreed that it's not a controlled A/B, and that the watchdog about 30 s after the last present looks tied to the sparse-queue stall (#433), not to compile time. AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask. |
…xcl-dev#819) Conflicts: - real.rs driver-compile gate: upstream's XCL_HUGE_PSO_BYTES / _CONCURRENCY, Slots::most() and GIANT lane (4 MiB) taken; integ's HUGE lane is the same 4 MiB lane (big_compile_lane now names compile_slots' lanes). BIG_DRIVER_COMPILE -> huge_pso_bytes() (also in warm). Compute PSO: integ's lane / slotless / pso_async hooks kept, then the driver call through driver_compile_identified (gated by its caller) for upstream's log lines and driver-only time; the cold retry gated as upstream. Graphics: integ's dxil_known, then upstream's gated driver_compile. pso_async::build_is_wanted is no longer test-only (upstream's gates use it). The two tests that take both real lanes hold BOTH_LANES (opposite orders). - shaders.rs: runtime_windows() with integ's --used; both sides' helpers and tests kept. - pso.rs: compute_shape and console_hlsl both kept. - README: both sides' lines kept. Assisted-by: omp (Claude Opus 5.5)
The huge-pipeline gate (xcl-dev#1524) let a compile on an xcl-pso worker start with 3 GB of commit free, whatever the program's size. The driver's compiler takes memory in proportion to the program: ~1.5 GB for a 1 MB one (NVIDIA), and an AMD driver took a process from 34 to 42 GB of commit on a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321). With the giant lane next to the ordinary ones that compile started at 4 s, in the background, while the title's world loading took its own 25 GB: on 32 GB of RAM the process ran into the machine's commit limit at 28 - 34 s, twice with XCL_HUGE_PSO_CONCURRENCY=4 and once with the defaults (a title thread's page could not be committed). big_compile_commit_needed(bytes) is 3 GB plus 1 GB for every 2 MB of DXIL, and big_compile_may_start also refuses a background compile that would take more than a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before): such a program waits for a bind that wants it (the gate's existing way out) and is built then, as a title thread would, and the log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. A graphics bind resolves without waiting and did not mark the pipeline wanted, so a graphics program the share holds back would have stayed a stand-in, its worker in the gate: `resolve` now calls `want()` too (found, with the test a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in review). Measured on an RX 7800 XT, 32 GB: with the rule the same runs end at 600 s, the 13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak commit goes from 84 GB (main) to 27 GB. Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The huge-pipeline gate (xcl-dev#1524, headroom by size since xcl-dev#1774) lets a compile on an xcl-pso worker start when its commit headroom is free. That reading at the start of a compile says nothing about what the title takes next: a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321) started at 4 s in the background with 36 GB of commit free - its headroom is 7 GB - and, with the title's own 25 GB of world loading after it, the AMD driver's ~15 GB for that compile ran the process into the machine's commit limit at 28 - 34 s on 32 GB of RAM, three times (twice with XCL_HUGE_PSO_CONCURRENCY=4, once with the defaults: a title thread's page could not be committed). A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before) and within the RAM available now (under Wine the commit reading is the memory available plus the free swap and never falls, as Royalflamejlh measured in review). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, as a title thread would, and the log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. A graphics bind resolves without waiting and did not mark its pipeline wanted, so a graphics program the share holds back would have stayed a stand-in with its worker in the gate: `resolve` now calls `want()` too (found, with the test a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in review). Measured on an RX 7800 XT, 32 GB: with the share the same runs end at 600 s, the 13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak commit goes from 84 GB (main) to 27 GB. Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The huge-pipeline gate (xcl-dev#1524, headroom by size since xcl-dev#1774) lets a compile on an xcl-pso worker start when its commit headroom is free. That reading at the start of a compile says nothing about what the title takes next: a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321) started at 4 s in the background with 36 GB of commit free - its headroom is 7 GB - and, with the title's own 25 GB of world loading after it, the AMD driver's ~15 GB for that compile ran the process into the machine's commit limit at 28 - 34 s on 32 GB of RAM, three times (twice with XCL_HUGE_PSO_CONCURRENCY=4, once with the defaults: a title thread's page could not be committed). A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before) and within the RAM available now (under Wine the commit reading is the memory available plus the free swap and never falls, as Royalflamejlh measured in review). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, as a title thread would, and the log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. A graphics bind resolves without waiting and did not mark its pipeline wanted, so a graphics program the share holds back would have stayed a stand-in with its worker in the gate: `resolve` now calls `want()` too (found, with the test a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in review). Every start read the same commit free, which the gated compiles already running had not taken yet, so with XCL_HUGE_PSO_CONCURRENCY=8 on an RTX 4090 with 47 GB of RAM (52.4 GB commit limit) 0.76 - 1.06 MB compiles started four at a time, each "gated (waited 0 ms)", while the system's free commit went 3.8 -> 1.8 -> 0.9 GB and the process 32.8 -> 42.4 GB (found by @S1m0ne1997 on the PR). What the background compiles in flight take is now kept in a running total: it is taken off the commit free and added to what the next one takes for the RAM share and the RAM available. Wanted builds skip that check and are not counted. Measured on an RX 7800 XT, 32 GB: with the share the same runs end at 600 s, the 13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak commit goes from 84 GB (main) to 27 GB. Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The huge-pipeline gate (xcl-dev#1524, headroom by size since xcl-dev#1774) lets a compile on an xcl-pso worker start when its commit headroom is free. That reading at the start of a compile says nothing about what the title takes next: a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321) started at 4 s in the background with 36 GB of commit free - its headroom is 7 GB - and, with the title's own 25 GB of world loading after it, the AMD driver's ~15 GB for that compile ran the process into the machine's commit limit at 28 - 34 s on 32 GB of RAM, three times (twice with XCL_HUGE_PSO_CONCURRENCY=4, once with the defaults: a title thread's page could not be committed). A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before) and within the RAM available now (under Wine the commit reading is the memory available plus the free swap and never falls, as Royalflamejlh measured in review). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, as a title thread would, and the log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. A graphics bind resolves without waiting and did not mark its pipeline wanted, so a graphics program the share holds back would have stayed a stand-in with its worker in the gate: `resolve` now calls `want()` too (found, with the test a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in review). Every start read the same commit free, which the gated compiles already running had not taken yet, so with XCL_HUGE_PSO_CONCURRENCY=8 on an RTX 4090 with 47 GB of RAM (52.4 GB commit limit) 0.76 - 1.06 MB compiles started four at a time, each "gated (waited 0 ms)", while the system's free commit went 3.8 -> 1.8 -> 0.9 GB and the process 32.8 -> 42.4 GB (found by @S1m0ne1997 on the PR). What the background compiles in flight take is now kept in a running total: it is taken off the commit free and added to what the next one takes for the RAM share and the RAM available. Wanted builds skip that check and are not counted. Measured on an RX 7800 XT, 32 GB: with the share the same runs end at 600 s, the 13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak commit goes from 84 GB (main) to 27 GB. Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Large translated pipelines can spend substantial CPU time and commit inside the driver compiler. Runtime-indexed vectors also inflate generated DXIL, while unconstrained background compiles compete with each other. This PR:
What is in it
Recompiler: avoid dynamic vector indices in format helperschanges the generated HLSL helpers and extends typed-format GPU coverage.D3D12.X: limit concurrent huge pipeline compilesadds size-based background compile lanes, cache-retry handling, logging, tests, and documented environment controls. Pipelines of 4 MiB or more get their own one-wide lane, which can run next to the ordinary slot. Every gated compile still needs 3 GB of commit free.Shaders: export and measure exact compute pipelinesadds strict record-hash selection, deterministic HLSL export, cache-disabled driver timing, tests, and CLI documentation.D3D12.X: identify driver compiles in the PSO logandREADME: …add numbereddriver compile start/finish #Klines.XCL_PSO_TRACE=1logs every compile.D3D12.X: log the record hash and time only the driver's compile(review fixes):record HASH, the hash--measure-pso/--record-hashtake).Shaders: fix --export-hlsl / --measure-pso review findings:XCL_HEAP_WINDOWSis honoured.mainc160d86 (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426, direct DXIL).pso.rskeeps both features.--measure-psomeasures the default HLSL path, notXCL_DIRECT_DXIL.Performance evidence (third-party; not repeated on NVIDIA)
--measure-pso --repeat 2, 3a06645 with vs without9f65f95(comment of 18:13Z):CS_RTShadowTrace32TemporalHQCS_RaytracingResolveCSComputeSkinningPedVelocityCS_ShadowRenderTiledCascades/…ParaboloidShadows+0x23cf683watchdog about 29 s after the last frame. No watchdog improvement is claimed. The builds in flight there are mid-size non-RT compute that commit 1 does not change. A second load was not reached.--measure-psotimings.Tested
x86_64-pc-windows-msvc; debug tests and release smoke builds.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 870 passed, 0 failed, 42 ignored. SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)title_textures,vram(twoPoisonErrorfollow-ons) andpso_async. All 4 passed alone, and the suite was clean on the rerun.big_compile_tests,shaders::tests, anda_stream_counts_referenced_shader_code_not_its_descriptors, 15 passed. These include new tests for the gate label, a flag without its value, single-file export and non-compute skipping.git diff --check c160d86...4143a09: clean.Regression run
Main and PR ran back to back under the shared smoke lock on an otherwise idle machine, with
XCL_PRESS_A_AT=10,15,20,25,30,40(A pressed at those seconds) for both. Main is 9e3831e; the release build of c160d86 was not available. That means this PR's numbers also include #1426.main:
PR:
PR / main: 100.6 % of frames, 103.5 % of peak commit.
Not tested
AI use
main, reviewed the diff, and ran the first validation.main;