Skip to content

Shaders: earlier-use preparation builds used split programs' chain-root whole - #3737

Draft
mononen wants to merge 1 commit into
xcl-dev:amd-devfrom
mononen:shaders/prep-used-whole-forms
Draft

mononen wants to merge 1 commit into
xcl-dev:amd-devfrom
mononen:shaders/prep-used-whole-forms

Conversation

@mononen

@mononen mononen commented Dec 2, 2026

Copy link
Copy Markdown

Targets amd-dev: split_builds and the narrowing it changes exist only there.

0481ad6 left split programs' whole forms out of launch preparation unless an earlier run had dispatched the program indirectly. For the ABI-root form that is right on AMD (nothing keeps it). The chain-root form is different: dispatch_chain::whole_ready builds it at the program's first ExecuteIndirect, on the title's thread unless XCL_CS_PSO_WAIT_MS is set. A program used directly in one run and first dispatched indirectly in a later run then stops the title for that compile. On an RX 7900 XT the retail title's render thread compiled such forms of 590 – 950 KB of DXIL for 16 – 48 s each, one after another, with no frame for minutes, run after run as it reached new parts of its loading (used-indirect-split.txt grew from 22 to 47 programs over four runs). Related: #2794 (merged, built all whole forms), 0481ad6.

What is in it

  • crates/xcl/src/shaders.rs: split_builds takes whole_direct: with it, a split program also gets Whole(DirectChain); programs on used-indirect-split.txt keep their builds as before, and the ABI-root form stays out. precompile sets it in the workers' earlier-use pass (--used-only), unless XCL_PREPARE_WHOLE=0. prepare_compute (milestone, corpus) is unchanged. split_programs_get_whole_forms_only_where_the_title_takes_them covers the new set.
  • README.md: the added builds and XCL_PREPARE_WHOLE=0.

Tested

  • AMD Radeon RX 7900 XT (driver 32.0.32029.2010), Ryzen 7 5800X3D, 32 GB, Windows 10 Pro 19045 with the Agility SDK 1.621, rustc 1.100.1, release.
  • On this head: cargo test -p xcl --lib shaders:: -- --test-threads=4: 94 passed, 0 failed, 0 ignored; SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Developer Mode).
  • Retail title, this change together with the largest-first worker queue (separate PR), not this head alone:
    • the first launch with it: compute preparation 1,124 s instead of 310 s, once, with the driver's cache cold for those forms.
    • in that run the title's thread built no whole form for its first ~1,400 s; it then built four of 730 – 950 KB (30 – 48 s each). Whether those four were on the lists preparation used was not checked.

Regression run

  • pending: the xcl-smoke blocks (amd-dev and this head) follow. smoke.ps1 sets XCL_PREPARE=0, so it does not reach this code.

Not tested

  • The whole suite on this head: not run yet.
  • This head alone in a title (measured with the worker queue on top); a second launch's preparation time once the forms are in the driver's cache.
  • NVIDIA / Intel (there whole_form_kept() is usually true and the set does not change).

AI use

  • Claude Code (Claude Opus 5.5) found the stalls in the logs, wrote the change and the test, ran the tests and drafted this description; the user ran the title.

…ot whole

0481ad6 left a split program's whole forms out of launch preparation unless an
earlier run had dispatched it indirectly, because neither whole form is used unless a
driver blob or the pipeline library keeps it (off on AMD). That holds for the ABI-root
form. The chain-root form is the one dispatch_chain::whole_ready builds at the
program's first ExecuteIndirect, and without XCL_CS_PSO_WAIT_MS it builds it on the
title's thread.

A program used directly in one run and first dispatched indirectly in a later one
therefore stops the title in that later run. On an RX 7900 XT the retail title's render
thread compiled such forms of 590 - 950 KB of DXIL for 16 - 48 s each, one after
another, with no frame for minutes; used-indirect-split.txt grew from 22 to 47 programs
over four runs as the title reached new parts of its loading.

When preparation builds what earlier runs used (the workers' --used-only pass), it now
also builds every used split program's whole form under the chain root, the same
pipeline whole_ready would build. Programs on used-indirect-split.txt keep their
indirect-root builds as before; the ABI-root form stays out. XCL_PREPARE_WHOLE=0 restores
the previous set.

Measured on this machine, together with the largest-first worker queue (not in this PR):
the first launch with it took 1,124 s of compute preparation instead of 310 s, once,
while the driver's cache was cold for those forms. In that run the title's thread built
no whole form for its first ~1,400 s; it then built four of 730 - 950 KB (30 - 48 s
each). Whether those four programs were on the lists preparation worked from was not
checked.

Assisted-by: Claude Code (Claude Opus 5.5)
@github-actions github-actions Bot added area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review of 4b8bcdee (code reading only, not a merge-check; draft, PR description red) · 3 medium, 1 nit

In short: This PR makes the launch workers' --used-only pass also build the chain-root whole form of every used split program, unless XCL_PREPARE_WHOLE=0. That partly reverses 0481ad6 by default. The wiring matches what dispatch_chain::whole_ready builds. But the default-on cost is large and its benefit is not measured on this head, a failed optional build now stops the launch, and records covered by a staged corpus do not get it.

Medium

  1. On by default without a measured benefit.

    • whole_direct is on whenever the workers run --used-only (shaders.rs ~4233, prepare_whole ~1855).
    • The description reports first-launch compute preparation going from 310 s to 1,124 s. 0481ad6 counted 49 used split programs with 6.9 MB of whole forms, nearly all never dispatched indirectly.
    • The only measurement was taken together with another PR, and in it the title's thread still built four whole forms. Nobody checked whether those were on the lists preparation used.

    Fix: measure this head alone and show the title-thread builds are gone, or make it opt-in.

  2. An optional pipeline can now stop the launch.

    • In prepare_compiled_compute, a failed make(&program.dxil, root) for the new Whole(DirectChain) build returns Err. The worker counts a record failure and returns "Shader preparation stopped" (~4408), and pipelines_in_workers (~3554) blocks guest entry.
    • At run time the same form is optional: if it fails, whole_ready only logs a warning (dispatch_chain.rs ~494).
    • These are the largest driver compiles in the pass.

    Fix: when only whole_direct asked for it, log and skip a failure instead of counting it.

  3. "Every used split program" does not hold with a staged corpus.

    • Workers skip a record the corpus covers (coverage.covers(i, &blob), ~4211) before whole_direct is applied.
    • The corpus builds through prepare_compute(.., false) (pso_corpus.rs ~165), and so does history preparation (milestone.rs ~264). Programs covered there still get their whole form built on the title's thread at their first ExecuteIndirect.

    Fix: narrow the wording in the README (~325) and the prepare_whole doc comment, or pass the flag on those paths too.

Nit

  1. The numbers differ between the code and the description. The README (~328) and the prepare_whole doc comment say "590 – 890 KB" and "16 – 24 s each". The description and the commit message say "590 – 950 KB" and "16 – 48 s".
Checked and fine
  • The new build matches the run-time one. make_required with PipelineRoot::DirectChain uses the same root signature (signature_for(.., false)) and the same ChainRoot::DirectConstants cache name as dispatch_chain::build.
  • indirect is Some only for --pipelines --used-only, so whole_direct is limited to that pass.
  • XCL_PREPARE_WHOLE reaches the worker processes. Adding it to the legacy_warm_settings exclusions leaves the legacy key unchanged when unset.
  • split_builds never adds Whole(DirectChain) twice, and the extended test covers the new and unchanged combinations.
  • prepare_compute and offline make_selected are unchanged. 33+/11- in two files.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants