Shaders: size-based admission for big compute driver compiles #1774
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!1774
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1774/head"
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?
@brandostrong on GitHub · 2026-11-24 20:34 UTC · original
brandostrong:a19-size-admission→main· +149 −17 · 3 files · 3 commits · merged 2026-11-25 00:54 UTCBounds what a big compute driver compile may spend. The commit headroom a background
compile waits for now scales with the program's DXIL size, and
xcl shaders --pipelinesleaves programs over a DXIL cap to the runtime instead of hanging the pass on them.
Measured on the retail pack (#1269): the driver's compile of a 29.8 MB program grew past
14 GB of free commit before it was stopped, and programs of ~1 MB took several GB each on
an 8 GB card; three programs of 29–30 MB DXIL hung
--precompile --only cs --pipelinesfor 33+ minutes on three machines (#744). The 3 GB headroom floor was measured on the
256 KiB class (~1.5 GB each); above 6 MiB of DXIL it now asks for 512× the DXIL size, and
the offline pass skips what it cannot afford. The title path is unchanged for everything
up to 6 MiB (the floor), and the runtime still builds a capped program when a title needs
the pipeline.
Part of #1269 (campaign task A19).
What is in it
crates/xcl/src/hle/d3d12x/real.rs:big_compile_headroom(dxil_len)= max(3 GB, 512× DXIL size);big_compile_commit_freewaits for that much, through main'sdriver_compile_identifiedgate (both the big and the giant lane); headroom testcrates/xcl/src/shaders.rs:XCL_PIPELINE_MAX_KB(KiB of DXIL, 8 MiB default, 0 turns the cap off) caps the--pipelinesstage; capped programs counted and reported; cap-resolution testcrates/xcl/src/shaders.rs: a stale driver blob no longer bypasses the cap — a blob the driver rejects (or accepts while recompiling internally) is removed, the program counts as capped, and the uncached compile is skipped; regression test from #1774 (WebIdentity1)README.md: the cap documentedTested
cargo test --workspace -- --test-threads=4on6b9b14f: 963 passed, 0 failed, 43 ignored; 22 SKIPPED, all adapter limits of this wave32 card: the wave64 lowering/comparison GPU tests (gpu::recomp::lower::tests::*,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)--precompile --only cs --pipelineswithXCL_PIPELINE_MAX_KB=1: the pipeline stage compiled only the programs at or under the cap (375 made, 0 refused) and capped the rest; the pass was interrupted before its final count (it is resumable). The same pass showed the DXC leg stalling ~176 s over records 22600–22800 (the > 8 MB HLSL programs at-O0) — that leg is not capped here and still finishesRegression run
Both runs below reached the same screen (post-EULA world load) on the same profile; both
stall there identically — 0 presents in the last 6 s at ~33 GB commit — which is the
pre-existing world-load freeze on main (see #1269), not something this PR introduces or
fixes. No crash, no device removal on either.
Not tested
--pipelinespass run to completion at the 8 MiB default on the retail pack (resumable; the capped line is unit-tested, the full-pass finish is not yet measured here)AI use
🤖 Generated with Claude Code
@eizispark on GitHub · 2026-11-24 21:16 UTC · original
Hardware test report — commit
a239e35Verified
a239e358922fad455fb91b7f9f11218e32f9619d(clean merge withmain7f7e768): pass.Tested
32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64 (stable-x86_64-pc-windows-msvc,rustc 1.100.0 (0ef1bc386 2026-11-09)), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4:893 passed, 0 failed, 42 ignored(2 skipped:shaders::tests::pso_measurement_compiles_an_exact_synthetic_record— Windows Developer Mode required (0x887A002D);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)hle::d3d12x::real::big_compile_tests::headroom_is_the_3_gb_floor_until_512_times_the_dxil_exceeds_it,shaders::pipeline_cap_tests::the_cap_is_8_mib_unless_set_and_off_at_zero,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, and both native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware) passed cleanlyRegression run (
scripts/smoke.ps1, 60 s, warm shader/driver cache)main(85e38262ff94aecd75d6f83fa8156a8b7697bd13):PR (
a239e358922fad455fb91b7f9f11218e32f9619d):Not tested
xcl shaders --pipelinespack run hitting> 8 MiBcompute DXIL containers orXCL_PIPELINES_MAX_DXIL_KBoverrides, NVIDIA/Intel GPUs, Wine/vkd3d-proton, gameplay past the menusAI use
@WebIdentity1 on GitHub · 2026-11-24 21:12 UTC · original · edited 2026-11-24 21:26 UTC
I found a reproducible cap bypass on exact head
a239e358922fad455fb91b7f9f11218e32f9619d. InPipelines::make(crates/xcl/src/shaders.rs), the new over-cap check asks whetherdriver_cache::loadreturned bytes. If a nonempty blob is then rejected byCreateComputePipelineState, the fallback still compiles that over-cap DXIL from scratch. A stale blob after a driver or adapter change can therefore defeatXCL_PIPELINE_MAX_KB.3090 negative control and local fix check: With an isolated cache, I wrote an intentionally invalid PSO blob for public synthetic 2,816-byte compute DXIL, set the diagnostic cap to 2,815 bytes, and dispatched the same shader to check GPU output. Unchanged head plus test-only fixture:
0 passed / 1 failed / 0 ignored(expected),capped=0, made=1, refused=0, GPU output42. A local candidate that checks the cap again after cached-PSO rejection, removes the stale blob and returns before the uncached fallback:1 passed / 0 failed / 0 ignored,capped=1, made=0, refused=0, GPU output still42. No skips or device removal. Both 295-file source snapshots matched their SHA256 manifests before and after native testing. Windows 10 19045, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11; command:cargo test --locked -p xcl --lib stale_blob_cannot_bypass_the_offline_pipeline_cap -- --test-threads=1 --show-output --nocapture.The narrow fix point is immediately after
from_cache: whencached.is_some() && from_cache.is_none() && over_cap, remove the rejected blob, release therunningslot, count it as capped, and return. The existing no-blob early check remains. Avoiddriver_cache::note(false, ...)here: its current log says the pipeline will be compiled again, whereas this path skips it. This fixture deliberately uses a low cap to make the failure cheap; it does not measure production 8 MiB shaders, world-loading memory or retail gameplay. I measured one uncached driver compile avoided; the millisecond timings are not a controlled speed benchmark because another build was active during the initial candidate run.Portable patch follow-up: I replaced the environment-specific diagnostic with a private cache-path injection seam and a test-owned scratch directory. The same regression on 3090 still fails before the fix (
0/1/0,capped=0, made=1, output42) and passes after (1/0/0,capped=1, made=0, output42), no skips/device removal. Both 295-file Windows snapshots matched SHA256 before and after. A matched interactive-session-1cargo build --locked --workspacepassed on both;cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-outputacross 20 targets was 891 passed / 3 failed / 42 ignored on the control and 892 / 2 / 42 on the candidate. Both shared the known integer-CLAMP failure and the synthetic PSO-measurement driver-cache/SDK requirement; the third control failure is this expected regression. Four explicit skips on each (two debug-layer, two native-wave64 references). Neither full suite is green, but there is no candidate-only failure. This local patch is in one file (shaders.rs, 62 additions / 2 deletions), uncommitted and unpushed; I can supply the complete diff if useful. The author still needs exact-head retail smoke after incorporating a runtime change.Separately, the PR-description check currently fails because its head smoke block names
60443ff, while this PR's head isa239e35; the required exact-head smoke needs updating after the last push.Portable one-file patch against a239e35
@WebIdentity1 on GitHub · 2026-11-24 21:44 UTC · original
I checked the new head
cbff0b8c09e240f33acb86db4b7e213966392641after its rebase. The cap bypass from my earlier fail-before/pass-after reproducer and portable patch is still present in the code:Pipelines::makecheckscached.is_none()atshaders.rs:1210, then a rejected nonempty cached PSO reaches the uncapped fallback atshaders.rs:1230-1232. The new commit does not add a post-rejection cap check. This is a code review ofcbff0b8, not a new GPU run on that head; the RTX 3090 reproducer was run ona239e35. The earlier patch can be integrated into this PR, with its test and the required exact-head smoke rerun by the author.@brandostrong on GitHub · 2026-11-24 22:04 UTC · original
@WebIdentity1 confirmed on RTX 4090 and merged as
6b9b14f, with your test and injection seam taken as-is and the diagnosis credited in the commit message. Your repro showed a second face here: with a warm NVIDIA driver cache the driver accepts the invalid blob, recompiles internally and returns Ok - the attempt then looks like a blob hit and your post-rejection check never fires (cold: hard reject, your case; warm: silent fallback, test failed in-suite). The merged fix adds hit-detection: a blob attempt counts as a hit only when the pipeline carries a blob of the size handed to it (GetCachedBlobsize check), so both faces land on the capped path and the test is deterministic cold and warm. Suite on the new head: 963 passed / 0 failed / 43 ignored, no candidate-only failures. Thanks for the precise fix point.@brandostrong on GitHub · 2026-11-24 22:04 UTC · original
@eizispark thanks for the AMD run - first RDNA4 coverage on this PR. Heads-up: the head moved to
6b9b14f(a stale-blob cap-bypass fix from #1774 discussion,shaders.rsonly, offline--pipelinespath; your gate/headroom results are unaffected). The regression pair in the description is now a same-screen world-load pair; both sides stall identically, which is the pre-existing freeze on main, not this PR.@DavidM1911 on GitHub · 2026-11-24 23:24 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@thiagocalile on GitHub · 2026-11-25 00:12 UTC · original
Tested commit
6b9b14fd636ae26152c02eeb8c0f34c51bbd55f7on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves) with unit/workspace tests and a 60 sscripts/smoke.ps1regression run (comparing againstmain62265d3).Tested
32.0.21045.29003;XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11.XCL_ADAPTER=radeon cargo test -p xcl --lib shaders::tests -- --test-threads=4: 6 passed, 0 failed, 0 ignored (46.64s).XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 959 passed, 3 failed, 43 ignored (68.14s).mainon this RX 6600 (placed_title_textures_share_vram_and_preserve_pixels: 3D mip subresource mismatch, plus 2 mutex-poison cascadestransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memory; tracked by #1028).SKIPPED(not counted as coverage):gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's));gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's));gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's));gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's));gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's));gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's));heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows;shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): O aplicativo solicitou uma operação que depende de um componente SDK que está ausente ou é incompatível. (0x887A002D)(plus D3D12 debug-layer tests skip becaused3d12SDKLayers.dllis not installed).Regression run (
scripts/smoke.ps1, 60 s, release build,XCL_ADAPTER=radeon)Base (
main62265d3):PR (
6b9b14f):Not tested
AI use
scripts/smoke.ps1runs on my RX 6600 and drafted this report; I checked the output before posting.@thehollowedone on GitHub · 2026-11-24 21:51 UTC · original · edited 2026-11-25 01:04 UTC
Tested
On
6b9b14fd, I ran the stock synthetic compute shader through the CLI in three separate processes using the same scratch cache. WithXCL_PIPELINE_MAX_KB=1and an empty cache, the CLI capped one pipeline and made none. With the cap disabled, it built one and saved the driver blob. With the 1 KiB cap restored, it reused that valid blob and reported zero capped pipelines. All three invocations exited successfully with zero refusals.RTX 3080 Ti / 621.35, Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11.
cargo test --offline --locked -p xcl --test gpu_compute_e2e <filter> -- --nocapture --test-threads=1passed 1/1 for the stockoffline_compute_pipeline_is_reused_by_a_second_processand 1/1 for the localscratch_offline_cap_preserves_valid_warm_pipelinefixture, with zero skips.Not tested
This checks cold admission and warm reuse through
shaders --precompile --pipelines. The fixture used a small synthetic shader and a lowered cap. It does not measure retail world loading or driver memory use.AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the local fixture and drafted this report.
Post-merge stale-cache check on
656c0e8On the RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC and DXC 1.8.2502.11,
cargo test --offline --locked -p xcl --lib --jobs 2 stale_blob_cannot_bypass_the_offline_pipeline_cap -- --nocapture --test-threads=1passed with zero skips. With a 2,816-byte synthetic shader and a cap one byte below it, the rejected cached blob was removed and offline counters were 1 capped, 0 made, 0 refused. A separate GPU dispatch read back the expected value of 42. The cap-default and headroom-formula tests also passed. This covers offline admission and the headroom calculation. No retail workload or runtime compiler memory was measured.AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this update.