Shaders: precompile --pipelines compiles in the driver on its own threads #253

Closed
1984742628 wants to merge 1 commit from upstream-pr/256 into main
1984742628 commented 2026-11-23 21:59:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by 1984742628 on 2026-11-23T21:59:18Z.


xcl shaders --precompile --pipelines made each compute pipeline on the thread that translated it, at most four at once (XCL_PIPELINE_THREADS). Once the four slots held programs the driver needs minutes for, every translating thread waited for a slot and the run stopped moving: a retail pack of 26 503 shaders sat at 22 800 for many minutes with about 3.5 cores busy, two driver compiles at about 6 CPU-minutes each. This PR moves the driver's compiles to their own threads and orders them by size and free memory. No issue is linked.

What is in it

  • One commit, crates/xcl/src/shaders.rs only (314 added, 25 removed).
  • The driver's compiles run on their own threads, fed by a queue (BiggestFirst, at most 2 GB of DXIL waiting). The translating threads go on and fill the DXIL cache meanwhile.
  • Each driver thread takes the biggest program whose compile fits in free memory (driver_fits): the big ones start first, the threads left over make small ones. A program is taken to need 1536 bytes per byte of DXIL, between 64 MB and 1.5 GB, with 2 GB kept free.
  • Driver threads: half the cores (at most 16) with memory watched. XCL_PIPELINE_THREADS still works: that many at once, memory not watched.
  • Output: a status line every 15 s and a line for each pipeline the driver took more than 60 s for, instead of one line every 25 pipelines.
  • Unit tests for the queue (order, byte limit, closing, biggest that fits) and for the memory rule.
  • The translation, the DXIL and the pipelines made are unchanged; only their order and how many are made at once change.

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1714), AMD Ryzen 9 7950X, 32 GB, Windows 11 10.0.26100, rustc 1.98.0, debug.
  • cargo test --workspace -- --test-threads=4 on ed5322f with no uncommitted changes: 656 passed, 0 failed, 40 ignored (SKIPPED GPU tests: 2, both "no wave64": gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware). The XCL_SAMPLE_* variables were not set, so the tests on game data did nothing.
  • cargo test -p xcl --release --lib on ed5322f: 616 passed, 0 failed, 20 ignored.

Regression run
Not run. scripts/smoke.ps1 was not run on main or on this PR, so there are no xcl-smoke blocks.

main:

PR:

Not tested

  • No regression run on a real title (see above). The change is in xcl shaders --precompile only; xcl run does not call it.
  • No timed whole --precompile --pipelines run with this version, so no before / after numbers. An earlier version (strictly biggest first, every running compile counted as 1.5 GB) was run on the retail pack: seven big programs took the whole memory allowance and nothing else was made meanwhile. The "biggest that fits" rule is the answer to that and has unit tests only.
  • The memory numbers come from the comment that was there and from this one NVIDIA machine. Not tested on AMD or Intel GPUs.
  • The branch is on 7a033c8, not rebased onto the newest main, and the commit subject is longer than 72 characters.

AI use
Claude Code. Claude Opus 5.5 wrote the first version of the change; Claude Fable 5.2 wrote the final code, the unit tests, the commit message and this description, and ran the tests listed above.

<!-- greyfinch-sync:ivall/xcl:issue:6569680227 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/256). Originally posted by [1984742628](https://github.com/1984742628) on 2026-11-23T21:59:18Z. --- `xcl shaders --precompile --pipelines` made each compute pipeline on the thread that translated it, at most four at once (`XCL_PIPELINE_THREADS`). Once the four slots held programs the driver needs minutes for, every translating thread waited for a slot and the run stopped moving: a retail pack of 26 503 shaders sat at 22 800 for many minutes with about 3.5 cores busy, two driver compiles at about 6 CPU-minutes each. This PR moves the driver's compiles to their own threads and orders them by size and free memory. No issue is linked. **What is in it** - One commit, `crates/xcl/src/shaders.rs` only (314 added, 25 removed). - The driver's compiles run on their own threads, fed by a queue (`BiggestFirst`, at most 2 GB of DXIL waiting). The translating threads go on and fill the DXIL cache meanwhile. - Each driver thread takes the biggest program whose compile fits in free memory (`driver_fits`): the big ones start first, the threads left over make small ones. A program is taken to need 1536 bytes per byte of DXIL, between 64 MB and 1.5 GB, with 2 GB kept free. - Driver threads: half the cores (at most 16) with memory watched. `XCL_PIPELINE_THREADS` still works: that many at once, memory not watched. - Output: a status line every 15 s and a line for each pipeline the driver took more than 60 s for, instead of one line every 25 pipelines. - Unit tests for the queue (order, byte limit, closing, biggest that fits) and for the memory rule. - The translation, the DXIL and the pipelines made are unchanged; only their order and how many are made at once change. **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1714), AMD Ryzen 9 7950X, 32 GB, Windows 11 10.0.26100, rustc 1.98.0, debug. - `cargo test --workspace -- --test-threads=4` on ed5322f with no uncommitted changes: 656 passed, 0 failed, 40 ignored (SKIPPED GPU tests: 2, both "no wave64": `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`). The `XCL_SAMPLE_*` variables were not set, so the tests on game data did nothing. - `cargo test -p xcl --release --lib` on ed5322f: 616 passed, 0 failed, 20 ignored. **Regression run** Not run. `scripts/smoke.ps1` was not run on main or on this PR, so there are no `xcl-smoke` blocks. main: PR: **Not tested** - No regression run on a real title (see above). The change is in `xcl shaders --precompile` only; `xcl run` does not call it. - No timed whole `--precompile --pipelines` run with this version, so no before / after numbers. An earlier version (strictly biggest first, every running compile counted as 1.5 GB) was run on the retail pack: seven big programs took the whole memory allowance and nothing else was made meanwhile. The "biggest that fits" rule is the answer to that and has unit tests only. - The memory numbers come from the comment that was there and from this one NVIDIA machine. Not tested on AMD or Intel GPUs. - The branch is on 7a033c8, not rebased onto the newest main, and the commit subject is longer than 72 characters. **AI use** Claude Code. Claude Opus 5.5 wrote the first version of the change; Claude Fable 5.2 wrote the final code, the unit tests, the commit message and this description, and ran the tests listed above.
upstream-sync closed this pull request 2026-11-24 06:57:52 +00:00

Pull request closed

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!253
No description provided.