Shaders: --pipelines makes programs of 4 MB DXIL or more last, by name #1279

Open
github-bot wants to merge 1 commit from github-bot/gh-1279 into main AGit
Owner

@⁠bstillbstill on GitHub · 2026-11-24 14:10 UTC · original
bstillbstill:shaders/precompile-giants-last → main · +66 −1 · 1 files · 1 commits · draft

xcl shaders <pack> --precompile --pipelines now makes the pipelines of compute programs of 4 MB of DXIL or more after all the others, one at a time, smallest first, and names each with its size before the driver gets it. Part of #505; the stall reported on #744 (RTX 4080, RTX 5080) and #505 (RTX 4090).

On the newer retail title's pack the pass stopped advancing right after record 22 600, its memory growing (to 27 – 44 GB on an RTX 4080), and printed no name. The records there are three screen-probe programs: #22616 indirect_diffuse_lighting:CS_ScreenProbes_ActivateProbes_9083c094_Wrapped (29 052 KB of DXIL), #22617 …ActivateProbesTarget_534f271f… (28 940 KB), #22618 …ActivateRays_d60186e6… (13 774 KB). Their console code is unrolled (88 863 instructions for ActivateProbes). The NVIDIA driver alone (one thread) had not built ActivateRays after 14 minutes, at 4.6 GB and growing about 0.2 GB a minute.

What is in it

  • Shaders: --pipelines makes programs of 4 MB DXIL or more last, by name – crates/xcl/src/shaders.rs: GIANT_DXIL (4 MB), Giants (kept aside during the pass, taken smallest first), the pass makes them after the others; test pipelines_of_giant_programs_are_kept_for_the_end_smallest_first.

