Repository navigation
Shaders: precompile --pipelines compiles in the driver on its own threads - #256
Closed
1984742628 wants to merge 1 commit into
Closed
1984742628 wants to merge 1 commit into
1984742628 wants to merge 1 commit into
Conversation
…biggest program that fits in memory first `xcl shaders --precompile --pipelines` made each compute pipeline on the thread that translated it, at most four at once. With the four slots taken by programs the driver needs minutes for, every translating thread ended up waiting for a slot: a retail pack sat at 22 800 / 26 503 for many minutes with about 3.5 cores busy, and in file order a big program could come last and compile alone. - The driver's compiles run on their own threads, fed by a queue; the translating threads go on and fill the DXIL cache meanwhile. The queue holds at most 2 GB of DXIL. - Each driver thread takes the biggest program whose compile fits in the memory that is free: the big ones start first, the threads left over make small ones instead of waiting. 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, or XCL_PIPELINE_THREADS as before (that many at once, memory not watched). - A status line every 15 s (made, refused, in the driver with the longest-running one, waiting), and a line for each pipeline the driver took more than 60 s for. The line every 25 pipelines said nothing for minutes. The translation, the DXIL and the pipelines made are the same: only their order and how many are made at once change. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 23, 2026
wondercrash
added a commit
to wondercrash/xcl
that referenced
this pull request
Nov 24, 2026
…eads The compute warm-up (`xcl shaders --precompile --only cs --pipelines`) sat for 20+ minutes at one record range with ~5 cores busy: each translating thread made its pipeline itself behind a gate of XCL_PIPELINE_THREADS (4), and three retail programs of 13-28 MB DXIL held 3 slots for 15+ CPU-minutes each. The other 13 translating threads each held a finished program waiting for the one slot left, and the DXC pool sat idle. Port of xcl-dev#256 onto the driver cache of xcl-dev#744: - A program whose driver blob is cached is made from it on the translating thread (a cheap create, no slot). The rest go to a queue served by driver threads of their own, XCL_PIPELINE_THREADS or half the logical CPUs. A push never waits: the queue holds the DXIL (a pack's compute programs come to a few GB at most). - Each driver thread takes the biggest waiting program that fits: 8 GB of commit and memory kept free, a compile counted as 1536 bytes per DXIL byte (64 MB - 1.5 GB), 3 GB for one over 8 MB; with nothing running any may go. - At most 2 programs over 8 MB at once, and one thread always left for the rest, so huge programs never hold every driver thread. - A status line every 15 s while compiles run; programs over 60 s are named. Assisted-by: omp (Claude Opus 5.5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xcl shaders --precompile --pipelinesmade 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
crates/xcl/src/shaders.rsonly (314 added, 25 removed).BiggestFirst, at most 2 GB of DXIL waiting). The translating threads go on and fill the DXIL cache meanwhile.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.XCL_PIPELINE_THREADSstill works: that many at once, memory not watched.Tested
cargo test --workspace -- --test-threads=4on 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). TheXCL_SAMPLE_*variables were not set, so the tests on game data did nothing.cargo test -p xcl --release --libon ed5322f: 616 passed, 0 failed, 20 ignored.Regression run
Not run.
scripts/smoke.ps1was not run on main or on this PR, so there are noxcl-smokeblocks.main:
PR:
Not tested
xcl shaders --precompileonly;xcl rundoes not call it.--precompile --pipelinesrun 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.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.