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

Open
bstillbstill wants to merge 1 commit from upstream-pr/1279 into main
bstillbstill commented 2026-11-24 14:10:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bstillbstill on 2026-11-24T14:10:25Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5473764076 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1279). Originally posted by [bstillbstill](https://github.com/bstillbstill) on 2026-11-24T14:10:25Z. --- `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)
DavidM1911 commented 2026-11-24 15:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:11:27Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133980196 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1279#issuecomment-7133980196). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:11:27Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib shaders`: 6 passed, 0 failed. Thanks!
WillyboPeep commented 2026-11-24 17:06:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by WillyboPeep on 2026-11-24T16:59:04Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7138507693 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1279#issuecomment-7138507693). Originally posted by [WillyboPeep](https://github.com/WillyboPeep) on 2026-11-24T16:59:04Z. --- **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.
simonbronk commented 2026-11-24 21:08:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by simonbronk on 2026-11-24T19:15:05Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7141823493 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7141823493). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-11-24T19:15:05Z. --- 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.*
DavidM1911 commented 2026-11-26 05:05:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:41:04Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7182811087 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7182811087). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:41:04Z. --- 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.
Foniass commented 2026-12-01 05:19:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:19:08Z.


Triage (#1607) – head d2eb1b4

Main has since solved the case that motivated this PR differently. pipeline_cap_kb in shaders.rs (XCL_PIPELINE_MAX_KB, default 8 MiB) leaves a compute program over 8 MiB of DXIL with no saved blob to the runtime instead of compiling it in the pass, so the 13–29 MB programs named in GIANT_DXIL's comment are no longer built there. #2179 (commit headroom for large builds) and #3212 (bounds the DXIL the pass holds) work on the same pass.
What this PR would still add after a rebase is ordering: programs of 4–8 MB are made last, one at a time. precompile on main now builds on a pool of pipeline threads (pipeline_threads), so the change needs reworking against that.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301644937 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1279#issuecomment-7301644937). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:19:08Z. --- **Triage (#1607)** – head d2eb1b4 Main has since solved the case that motivated this PR differently. `pipeline_cap_kb` in shaders.rs (`XCL_PIPELINE_MAX_KB`, default 8 MiB) leaves a compute program over 8 MiB of DXIL with no saved blob to the runtime instead of compiling it in the pass, so the 13–29 MB programs named in `GIANT_DXIL`'s comment are no longer built there. #2179 (commit headroom for large builds) and #3212 (bounds the DXIL the pass holds) work on the same pass. What this PR would still add after a rebase is ordering: programs of 4–8 MB are made last, one at a time. `precompile` on main now builds on a pool of pipeline threads (`pipeline_threads`), so the change needs reworking against that. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1279:upstream-pr/1279'
git switch 'upstream-pr/1279'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1279'
git switch 'upstream-pr/1279'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1279'
git switch 'upstream-pr/1279'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1279'
git switch 'main'
git merge --squash 'upstream-pr/1279'
git switch 'main'
git merge --ff-only 'upstream-pr/1279'
git switch 'main'
git merge 'upstream-pr/1279'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1269
No description provided.