Tested

  • NVIDIA GeForce RTX 3090 Ti (driver 32.0.16.2101, 32-lane waves), Intel Core i9-13900K, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.9.2609.5; debug for the tests, release for the passes.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on d2eb1b4: 742 passed, 0 failed, 41 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • The pack's 29 screen-probe records (xcl rpf <pack> --extract CS_ScreenProbes_ --out <dir>; 5 more have names past the Windows path limit), then xcl shaders <dir> --precompile --only cs --pipelines: the 26 others were made in 25 s (pipelines: 25 made, 0 refused the last progress line), then it printed 3 compute programs of 4 MB of DXIL or more, made last … and gave ActivateRays (13 774 KB) to the driver, named. I stopped it there.
  • The whole pack, --precompile --only cs --pipelines --limit 22700: 225 pipelines in 22 minutes, 0 refused, private bytes mostly 2.2 – 3.1 GB (peak 8.9 GB). It had not reached record 22 616 when I stopped it: the 0.3 – 1 MB programs before it went at about 2 a minute (NVIDIA's compiler waits on the process heap lock, as reported on #744 and #759).

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 3090 Ti
title: My1stGame
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16569 MB

This PR:

xcl-smoke v1
commit: d2eb1b4da080456740599a1b2d0a6d85e212c9d8
gpu: NVIDIA GeForce RTX 3090 Ti
title: My1stGame
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17670 MB

The title run does not reach this code (it is xcl shaders only). No input in either run (intro and menus). Made with smoke.ps1 plus a local fix that reads the log of a run that does not exit by itself (an earlier main run hung in end_title after its 60 s); these runs exited by themselves, so main's script gives the same blocks.

Not tested

  • A pass to the end of the pack, and how long each of the three takes to finish (hours here).
  • With #744 (which changes what Pipelines::make keeps): a conflict in shaders.rs is likely.
  • AMD; Linux / Wine.

AI use

  • Claude Code (Claude Opus 5.5): found and measured the programs, wrote the change, the test and this description, ran the tests and the passes on the hardware above.

🤖 Generated with Claude Code

**@⁠bstillbstill** on GitHub · 2026-11-24 14:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1279) `bstillbstill:shaders/precompile-giants-last` → `main` · +66 −1 · 1 files · 1 commits · draft `xcl shaders <pack> --precompile --pipelines` now makes the pipelines of compute programs of 4 MB of DXIL or more after all the others, one at a time, smallest first, and names each with its size before the driver gets it. Part of #505; the stall reported on #744 (RTX 4080, RTX 5080) and #505 (RTX 4090). On the newer retail title's pack the pass stopped advancing right after record 22 600, its memory growing (to 27 – 44 GB on an RTX 4080), and printed no name. The records there are three screen-probe programs: #22616 `indirect_diffuse_lighting:CS_ScreenProbes_ActivateProbes_9083c094_Wrapped` (29 052 KB of DXIL), #22617 `…ActivateProbesTarget_534f271f…` (28 940 KB), #22618 `…ActivateRays_d60186e6…` (13 774 KB). Their console code is unrolled (88 863 instructions for ActivateProbes). The NVIDIA driver alone (one thread) had not built ActivateRays after 14 minutes, at 4.6 GB and growing about 0.2 GB a minute. **What is in it** - `Shaders: --pipelines makes programs of 4 MB DXIL or more last, by name` – `crates/xcl/src/shaders.rs`: `GIANT_DXIL` (4 MB), `Giants` (kept aside during the pass, taken smallest first), the pass makes them after the others; test `pipelines_of_giant_programs_are_kept_for_the_end_smallest_first`. **Tested** - NVIDIA GeForce RTX 3090 Ti (driver 32.0.16.2101, 32-lane waves), Intel Core i9-13900K, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, DXC 1.9.2609.5; debug for the tests, release for the passes. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` on `d2eb1b4`: 742 passed, 0 failed, 41 ignored. SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64). - The pack's 29 screen-probe records (`xcl rpf <pack> --extract CS_ScreenProbes_ --out <dir>`; 5 more have names past the Windows path limit), then `xcl shaders <dir> --precompile --only cs --pipelines`: the 26 others were made in 25 s (`pipelines: 25 made, 0 refused` the last progress line), then it printed `3 compute programs of 4 MB of DXIL or more, made last …` and gave ActivateRays (13 774 KB) to the driver, named. I stopped it there. - The whole pack, `--precompile --only cs --pipelines --limit 22700`: 225 pipelines in 22 minutes, 0 refused, private bytes mostly 2.2 – 3.1 GB (peak 8.9 GB). It had not reached record 22 616 when I stopped it: the 0.3 – 1 MB programs before it went at about 2 a minute (NVIDIA's compiler waits on the process heap lock, as reported on #744 and #759). **Regression run** `main`: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 3090 Ti title: My1stGame seconds: 60 exit: 0x0 frames shown: 1649 (PresentX 1649) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16569 MB ``` This PR: ``` xcl-smoke v1 commit: d2eb1b4da080456740599a1b2d0a6d85e212c9d8 gpu: NVIDIA GeForce RTX 3090 Ti title: My1stGame seconds: 60 exit: 0x0 frames shown: 1649 (PresentX 1649) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17670 MB ``` The title run does not reach this code (it is `xcl shaders` only). No input in either run (intro and menus). Made with `smoke.ps1` plus a local fix that reads the log of a run that does not exit by itself (an earlier main run hung in `end_title` after its 60 s); these runs exited by themselves, so `main`'s script gives the same blocks. **Not tested** - A pass to the end of the pack, and how long each of the three takes to finish (hours here). - With #744 (which changes what `Pipelines::make` keeps): a conflict in `shaders.rs` is likely. - AMD; Linux / Wine. **AI use** - Claude Code (Claude Opus 5.5): found and measured the programs, wrote the change, the test and this description, ran the tests and the passes on the hardware above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`xcl shaders <pack> --precompile --pipelines` on a retail title's pack
stops advancing right after record 22 600, its memory growing (reported
on #505 / #744 from three machines, and on this one). The records there
are three screen-probe compute programs of 13 - 29 MB of DXIL (88 863
console instructions for the biggest, unrolled). The NVIDIA driver alone
had not built the smallest after 14 minutes; in the pass, the compiles
queued behind them held up everything after, and the pass printed no
name.

Programs of GIANT_DXIL (4 MB) or more are now kept aside and made after
all the others, one at a time, smallest first, each named with its size
before the driver gets it and timed after. Stopping the pass there keeps
everything made before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:15 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:11 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib shaders: 6 passed, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 14:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7133980196) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib shaders`: 6 passed, 0 failed. Thanks!
Author
Owner

@⁠WillyboPeep on GitHub · 2026-11-24 16:59 UTC · original

Test report: d2eb1b4 on an RTX 4090. The pass gets everything but the giants done first, as described; then the driver had not finished the smallest giant after 41 minutes. Counts and timings only.

Setup: NVIDIA GeForce RTX 4090 (driver 621.01, 32-lane waves), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust 1.98.1 MSVC, release, DXC 1.9.2602.17. This PR's head d2eb1b4 as pushed (on main 47efa2e), nothing else.

  • cargo test --release -p xcl --lib shaders: 6 passed, 0 failed (with pipelines_of_giant_programs_are_kept_for_the_end_smallest_first).
  • Retail 1.0.2.1 shaders.rpf: xcl rpf … --extract CS_ScreenProbes_ --out <short path> extracted 32 records with a short output path (29 in the PR's run). Then xcl shaders <folder> --precompile --only cs --pipelines with a new, empty XCL_DXIL_CACHE, one run, page file grown beforehand, stopped after 45 minutes.
the 29 others (DXC from an empty cache included) done after about 4 minutes
3 compute programs of 4 MB of DXIL or more, made last … printed, ActivateRays (13 774 KB) named and given to the driver
ActivateRays in CreateComputePipelineState not done after 41 minutes (stopped by my cap at 2 711 s of the pass)
process private bytes during it 0.7 GB → 3.5 (10 min) → 4.6 (16 min) → 5.9 (26 min) → 7.8 GB (41 min), about 0.17 GB a minute, steady
ActivateProbesTarget, ActivateProbes not reached

Three things that may matter for the PR:

  • On this head the pass keeps no driver blobs: the new cache had no driver\*.pso file afterwards. The base is before #744 (merged in 6cef69f), so a rebase onto main would keep what the pass makes before the giants. That is where this ordering pays.
  • "the driver can take 15 minutes or more over each" understates it here: more than 40 minutes for the smallest one on a 4090, and still growing. A way to leave the giants out (a size cap) would let a pass end; that is what the maintainer asked for on #744.
  • On today's main this record is far bigger: since b8b1f49, ActivateRays translates to 148.5 MB of structured HLSL (#1307, fixed by #1321). A rebase onto main would want #1321 for this pass, or the giants' DXC alone takes a long time. Not measured here.

Not tested: this PR rebased onto main; the whole pack; the two bigger giants; AMD.

AI use: Claude Code (Claude Opus 5.5) ran the builds and runs on my PC and wrote this report.

**@⁠WillyboPeep** on GitHub · 2026-11-24 16:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7138507693) **Test report: `d2eb1b4` on an RTX 4090. The pass gets everything but the giants done first, as described; then the driver had not finished the smallest giant after 41 minutes.** Counts and timings only. **Setup:** NVIDIA GeForce RTX 4090 (driver 621.01, 32-lane waves), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust 1.98.1 MSVC, release, DXC 1.9.2602.17. This PR's head `d2eb1b4` as pushed (on `main` `47efa2e`), nothing else. - `cargo test --release -p xcl --lib shaders`: 6 passed, 0 failed (with `pipelines_of_giant_programs_are_kept_for_the_end_smallest_first`). - Retail 1.0.2.1 `shaders.rpf`: `xcl rpf … --extract CS_ScreenProbes_ --out <short path>` extracted 32 records with a short output path (29 in the PR's run). Then `xcl shaders <folder> --precompile --only cs --pipelines` with a new, empty `XCL_DXIL_CACHE`, one run, page file grown beforehand, stopped after 45 minutes. | | | |---|---| | the 29 others (DXC from an empty cache included) | done after about 4 minutes | | `3 compute programs of 4 MB of DXIL or more, made last …` | printed, ActivateRays (13 774 KB) named and given to the driver | | ActivateRays in `CreateComputePipelineState` | **not done after 41 minutes** (stopped by my cap at 2 711 s of the pass) | | process private bytes during it | 0.7 GB → 3.5 (10 min) → 4.6 (16 min) → 5.9 (26 min) → 7.8 GB (41 min), about 0.17 GB a minute, steady | | ActivateProbesTarget, ActivateProbes | not reached | Three things that may matter for the PR: - **On this head the pass keeps no driver blobs:** the new cache had no `driver\*.pso` file afterwards. The base is before #744 (merged in `6cef69f`), so a rebase onto `main` would keep what the pass makes before the giants. That is where this ordering pays. - **"the driver can take 15 minutes or more over each"** understates it here: more than 40 minutes for the smallest one on a 4090, and still growing. A way to leave the giants out (a size cap) would let a pass end; that is what the maintainer asked for on #744. - **On today's `main` this record is far bigger:** since `b8b1f49`, ActivateRays translates to 148.5 MB of structured HLSL (#1307, fixed by #1321). A rebase onto `main` would want #1321 for this pass, or the giants' DXC alone takes a long time. Not measured here. **Not tested:** this PR rebased onto `main`; the whole pack; the two bigger giants; AMD. **AI use:** Claude Code (Claude Opus 5.5) ran the builds and runs on my PC and wrote this report.
Author
Owner

@⁠simonbronk on GitHub · 2026-11-24 19:15 UTC · original

A data point and one suggestion for this PR, from a run of a variant of it.

This PR keeps the giants aside only at pipeline creation, by DXIL size. DXIL size is known only after translation and DXC, so the giants' translation and DXC (-O0, 14 – 30 MB of DXIL) still run in pack order, on the pass's threads. On this machine that part alone stalled the pass. A variant of mine sorts the records by their inflated size (pack::Record::usize, so nothing has to be read first) before any thread takes one: precompile walks order[k] instead of k. The giants then come last in DXC as well as in the driver.

Setup: RTX 5070 12 GB (driver 621.24), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust stable MSVC, release, DXC 1.9.2609. main 9e3831e (#680 merged) plus only the ordering change, retail 1.0.2.1 pack (26 503 records). xcl shaders shaders.rpf --precompile --only cs --pipelines with XCL_HEAP_WINDOWS=1. One run each, and not a controlled comparison: the second run started with the DXIL and blobs the first had made.

  • Pack order (main): 525 pipelines made, then private bytes rose from 30 to 46 GB in 5 minutes past record 22 600. I killed it when free commit dropped under 6 GB.
  • Smallest first: 2 100 pipelines made in about 25 minutes, 1 refused, private bytes 2 – 14 GB. I stopped it when it reached the largest records.

So I cannot give a throughput figure. What the data shows is that ordered this way, the pass got through the rest of the pack before the giants without the memory climb. If you'd rather keep this PR as it is, I can open the ordering as a separate small PR stacked on this one. Say which you prefer.

Title run after it (same tree, XCL_HEAP_WINDOWS=1, warm blobs): at world load 291 compute pipelines came from blobs in 0 – 23 ms. The stop at world load (#1452) is still there. With XCL_PSO_WAIT_MS=50 it became the queue.Wait … did not complete within 5000 ms mode (waiter=q0/q2/q4, prod=qSome(1), completed=0x0) instead of the title's watchdog. So on this card the pipeline builds no longer explain it.

AI use: Claude Code with Claude Opus 5.5 wrote the variant, ran the passes and the title, and wrote this comment at the request of the person running it.

**@⁠simonbronk** on GitHub · 2026-11-24 19:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7141823493) A data point and one suggestion for this PR, from a run of a variant of it. This PR keeps the giants aside only at pipeline creation, by DXIL size. DXIL size is known only after translation and DXC, so the giants' translation and DXC (`-O0`, 14 – 30 MB of DXIL) still run in pack order, on the pass's threads. On this machine that part alone stalled the pass. A variant of mine sorts the records by their inflated size (`pack::Record::usize`, so nothing has to be read first) before any thread takes one: `precompile` walks `order[k]` instead of `k`. The giants then come last in DXC as well as in the driver. **Setup:** RTX 5070 12 GB (driver 621.24), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust stable MSVC, release, DXC 1.9.2609. `main` 9e3831e (#680 merged) plus only the ordering change, retail 1.0.2.1 pack (26 503 records). `xcl shaders shaders.rpf --precompile --only cs --pipelines` with `XCL_HEAP_WINDOWS=1`. One run each, and **not a controlled comparison**: the second run started with the DXIL and blobs the first had made. - **Pack order (`main`):** 525 pipelines made, then private bytes rose from 30 to 46 GB in 5 minutes past record 22 600. I killed it when free commit dropped under 6 GB. - **Smallest first:** 2 100 pipelines made in about 25 minutes, 1 refused, private bytes 2 – 14 GB. I stopped it when it reached the largest records. So I cannot give a throughput figure. What the data shows is that ordered this way, the pass got through the rest of the pack before the giants without the memory climb. If you'd rather keep this PR as it is, I can open the ordering as a separate small PR stacked on this one. Say which you prefer. **Title run after it** (same tree, `XCL_HEAP_WINDOWS=1`, warm blobs): at world load 291 compute pipelines came from blobs in 0 – 23 ms. The stop at world load (#1452) is still there. With `XCL_PSO_WAIT_MS=50` it became the `queue.Wait … did not complete within 5000 ms` mode (`waiter=q0/q2/q4`, `prod=qSome(1)`, `completed=0x0`) instead of the title's watchdog. So on this card the pipeline builds no longer explain it. *AI use: Claude Code with Claude Opus 5.5 wrote the variant, ran the passes and the title, and wrote this comment at the request of the person running it.*
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:41 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 04:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7182811087) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/shaders.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1279/head:github-bot/gh-1279'
git switch 'github-bot/gh-1279'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'main'
git merge --squash 'github-bot/gh-1279'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'main'
git merge 'github-bot/gh-1279'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.