Repository navigation
Faster shader compiles: one window switch per four dwords, every core, --precompile builds the cache titles use - #113
Merged
Conversation
…ches for loads With a title's unified memory every access to it is a switch between the four windows (xcl_m*), and HLSL 2021's ?: is a branch. Scalar loads made one switch and one branch per dword (an s_load_dwordx8 of a descriptor: 8 switches), and every vector load, image result and interpolation sat in an if (exec). - s_load: Load4 / Load2 for the contiguous dwords - s_buffer_load / buffer_load: bounds checks as selects; a dword out of range or of an inactive lane reads offset 0 (always in the window) and is dropped; four dwords share one switch (xcl_loadx4) - ld_raw: one Load4 + one Load, no branch - image results, v_interp, s_cselect / s_cmov / s_ff1 / s_flbit / v_bfm / DPP lane sources: select instead of if / ?: A 1 % sample of a retail pack (253 programs) translated as a title translates them (4 windows): DXC 771 s -> 424 s of CPU, the slowest program 130 s -> 33 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DXC and the PSO workers were capped at 6 threads for memory. A retail pack's biggest translations now take about 0.7 GB in DXC (typical 0.1-0.3 GB). wait_for_memory now wants 6 GB of commit plus 1 GB per compile already running before it lets one more in at once. XCL_DXC_THREADS sets the count. The workers stay at normal priority: a title thread can wait for a pipeline (resolve_wait, a compute pipeline's first bind) and must not wait behind its own threads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The DXIL cache is keyed by the HLSL. --precompile translated with one memory window and no split wave64 form; a title translates VS / PS / CS with its four windows (pso::mem_windows) and, on a GPU with 32-lane waves, compute in the split form, so it compiled everything again. --windows N and --split 0|1 override. Also for measuring DXC on a pack: XCL_DUMP_HLSL=<dir> (with --recomp) writes every XCL_DUMP_EVERY-th complete translation, XCL_RECOMP_WINDOWS translates with that many windows, XCL_RECOMP_ONLY=<hash> translates one program. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Foniass
force-pushed
the
t3/faster-shader-compile
branch
from
November 23, 2026 12:46
500f4d2 to
517d983
Compare
Collaborator
|
Merged (f311ca5) – great work, thanks. Checked on an RX 9070 (16 threads), DXC from SDK 10.0.26100, same random sample (seed 12345, 1 in 100 records, 258 variants) translated with 4 windows (
|
Contributor
Author
|
One more measurement: the NVIDIA driver's own compile (pipeline creation) next to DXC's, on the 1 % random sample's 137 compute programs. These are CS plus the compute halves of MS, translated as on a 32-lane GPU (4 windows, split wave64). Times are single-threaded on an RTX 5070 Ti, driver 621.14.
|
hexgeon1
added a commit
to hexgeon1/xcl
that referenced
this pull request
Nov 23, 2026
…de after a minute `wait_for_memory` (xcl-dev#113) let a compile start with 6 GB of commit left plus 1 GB per compile already running. The available commit already excludes what the running compiles use, so that counted them twice: on a desktop with 8.1 GB of commit free (a browser and chat open) about three compiles ran and the other workers polled. - `may_start`: in at once while commit covers 6 GB + 300 MB per running compile (their growth still to come; a typical retail compile peaks at 0.1-0.3 GB per xcl-dev#113's measurements); with less, one at a time. - After a minute's wait a compile still goes in when commit is short, but one per minute; before, every waiting worker went in at once - when commit was shortest. - The running count only rises from the value the decision saw (compare and swap), so workers deciding on the same reading cannot all go in. - Waiters wake when a compile ends (condition variable) instead of polling every 50 ms. Minecraft Preview's 716 programs, 4 memory windows, 15 threads (default), Ryzen 7 5700X, 8.1 GB of commit free, main and this interleaved, 3 runs each: 12.7-15.2 s -> 6.35-6.71 s wall (5.3-5.6 s with no gate at all); DXIL digest identical. Tests: `gate_tests` (the rule, short commit / one escape per interval, 32 threads never exceeding what the commit allows); `cargo test --workspace --release` green on an RTX 3090 with the Agility SDK (0 GPU skips). Driver PSO compiles are still not gated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Shader compile time. A title's ~24 000 shaders took 30–40 min, so I looked at where DXC spends its time. Measured with the retail
shaders.rpf, translated the way a title translates them.What was slow
memaccess is a[branch] switchbetween the 4 windows (xcl_m*), and the translator emitted one per dword. Ans_load_dwordx8of a descriptor was 8 switches, and ans_buffer_load_dwordx16was 16 switches plus 16?:branches (HLSL 2021's?:is a branch). In a 1 % random sample (253 programs), 88 % of the switches came from scalar loads. Translated the way a title translates them (4 windows), the same programs took DXC 2.3× as long as with one window, and the slowest went from 24 s to 130 s.MAX_COMPILE_THREADS = 6capped DXC and the PSO workers. A 16-thread CPU sat mostly idle.--precompilebuilt the wrong cache. The DXIL cache is keyed by the HLSL.--precompiletranslated with 1 window and no split wave64 form, but a title translates VS / PS / CS with its 4 windows (and on a 32-lane GPU, compute in the split form). So a title asked for other HLSL and compiled everything again.Changes
emit.rs):s_load:Load4/Load2for the contiguous dwords.s_buffer_loadandbuffer_load: bounds checks asselects. A dword that is out of range, or belongs to an inactive lane, reads offset 0 (always inside the window) and is discarded. Four dwords share one switch (xcl_loadx4).ld_raw: oneLoad4plus oneLoad, with no branch.v_interp,s_cselect/s_cmov/s_ff1/s_flbit,v_bfmand DPP lane sources:selectinstead ofif/?:.dxc.rs,pso_async.rs): every core but one (XCL_DXC_THREADSoverrides).wait_for_memorynow wants 6 GB of commit plus 1 GB per compile already running before it lets another start right away. Peak DXC commit on the pack's biggest translations is about 0.7 GB (typically 0.1–0.3 GB), so "gigabytes each" no longer holds. Priority stays normal: a title thread can wait for a pipeline (resolve_wait, a compute pipeline's first bind) and must not end up waiting behind its own threads. The driver compiles on thexcl-psoworkers are still not memory-gated.--precompile(shaders.rs): translates exactly aspsodoes: 4 windows for VS / PS / CS, 1 for MS, and the split form when the GPU runs only 32-lane waves.--windows Nand--split 0|1override. There are also measurement helpers:XCL_DUMP_HLSL=<dir>(with--recomp) writes everyXCL_DUMP_EVERY-th translation,XCL_RECOMP_WINDOWStranslates with that many windows, andXCL_RECOMP_ONLY=<hash>translates one program.Numbers (Ryzen 7 7800X3D, 8 cores / 16 threads, DXC 1.9.2602)
maindxc.exeCPU time (4 windows)--precompile, first 10 % of the pack (2 650 records), 4 windows, wall timemainmeasured 327 s and 378 s on two runs of the same slice, so wall-time differences of a few percent between runs are noise.Checked
cargo test --workspace --releaseon an RTX 5070 Ti: 527 passed, 0 failed (2no wave64skips, as onmain). The GPU tests also pass withXCL_SPLIT_WAVE64=1.gpu_grouped_loads_bounds_and_inactive_lanescovers an unaligneds_load_dwordx8,s_buffer_load_dwordx8/x16/x2straddlingnum_records, andbuffer_load_dwordx3(idxen) /x2(offen) with lanes past the end and inactive lanes that keep their registers.gpu_memory_windows_above_4_gibgains ans_buffer_load_dwordx4from window 1, which goes through the multi-windowxcl_loadx4.v_interpkeeps its(float)conversion as aselect, andps_interp_converts_integer_inputs_and_compilespasses.Found along the way, not in this PR
pcdispatcher, which costs DXC about 1.5× per instruction. Most of them are cold blocks that the console compiler placed after the program, which jump back into it. In address order those look like crossing loops. I have a layout pass that moves them next to their branch; it is not measured enough yet to propose.--precompilestill differs from the runtime in two places that predate this PR. A PS's static samplers start after its VS's at run time, but at 0 in--precompile. And the runtime builds the mesh pass-through for its pixel shader, while--precompilebuilds it without one.translate_mesh/translate_geometrytranslate with 1 memory window, while VS / PS / CS get the title's 4. Is it intended that NGG and GS programs only reach window 0?🤖 Generated with Claude Code