Skip to content

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

Draft
bstillbstill wants to merge 1 commit into
xcl-dev:mainfrom
bstillbstill:shaders/precompile-giants-last
Draft

bstillbstill wants to merge 1 commit into
xcl-dev:mainfrom
bstillbstill:shaders/precompile-giants-last

Conversation

@bstillbstill

Copy link
Copy Markdown

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 Shaders: save offline compute pipelines to the runtime driver cache #744 and Shaders: xcl pipelines compiles a run's queued pipelines outside the title #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

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

`xcl shaders <pack> --precompile --pipelines` on a retail title's pack
stops advancing right after record 22 600, its memory growing (reported
on xcl-dev#505 / xcl-dev#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 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

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

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

Thanks!

@WillyboPeep

Copy link
Copy Markdown

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:

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

Copy link
Copy Markdown

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.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants