Compilation Time: DXC Compile Time Issues #293

Open
opened 2026-11-27 02:41:03 +00:00 by brcly · 19 comments
brcly commented 2026-11-27 02:41:03 +00:00 (Migrated from github.com)
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T02:41:03Z.


Hey guys,

I know we're all fighting compilation times on shaders.

The number 1 suspect for that atm is DXC.

image

Our validator and translator layer is really fast, fantastic.

But DXC, which is what TuxBox uses to compile the DirectX shaders, is what's stalling and causing extremely long compile times.

I'm gonna push a change to help increase the compilation time, but I also want to hear people's ideas on how we can increase the speed even further.

If it means a home grown system, so be it.

Right now TuxBox compiles shaders in this order:

Raw RDNA2 (provided by the game) -> HLSL (this is fast) -> DXIL (this is the slow DXC step) -> SPIR-V (linux only for VKD3D) -> GPU Driver

What would be more ideal is either

Raw RDNA2 -> DXIL -> Driver (Windows)
Raw RDNA2 -> SPIR-V -> Driver (Linux)

or

Raw RDNA2 -> HLSL -> DXIL -> Driver (Windows)
Raw RDNA2 -> HLSL -> SPIR-V -> Driver (Linux)

If someone could throw some tokens to get some ideas on the way forward, I'd like to know.

The long times seem to affect only compute shaders going through DXC.

So I propose that we maybe have a specific pipeline for compute shaders first.

<!-- greyfinch-sync:brcly/TuxBox:issue:6638836896 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293). Originally posted by [brcly](https://github.com/brcly) on 2026-11-27T02:41:03Z. --- Hey guys, I know we're all fighting compilation times on shaders. The number 1 suspect for that atm is DXC. <img width="477" height="175" alt="image" src="https://github.com/user-attachments/assets/a3d9d034-3e9d-4f05-90c6-0fed1fd0904b" /> Our validator and translator layer is really fast, fantastic. But DXC, which is what TuxBox uses to compile the DirectX shaders, is what's stalling and causing extremely long compile times. I'm gonna push a change to help increase the compilation time, but I also want to hear people's ideas on how we can increase the speed even further. If it means a home grown system, so be it. Right now TuxBox compiles shaders in this order: Raw RDNA2 (provided by the game) -> HLSL (this is fast) -> DXIL (this is the slow DXC step) -> SPIR-V (linux only for VKD3D) -> GPU Driver What would be more ideal is either Raw RDNA2 -> DXIL -> Driver (Windows) Raw RDNA2 -> SPIR-V -> Driver (Linux) or Raw RDNA2 -> HLSL -> DXIL -> Driver (Windows) Raw RDNA2 -> HLSL -> SPIR-V -> Driver (Linux) If someone could throw some tokens to get some ideas on the way forward, I'd like to know. The long times seem to affect only compute shaders going through DXC. So I propose that we maybe have a specific pipeline for compute shaders first.
NickStallman commented 2026-11-27 02:59:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T02:59:54Z.


I'll take this on. Some context from what I measured for #229: on the host, DXC is 97.5% of CPU, and the slowest 10% of requests take 76% of that, mostly in LLVM Jump Threading. The 30-minute cold run itself looked limited by the driver stage (638 large compute pipelines through 4 slots), but that is inferred from one log on driver 595, so the first job is a per-stage baseline on 620.

I'm running these in parallel, compute first, and will post numbers here:

  1. Per-stage baseline for the compute set: xshader, DXC, DXV, dxil-spirv, driver.
  2. DXC flags and passes per target, including what each does to dxil-spirv time.
  3. Which shapes in the emitted HLSL cost DXC the most. Measurements only; I'll stay out of your simplification work.
  4. Home-grown DXIL (RDNA2 → DXIL, no DXC): a small writer spike validated with dxv and on the GPU, how much optimising our own emitter would need so dxil-spirv and the driver don't get slower, and a size estimate. Nothing changes downstream, and it would serve Windows too.
  5. Home-grown SPIR-V: first HLSL → SPIR-V with DXC's SPIR-V backend, then how SPIR-V could reach the driver without patching Proton, then RDNA2 → SPIR-V without HLSL.
  6. Large-compile slots against memory on a 5090; results go to #236.

For 4 and 5: xshader has no IR between the decoder and the HLSL text, so I'll size both honestly before building anything past a spike.

Anything that overlaps the change you're pushing, tell me and I'll drop it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7208610997 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7208610997). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T02:59:54Z. --- I'll take this on. Some context from what I measured for #229: on the host, DXC is 97.5% of CPU, and the slowest 10% of requests take 76% of that, mostly in LLVM Jump Threading. The 30-minute cold run itself looked limited by the driver stage (638 large compute pipelines through 4 slots), but that is inferred from one log on driver 595, so the first job is a per-stage baseline on 620. I'm running these in parallel, compute first, and will post numbers here: 1. Per-stage baseline for the compute set: xshader, DXC, DXV, dxil-spirv, driver. 2. DXC flags and passes per target, including what each does to dxil-spirv time. 3. Which shapes in the emitted HLSL cost DXC the most. Measurements only; I'll stay out of your simplification work. 4. Home-grown DXIL (RDNA2 → DXIL, no DXC): a small writer spike validated with dxv and on the GPU, how much optimising our own emitter would need so dxil-spirv and the driver don't get slower, and a size estimate. Nothing changes downstream, and it would serve Windows too. 5. Home-grown SPIR-V: first HLSL → SPIR-V with DXC's SPIR-V backend, then how SPIR-V could reach the driver without patching Proton, then RDNA2 → SPIR-V without HLSL. 6. Large-compile slots against memory on a 5090; results go to #236. For 4 and 5: xshader has no IR between the decoder and the HLSL text, so I'll size both honestly before building anything past a spike. Anything that overlaps the change you're pushing, tell me and I'll drop it.
akimfomin commented 2026-11-27 02:59:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by akimfomin on 2026-11-27T02:59:55Z.


For the DXC question, Xbox2Windows already publishes a title-free compiler control. PortBridge measured 1.294 s median on its 2,048-branch sampling variant, with the compiler revision and the other variants recorded. It is a pixel-shader calibration and TuxBox's compute bottleneck remains an open question. Pinned generator · Archived method and results

When your next compute change is ready, would you nominate one generated shader or public test PR for a second timing through PortBridge? A volunteer can report DXC wall time separately from native pipeline creation and return the compiler version, revision and aggregates here.

<!-- greyfinch-sync:brcly/TuxBox:comment:7208611365 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7208611365). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-27T02:59:55Z. --- For the DXC question, Xbox2Windows already publishes a title-free compiler control. PortBridge measured 1.294 s median on its 2,048-branch sampling variant, with the compiler revision and the other variants recorded. It is a pixel-shader calibration and TuxBox's compute bottleneck remains an open question. [Pinned generator](https://github.com/R0Y00/Xbox2Windows/blob/721dc1d97f02207ab4a6d74f8d3394f942b303c4/tools/dxc_compile_time.py) · [Archived method and results](https://github.com/akimfomin/PortBridge/tree/main/research/shader-tail-factoring) When your next compute change is ready, would you nominate one generated shader or public test PR for a second timing through [PortBridge](https://github.com/akimfomin/PortBridge/issues/112)? A volunteer can report DXC wall time separately from native pipeline creation and return the compiler version, revision and aggregates here.
brcly commented 2026-11-27 03:16:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T03:16:54Z.


Before committing to anything, I'm going to simplify the computer shaders where possible.

If I manage a break through, I'll update

<!-- greyfinch-sync:brcly/TuxBox:comment:7208856664 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7208856664). Originally posted by [brcly](https://github.com/brcly) on 2026-11-27T03:16:54Z. --- Before committing to anything, I'm going to simplify the computer shaders where possible. If I manage a break through, I'll update
NickStallman commented 2026-11-27 03:27:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T03:27:40Z.


Per-stage baseline, CPU only, at 9168b2f with DXC 1.8.2505.1 and the dxil-spirv commit GE-Proton11-14 ships (34f0ff84, built standalone). Sample: 400 random cs_6_6, 150 cs_6_0, 100 of each other target, from the recorded ProjectScarlett requests, run through the same flag policy as compile_dxil. The GPU driver compile is not in here.

Mean CPU seconds per program (measured):

target n HLSL KB DXC DXV dxil-spirv DXC share
cs_6_6 400 879 8.37 0.034 0.63 92%
ms_6_6 100 128 1.70 0.010 0.14 92%
ps_6_6 100 255 1.32 0.010 0.06 92%
cs_6_0 150 62 0.17 0.005 0.01 90%

xshader is under 1% everywhere. So offline, DXC is the cost, as you suspected.

For cs_6_6 the cost is broad, not a few outliers (measured). This corrects what I said above from the earlier mixed sample: the slowest 10% take 33% of DXC time, and 40% of the programs cost over 10 s each (p50 2.1 s, p90 20 s, max 91 s). The programs with 1 to 4 MiB of HLSL carry 89% of it, and DXC's cost per byte is about nine times higher there than for small programs. DXC time tracks the block count of the output (r = 0.95) more closely than HLSL size (r = 0.85).

Scaled to all 24,800 translated programs (inferred from the sample): about 47,000 core-seconds of DXC, of which cs_6_6 is 22,500 (95% interval 19,900 to 25,100), ms_6_6 13,200 and ps_6_6 10,600; dxil-spirv is about 3,400.

Two side findings (measured):

  • A DXC timeout is costly twice. The two cs_6_6 programs that fell back to -O0 then took 17 s and 68 s in dxil-spirv (57k and 78k blocks), against a p99 of 2.9 s for -O1 output.
  • Both of those had 52 to 56 s of CPU inside the 60 s wall-clock limit, on a machine that was busy. The limit is wall time in the game too, so load during a launch can push large programs onto the -O0 path.

One early result from the home-grown DXIL test that bears on your simplification (measured, synthetic programs): dxil-spirv time grows faster than quadratically with basic blocks. For 16,000 masked register writes, DXC -O1 output had 4,000 blocks and took 1.2 s in dxil-spirv; the same writes expressed as selects were one block and took 0.23 s. I'm now testing whether emitting pure register writes as selects in the HLSL gives the same gain through DXC.

Flags, HLSL shapes and the two home-grown routes are still running.

<!-- greyfinch-sync:brcly/TuxBox:comment:7209005998 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7209005998). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T03:27:40Z. --- Per-stage baseline, CPU only, at 9168b2f with DXC 1.8.2505.1 and the dxil-spirv commit GE-Proton11-14 ships (34f0ff84, built standalone). Sample: 400 random `cs_6_6`, 150 `cs_6_0`, 100 of each other target, from the recorded ProjectScarlett requests, run through the same flag policy as `compile_dxil`. The GPU driver compile is not in here. **Mean CPU seconds per program (measured):** | target | n | HLSL KB | DXC | DXV | dxil-spirv | DXC share | |---|---:|---:|---:|---:|---:|---:| | cs_6_6 | 400 | 879 | 8.37 | 0.034 | 0.63 | 92% | | ms_6_6 | 100 | 128 | 1.70 | 0.010 | 0.14 | 92% | | ps_6_6 | 100 | 255 | 1.32 | 0.010 | 0.06 | 92% | | cs_6_0 | 150 | 62 | 0.17 | 0.005 | 0.01 | 90% | xshader is under 1% everywhere. So offline, DXC is the cost, as you suspected. **For `cs_6_6` the cost is broad, not a few outliers (measured).** This corrects what I said above from the earlier mixed sample: the slowest 10% take 33% of DXC time, and 40% of the programs cost over 10 s each (p50 2.1 s, p90 20 s, max 91 s). The programs with 1 to 4 MiB of HLSL carry 89% of it, and DXC's cost per byte is about nine times higher there than for small programs. DXC time tracks the block count of the output (r = 0.95) more closely than HLSL size (r = 0.85). **Scaled to all 24,800 translated programs (inferred from the sample):** about 47,000 core-seconds of DXC, of which `cs_6_6` is 22,500 (95% interval 19,900 to 25,100), `ms_6_6` 13,200 and `ps_6_6` 10,600; dxil-spirv is about 3,400. Two side findings (measured): - A DXC timeout is costly twice. The two `cs_6_6` programs that fell back to `-O0` then took 17 s and 68 s in dxil-spirv (57k and 78k blocks), against a p99 of 2.9 s for `-O1` output. - Both of those had 52 to 56 s of CPU inside the 60 s wall-clock limit, on a machine that was busy. The limit is wall time in the game too, so load during a launch can push large programs onto the `-O0` path. One early result from the home-grown DXIL test that bears on your simplification (measured, synthetic programs): dxil-spirv time grows faster than quadratically with basic blocks. For 16,000 masked register writes, DXC `-O1` output had 4,000 blocks and took 1.2 s in dxil-spirv; the same writes expressed as selects were one block and took 0.23 s. I'm now testing whether emitting pure register writes as selects in the HLSL gives the same gain through DXC. Flags, HLSL shapes and the two home-grown routes are still running.
gtb-sbe commented 2026-11-27 03:28:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-27T03:28:08Z.


@NickStallman A data point from AMD, and from after the startup phase, in case it helps with 1 and 2. It's one run, so the numbers are samples, not a baseline.

Setup: RX 9060 XT (RADV GFX1200, Mesa 26.2.6), Ryzen 7 5800X (16 threads), 31 GB, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline at 3840x2160, #258 d50a51c on 12e4b06, no preload, Linux DXC 1.10.2605.37. The translator had changed since the previous run, so every request was translated live; nothing was prepared.

Startup (first ~8 min): about 9,000 requests the title had already made in earlier runs, at about 1,100 per minute. All 150 compute CreatePipelineState ... finished in lines (5-9 s) are from these minutes.

After the Account Picker (~65 min, loading at 3 draws per frame): about 5,900 requests no earlier run had reached, at 60-400 per minute, usually 100-150. The slow pipelines in this phase are all mesh + pixel (84 lines, mean 6.3 s, max 8 s); no compute.

Two 60 s samples of the live worker in that phase (ps every 0.5 s, so durations are lower bounds). The worker had 8 slots (up to 8 concurrent requests) and was never full.

UTC requests in flight, mean / max DXC processes, mean / max xshader idle CPU DXC jobs
02:54 3.5 / 5 3.3 / 5 0.04 49% ms_6_6 30 (mean >= 3.0 s, max >= 11 s); ps_6_6 -disable-lifetime-markers 59 (mean >= 1.8 s, max >= 4.5 s)
03:20 0.8 / 4 0.7 / 4 0.00 74% ms_6_6 31 (mean >= 1.0 s, max >= 3.0 s); pixel 8

What I read from it:

  • In this phase the title has only a few pipeline creations in flight, and each waits for its own translation. More slots would not help here. Shorter per-request latency, or translating before the title asks, would.
  • DXC is nearly all of the translator's time; xshader and DXV barely show up.
  • Mesh programs are the largest DXC cost here. Unless it is a dispatched program, ms_6_6 goes through DXC at default optimisation. It gets neither the -disable-lifetime-markers variant (dispatched programs and pixel programs of 256 KiB or more) nor the compute flags. Whether changing that would cost dxil-spirv or the driver more is open. Your item 2 would answer it.

Not measured: driver time separately from DXC, and the time from the title's call to the finished pipeline.

<!-- greyfinch-sync:brcly/TuxBox:comment:7209012119 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7209012119). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-27T03:28:08Z. --- @NickStallman A data point from AMD, and from after the startup phase, in case it helps with 1 and 2. It's one run, so the numbers are samples, not a baseline. **Setup:** RX 9060 XT (RADV GFX1200, Mesa 26.2.6), Ryzen 7 5800X (16 threads), 31 GB, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline at 3840x2160, #258 `d50a51c` on `12e4b06`, no preload, Linux DXC 1.10.2605.37. The translator had changed since the previous run, so every request was translated live; nothing was prepared. **Startup (first ~8 min):** about 9,000 requests the title had already made in earlier runs, at about 1,100 per minute. All 150 compute `CreatePipelineState ... finished in` lines (5-9 s) are from these minutes. **After the Account Picker (~65 min, loading at 3 draws per frame):** about 5,900 requests no earlier run had reached, at 60-400 per minute, usually 100-150. The slow pipelines in this phase are all mesh + pixel (84 lines, mean 6.3 s, max 8 s); no compute. Two 60 s samples of the live worker in that phase (`ps` every 0.5 s, so durations are lower bounds). The worker had 8 slots (`up to 8 concurrent requests`) and was never full. | UTC | requests in flight, mean / max | DXC processes, mean / max | xshader | idle CPU | DXC jobs | | --- | --- | --- | --- | --- | --- | | 02:54 | 3.5 / 5 | 3.3 / 5 | 0.04 | 49% | `ms_6_6` 30 (mean >= 3.0 s, max >= 11 s); `ps_6_6 -disable-lifetime-markers` 59 (mean >= 1.8 s, max >= 4.5 s) | | 03:20 | 0.8 / 4 | 0.7 / 4 | 0.00 | 74% | `ms_6_6` 31 (mean >= 1.0 s, max >= 3.0 s); pixel 8 | What I read from it: - In this phase the title has only a few pipeline creations in flight, and each waits for its own translation. More slots would not help here. Shorter per-request latency, or translating before the title asks, would. - DXC is nearly all of the translator's time; xshader and DXV barely show up. - Mesh programs are the largest DXC cost here. Unless it is a dispatched program, `ms_6_6` goes through DXC at default optimisation. It gets neither the `-disable-lifetime-markers` variant (dispatched programs and pixel programs of 256 KiB or more) nor the compute flags. Whether changing that would cost dxil-spirv or the driver more is open. Your item 2 would answer it. Not measured: driver time separately from DXC, and the time from the title's call to the finished pipeline.
NickStallman commented 2026-11-27 04:19:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T04:19:13Z.


Results on what in the emitted compute HLSL costs DXC, since that's what you're working on. cs_6_6, DXC 1.8.2505.1, -O1 -disable-lifetime-markers, CPU time; dxil-spirv is the GE-Proton11-14 commit built standalone. The machine was shared, so repeat runs vary by up to 1.6x: read these as ratios. Rewrites were scripted on real recorded programs and all outputs pass DXV, but nothing here was run on a GPU, and driver compile time is not measured.

1. ?: is a branch, not a select (measured). DXC defaults to HLSL 2021, where ?:, && and || on scalars short-circuit, and -O1 doesn't fold them back. select(c, a, b) gives a real DXIL select. Turning if (m) v = e; into v = m ? e : v; is worse than the if (2.6x the blocks). -HV 2018 alone gave −15 to −22% DXC time and −9 to −17% blocks on five programs, but is only safe if no emitted ?:/&&/|| relies on short-circuiting, which I haven't audited.

2. Pure masked register writes as select() (measured, six of the slowest programs). Only side-effect-free right-hand sides were rewritten; loads, stores, wave ops and atomics stayed under branches.

program variant DXC s blocks dxil-spirv s
8 MB, paired wave64 now 48–60 32,884 13.8–16.4
select() 37.4 10,491 1.94
select() + -HV 2018 24.0 7,672 1.61
677 skip flags now 44.8 16,777 6.57
select() + -HV 2018 29.6 8,779 2.81
dispatcher now 25.0 9,674 1.55
select() + -HV 2018 16.5 4,662 0.69

Across the six: blocks −35 to −68%, dxil-spirv −40 to −88%, DXC −38% to +15%. One program with 95 loops got slower in DXC (51 → 104 s, all in InstCombine); I don't know why yet. [flatten] on the same ifs changes nothing.

3. Small [noinline] functions cut DXC time 6–10x (measured, three programs). Registers as static uint globals, each dispatcher block or guard body as a [noinline] void f():

program variant DXC s blocks DXIL KB dxil-spirv s
loops + skip flags now 38.5 8,324 595 1.87
outlined + select() 5.0 6,072 1,130 0.81
677 skip flags now 56.7 16,777 914 6.29
outlined + select() 7.3 12,258 1,630 2.50
dispatcher now 25.0 9,051 665 1.34
outlined 4.0 10,912 886 3.69

This is the largest effect, and the least proven: the DXIL is 33–80% larger because registers become memory, and the driver then has to inline and promote them, so driver time and runtime speed could get worse. Function size matters (32,000 synthetic instructions: 3.8 s in 400 functions, 54.5 s in 8). Without [noinline] DXC inlines everything and nothing changes. [noinline] with an inout struct fails validation in a compute target. Compiling as libraries and linking gave no gain.

4. A scoped temporary across a guard is super-quadratic (measured on synthetic; inferred for the real programs). { uint r = v; if (m) r = e; v = r; }, which the paired-wave64 form emits tens of thousands of times in the 8 MB programs, costs 33.7 s in Dxil Conditional Mem2Reg at 16,000 writes against 2.2 s for writing the register directly.

5. Loops that carry skip flags scale worst (measured, synthetic). 8,000 instructions and 400 flags: 6.4 s with no loops, 20.7 s with 40, 77.6 s with 100 (loop canonicalisation).

No effect: comments and text volume (the front end is 1–4%), nesting depth, scalars versus an array for registers, [flatten]. || in place of | in guards costs 30–45%, as you already found.

Overall DXC time goes as instructions^1.46 on 300 random programs, and no single text feature predicts it better than size, so keeping functions and straight-line runs small is what helps.

Home-grown routes, short version (details to follow):

  • RDNA2 → DXIL: a 1,100-line writer with its own container hash works: dxv accepts it and it passes the Lanes wave64-shader scenario on AMD. The cost is the translator behind it, estimated at 20,000 to 28,000 lines for compute, because the lowering is tied to HLSL text.
  • HLSL → SPIR-V with dxc -spirv: not viable. It was 4x slower than DXC + dxil-spirv on compute and segfaulted on 59 of 150 programs, including all the large ones.
  • RDNA2 → SPIR-V: VKD3D_SHADER_OVERRIDE accepts our SPIR-V with no Proton patch (shown for one compute shader on RADV), but it's a debug feature, needs vkd3d-proton's private binding layout, and loses [WaveSize]. It only removes dxil-spirv, which is 7% of the CPU.

The synthetic generator has no game content; I can put it in a PR or gist if it's useful. @gtb-sbe: the per-target flag table for ms_6_6 and ps_6_6, with the dxil-spirv cost, is still running.

<!-- greyfinch-sync:brcly/TuxBox:comment:7209702132 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7209702132). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T04:19:13Z. --- Results on what in the emitted compute HLSL costs DXC, since that's what you're working on. `cs_6_6`, DXC 1.8.2505.1, `-O1 -disable-lifetime-markers`, CPU time; dxil-spirv is the GE-Proton11-14 commit built standalone. The machine was shared, so repeat runs vary by up to 1.6x: read these as ratios. Rewrites were scripted on real recorded programs and all outputs pass DXV, but **nothing here was run on a GPU**, and driver compile time is not measured. **1. `?:` is a branch, not a select (measured).** DXC defaults to HLSL 2021, where `?:`, `&&` and `||` on scalars short-circuit, and `-O1` doesn't fold them back. `select(c, a, b)` gives a real DXIL `select`. Turning `if (m) v = e;` into `v = m ? e : v;` is worse than the `if` (2.6x the blocks). `-HV 2018` alone gave −15 to −22% DXC time and −9 to −17% blocks on five programs, but is only safe if no emitted `?:`/`&&`/`||` relies on short-circuiting, which I haven't audited. **2. Pure masked register writes as `select()` (measured, six of the slowest programs).** Only side-effect-free right-hand sides were rewritten; loads, stores, wave ops and atomics stayed under branches. | program | variant | DXC s | blocks | dxil-spirv s | |---|---|---:|---:|---:| | 8 MB, paired wave64 | now | 48–60 | 32,884 | 13.8–16.4 | | | `select()` | 37.4 | 10,491 | 1.94 | | | `select()` + `-HV 2018` | 24.0 | 7,672 | 1.61 | | 677 skip flags | now | 44.8 | 16,777 | 6.57 | | | `select()` + `-HV 2018` | 29.6 | 8,779 | 2.81 | | dispatcher | now | 25.0 | 9,674 | 1.55 | | | `select()` + `-HV 2018` | 16.5 | 4,662 | 0.69 | Across the six: blocks −35 to −68%, dxil-spirv −40 to −88%, DXC −38% to +15%. One program with 95 loops got slower in DXC (51 → 104 s, all in InstCombine); I don't know why yet. `[flatten]` on the same ifs changes nothing. **3. Small `[noinline]` functions cut DXC time 6–10x (measured, three programs).** Registers as `static uint` globals, each dispatcher block or guard body as a `[noinline] void f()`: | program | variant | DXC s | blocks | DXIL KB | dxil-spirv s | |---|---|---:|---:|---:|---:| | loops + skip flags | now | 38.5 | 8,324 | 595 | 1.87 | | | outlined + `select()` | 5.0 | 6,072 | 1,130 | 0.81 | | 677 skip flags | now | 56.7 | 16,777 | 914 | 6.29 | | | outlined + `select()` | 7.3 | 12,258 | 1,630 | 2.50 | | dispatcher | now | 25.0 | 9,051 | 665 | 1.34 | | | outlined | 4.0 | 10,912 | 886 | 3.69 | This is the largest effect, and the least proven: the DXIL is 33–80% larger because registers become memory, and the driver then has to inline and promote them, so driver time and runtime speed could get worse. Function size matters (32,000 synthetic instructions: 3.8 s in 400 functions, 54.5 s in 8). Without `[noinline]` DXC inlines everything and nothing changes. `[noinline]` with an `inout` struct fails validation in a compute target. Compiling as libraries and linking gave no gain. **4. A scoped temporary across a guard is super-quadratic (measured on synthetic; inferred for the real programs).** `{ uint r = v; if (m) r = e; v = r; }`, which the paired-wave64 form emits tens of thousands of times in the 8 MB programs, costs 33.7 s in Dxil Conditional Mem2Reg at 16,000 writes against 2.2 s for writing the register directly. **5. Loops that carry skip flags scale worst (measured, synthetic).** 8,000 instructions and 400 flags: 6.4 s with no loops, 20.7 s with 40, 77.6 s with 100 (loop canonicalisation). **No effect:** comments and text volume (the front end is 1–4%), nesting depth, scalars versus an array for registers, `[flatten]`. `||` in place of `|` in guards costs 30–45%, as you already found. Overall DXC time goes as instructions^1.46 on 300 random programs, and no single text feature predicts it better than size, so keeping functions and straight-line runs small is what helps. **Home-grown routes, short version (details to follow):** - RDNA2 → DXIL: a 1,100-line writer with its own container hash works: dxv accepts it and it passes the Lanes `wave64-shader` scenario on AMD. The cost is the translator behind it, estimated at 20,000 to 28,000 lines for compute, because the lowering is tied to HLSL text. - HLSL → SPIR-V with `dxc -spirv`: not viable. It was 4x slower than DXC + dxil-spirv on compute and segfaulted on 59 of 150 programs, including all the large ones. - RDNA2 → SPIR-V: `VKD3D_SHADER_OVERRIDE` accepts our SPIR-V with no Proton patch (shown for one compute shader on RADV), but it's a debug feature, needs vkd3d-proton's private binding layout, and loses `[WaveSize]`. It only removes dxil-spirv, which is 7% of the CPU. The synthetic generator has no game content; I can put it in a PR or gist if it's useful. @gtb-sbe: the per-target flag table for `ms_6_6` and `ps_6_6`, with the dxil-spirv cost, is still running.
NickStallman commented 2026-11-27 07:03:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T07:03:58Z.


@gtb-sbe: the per-target flag table. Short version: ms_6_6 should get -disable-lifetime-markers too; ps_6_6 is already covered by the existing rule.

Measured, CPU seconds summed over the sample, one core per job, DXC 1.8.2505.1, dxil-spirv at the GE-Proton11-14 commit built standalone. The machine was shared, so sums carry noise; the first three rows of each table were run interleaved per program. ">15 s" counts programs over the production DXC limit, which fall back to -O0 today.

ms_6_6, random 100 (none of these get the flag today)

flags DXC p99 >15 s DXIL blocks dxil-spirv
default 146.7 22.1 3 131,343 6.2
-disable-lifetime-markers 69.9 8.1 0 144,596 6.9
-O1 -disable-lifetime-markers 68.3 7.3 0 144,870 6.9
-O0 131.1 14.0 0 330,210 38.2

ms_6_6, largest 40 by HLSL size (none get the flag today)

flags DXC p50 >15 s DXIL blocks dxil-spirv
default 737.6 18.5 28 295,793 27.6
-disable-lifetime-markers 198.0 4.9 0 300,464 29.2
-O1 -disable-lifetime-markers 199.9 4.7 0 302,556 29.4
-O0 495.6 12.1 1 805,038 231.9
  • The flag cuts DXC CPU by 52% on the random sample and 73% on the largest 40, and no program is left over 15 s.
  • It does not move the cost downstream: blocks +2% to +10%, dxil-spirv time inside noise.
  • 28 of the largest 40 exceed 15 s of CPU at default, so in a real run they pay the 15 s, then an -O0 compile, then about 7x the dxil-spirv time (231.9 s against about 30 s for these 40). That fallback is the expensive part, and the flag avoids it.
  • On the 10 slowest ms_6_6, Jump Threading is 72% of default DXC time. With the flag the pass is not scheduled at all (-Odump), and Dxil Conditional Mem2Reg becomes the largest at 30%.

ps_6_6

sample flags DXC >15 s dxil-spirv
random 100 default 813.6 8 17.3
random 100 -disable-lifetime-markers 94.2 0 5.1
random 100 -O1 -disable-lifetime-markers 83.4 0 5.1
largest 40 -disable-lifetime-markers 190.8 0 16.1
largest 40 -O1 -disable-lifetime-markers 175.0 0 16.4
  • The existing rule (dispatcher or ≥256 KiB) already gives the flag to 39 of the random 100 and all of the largest 40; the default row shows what it avoids. Two of the random 100 hit my 180 s cap at default, so the dxil-spirv column covers 98.
  • The 61 random programs still on default are small: 22.9 s in total against 12.3 s with the flag, slowest 1.5 s. Extending the flag to all ps_6_6 would be a small gain.
  • -O1 on top of the flag: nothing for ms_6_6, about −10% DXC for ps_6_6, same blocks and dxil-spirv time. An earlier, non-interleaved run showed a bigger -O1 gain that did not reproduce, so I'm treating it as load noise.

All outputs pass DXV in every variant. That is not proof they render the same: the flag changes the DXIL of every affected mesh shader, so it needs GPU checks on AMD and NVIDIA, which I have not run. Your run used DXC 1.10.2605.37; these numbers are from 1.8.2505.1 and I have not compared the two.

The cs_6_6 optimisation-level and pass-ablation runs are still going.

<!-- greyfinch-sync:brcly/TuxBox:comment:7212107948 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7212107948). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T07:03:58Z. --- @gtb-sbe: the per-target flag table. Short version: **`ms_6_6` should get `-disable-lifetime-markers` too; `ps_6_6` is already covered by the existing rule.** Measured, CPU seconds summed over the sample, one core per job, DXC 1.8.2505.1, dxil-spirv at the GE-Proton11-14 commit built standalone. The machine was shared, so sums carry noise; the first three rows of each table were run interleaved per program. ">15 s" counts programs over the production DXC limit, which fall back to `-O0` today. **`ms_6_6`, random 100** (none of these get the flag today) | flags | DXC | p99 | >15 s | DXIL blocks | dxil-spirv | |---|---:|---:|---:|---:|---:| | default | 146.7 | 22.1 | 3 | 131,343 | 6.2 | | `-disable-lifetime-markers` | 69.9 | 8.1 | 0 | 144,596 | 6.9 | | `-O1 -disable-lifetime-markers` | 68.3 | 7.3 | 0 | 144,870 | 6.9 | | `-O0` | 131.1 | 14.0 | 0 | 330,210 | 38.2 | **`ms_6_6`, largest 40 by HLSL size** (none get the flag today) | flags | DXC | p50 | >15 s | DXIL blocks | dxil-spirv | |---|---:|---:|---:|---:|---:| | default | 737.6 | 18.5 | 28 | 295,793 | 27.6 | | `-disable-lifetime-markers` | 198.0 | 4.9 | 0 | 300,464 | 29.2 | | `-O1 -disable-lifetime-markers` | 199.9 | 4.7 | 0 | 302,556 | 29.4 | | `-O0` | 495.6 | 12.1 | 1 | 805,038 | 231.9 | - The flag cuts DXC CPU by 52% on the random sample and 73% on the largest 40, and no program is left over 15 s. - It does not move the cost downstream: blocks +2% to +10%, dxil-spirv time inside noise. - 28 of the largest 40 exceed 15 s of CPU at default, so in a real run they pay the 15 s, then an `-O0` compile, then about 7x the dxil-spirv time (231.9 s against about 30 s for these 40). That fallback is the expensive part, and the flag avoids it. - On the 10 slowest `ms_6_6`, Jump Threading is 72% of default DXC time. With the flag the pass is not scheduled at all (`-Odump`), and Dxil Conditional Mem2Reg becomes the largest at 30%. **`ps_6_6`** | sample | flags | DXC | >15 s | dxil-spirv | |---|---|---:|---:|---:| | random 100 | default | 813.6 | 8 | 17.3 | | random 100 | `-disable-lifetime-markers` | 94.2 | 0 | 5.1 | | random 100 | `-O1 -disable-lifetime-markers` | 83.4 | 0 | 5.1 | | largest 40 | `-disable-lifetime-markers` | 190.8 | 0 | 16.1 | | largest 40 | `-O1 -disable-lifetime-markers` | 175.0 | 0 | 16.4 | - The existing rule (dispatcher or ≥256 KiB) already gives the flag to 39 of the random 100 and all of the largest 40; the default row shows what it avoids. Two of the random 100 hit my 180 s cap at default, so the dxil-spirv column covers 98. - The 61 random programs still on default are small: 22.9 s in total against 12.3 s with the flag, slowest 1.5 s. Extending the flag to all `ps_6_6` would be a small gain. - `-O1` on top of the flag: nothing for `ms_6_6`, about −10% DXC for `ps_6_6`, same blocks and dxil-spirv time. An earlier, non-interleaved run showed a bigger `-O1` gain that did not reproduce, so I'm treating it as load noise. All outputs pass DXV in every variant. That is not proof they render the same: the flag changes the DXIL of every affected mesh shader, so it needs GPU checks on AMD and NVIDIA, which I have not run. Your run used DXC 1.10.2605.37; these numbers are from 1.8.2505.1 and I have not compared the two. The `cs_6_6` optimisation-level and pass-ablation runs are still going.
NickStallman commented 2026-11-27 08:03:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T08:03:43Z.


The DXC flag and pass run for cs_6_6 finished. One flag is worth a look: -fnew-inlining-behavior on top of the current -O1 -disable-lifetime-markers cut cs_6_6 DXC CPU by about a third.

Measured, CPU time, DXC 1.8.2505.1, dxil-spirv at the GE-Proton11-14 commit built standalone, shared machine; ratios come from runs that interleave the variants per program.

-fnew-inlining-behavior, ratio to the flags used today

set DXC CPU dxil-spirv CPU
cs_6_6 random 150 0.62 0.81
cs_6_6 30 slowest 0.66 0.84
ps_6_6 random 100 / largest 40 0.71 / 0.66 0.89 / 0.89
ms_6_6 random 100 / largest 40 (with the lifetime flag) 1.04 / 0.82 1.00 / 1.00
  • Every output passes DXV. On 10 slow programs, Dxil Conditional Mem2Reg fell from 164.5 s to 58.7 s.
  • Why it helps is inferred: locals are promoted per function before inlining, not afterwards in one large CFG. I did not vary the HLSL to confirm that.
  • DXC's help labels the flag experimental, and nothing here was run on a GPU. It changes the DXIL of every program, so it needs AMD and NVIDIA checks.

Where DXC spends cs_6_6 time under today's flags (30 slowest of 206)

part share
Dxil Conditional Mem2Reg 41%
Value Propagation 12%
GVN 10%
LCSSA 9%
front end 3.6%
container emit and validation 2.5%
  • At default flags, Jump Threading is 55% of DXC time on the slowest cs_6_6, 72% on ms_6_6 and 89% on slow ps_6_6. -disable-lifetime-markers takes the pass out of the pipeline (-Odump no longer lists -sroa -simplify-inst -jump-threading).
  • -O0 is not a fast path for cs_6_6: 1.15x the DXC CPU of today's flags, 3.6x the blocks, 8x the dxil-spirv CPU.
  • Once lifetime markers are off, -O1, -O2 and -O3 are within noise, with identical block counts.
  • No help for cs_6_6: -opt-disable gvn (same DXC, 1.16x dxil-spirv), -Gfp (1.10x DXC, 2.05x dxil-spirv), -Gis, -res-may-alias, -Gfa -all-resources-bound, -Vd.
  • The stock binary cannot switch off Jump Threading, Mem2Reg or Value Propagation: -opt-disable accepts any name silently and only five names change the pipeline.

What the optimiser is needed for (36 cs_6_6 programs, stock libdxcompiler.so driven with edited -Odump pass lists; DXC not rebuilt)

  • simplifycfg accounts for the whole -O0 to -O1 block drop. Without the early instances, blocks go back to 3.6x and dxil-spirv to 8.3x. GVN, instcombine, SROA, SCCP, DCE and reassociate each move blocks by 5% or less.
  • A cut-down list (function-level mem2reg before inlining, the HLSL lowering passes, then gvn, loop-rotate, simplifycfg) took 0.24x the optimiser CPU with 1.05x blocks and 0.96x dxil-spirv CPU; 36 of 36 pass DXV. That is the ceiling for flag work: it needs the API, not the command line.
  • dxil-spirv crash: without a late loop-rotate, the standalone converter segfaults on 12 of 36 programs whose DXIL passes DXV. The smallest has 781 blocks, and a 4 GB stack does not help. I have not checked whether the vkd3d-proton build in the game does the same.

Summary of flag changes the numbers support

target change DXC CPU downstream
ms_6_6 add -disable-lifetime-markers −52% to −73%, none over 15 s flat; avoids the -O0 fallback
cs_6_6 add -fnew-inlining-behavior −34% to −38% dxil-spirv −16% to −19%
ps_6_6 lifetime flag at all sizes −46% on the small programs, about 11 s per 100 flat
vs_6_6 lifetime flag for all −42% on non-dispatcher programs flat

Not done: -fnew-inlining-behavior on cs_6_0 and vs_6_6, driver compile time, and any GPU check. If you want any of these as a PR with AMD and NVIDIA runs, say which.

<!-- greyfinch-sync:brcly/TuxBox:comment:7213094880 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7213094880). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T08:03:43Z. --- The DXC flag and pass run for `cs_6_6` finished. One flag is worth a look: **`-fnew-inlining-behavior` on top of the current `-O1 -disable-lifetime-markers` cut `cs_6_6` DXC CPU by about a third.** Measured, CPU time, DXC 1.8.2505.1, dxil-spirv at the GE-Proton11-14 commit built standalone, shared machine; ratios come from runs that interleave the variants per program. **`-fnew-inlining-behavior`, ratio to the flags used today** | set | DXC CPU | dxil-spirv CPU | |---|---:|---:| | `cs_6_6` random 150 | 0.62 | 0.81 | | `cs_6_6` 30 slowest | 0.66 | 0.84 | | `ps_6_6` random 100 / largest 40 | 0.71 / 0.66 | 0.89 / 0.89 | | `ms_6_6` random 100 / largest 40 (with the lifetime flag) | 1.04 / 0.82 | 1.00 / 1.00 | - Every output passes DXV. On 10 slow programs, Dxil Conditional Mem2Reg fell from 164.5 s to 58.7 s. - Why it helps is inferred: locals are promoted per function before inlining, not afterwards in one large CFG. I did not vary the HLSL to confirm that. - DXC's help labels the flag experimental, and **nothing here was run on a GPU**. It changes the DXIL of every program, so it needs AMD and NVIDIA checks. **Where DXC spends `cs_6_6` time under today's flags (30 slowest of 206)** | part | share | |---|---:| | Dxil Conditional Mem2Reg | 41% | | Value Propagation | 12% | | GVN | 10% | | LCSSA | 9% | | front end | 3.6% | | container emit and validation | 2.5% | - At default flags, Jump Threading is 55% of DXC time on the slowest `cs_6_6`, 72% on `ms_6_6` and 89% on slow `ps_6_6`. `-disable-lifetime-markers` takes the pass out of the pipeline (`-Odump` no longer lists `-sroa -simplify-inst -jump-threading`). - `-O0` is not a fast path for `cs_6_6`: 1.15x the DXC CPU of today's flags, 3.6x the blocks, 8x the dxil-spirv CPU. - Once lifetime markers are off, `-O1`, `-O2` and `-O3` are within noise, with identical block counts. - No help for `cs_6_6`: `-opt-disable gvn` (same DXC, 1.16x dxil-spirv), `-Gfp` (1.10x DXC, 2.05x dxil-spirv), `-Gis`, `-res-may-alias`, `-Gfa -all-resources-bound`, `-Vd`. - The stock binary cannot switch off Jump Threading, Mem2Reg or Value Propagation: `-opt-disable` accepts any name silently and only five names change the pipeline. **What the optimiser is needed for** (36 `cs_6_6` programs, stock `libdxcompiler.so` driven with edited `-Odump` pass lists; DXC not rebuilt) - `simplifycfg` accounts for the whole `-O0` to `-O1` block drop. Without the early instances, blocks go back to 3.6x and dxil-spirv to 8.3x. GVN, instcombine, SROA, SCCP, DCE and reassociate each move blocks by 5% or less. - A cut-down list (function-level `mem2reg` before inlining, the HLSL lowering passes, then `gvn`, `loop-rotate`, `simplifycfg`) took 0.24x the optimiser CPU with 1.05x blocks and 0.96x dxil-spirv CPU; 36 of 36 pass DXV. That is the ceiling for flag work: it needs the API, not the command line. - **dxil-spirv crash:** without a late `loop-rotate`, the standalone converter segfaults on 12 of 36 programs whose DXIL passes DXV. The smallest has 781 blocks, and a 4 GB stack does not help. I have not checked whether the vkd3d-proton build in the game does the same. **Summary of flag changes the numbers support** | target | change | DXC CPU | downstream | |---|---|---|---| | `ms_6_6` | add `-disable-lifetime-markers` | −52% to −73%, none over 15 s | flat; avoids the `-O0` fallback | | `cs_6_6` | add `-fnew-inlining-behavior` | −34% to −38% | dxil-spirv −16% to −19% | | `ps_6_6` | lifetime flag at all sizes | −46% on the small programs, about 11 s per 100 | flat | | `vs_6_6` | lifetime flag for all | −42% on non-dispatcher programs | flat | Not done: `-fnew-inlining-behavior` on `cs_6_0` and `vs_6_6`, driver compile time, and any GPU check. If you want any of these as a PR with AMD and NVIDIA runs, say which.
gtb-sbe commented 2026-11-27 12:15:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-27T12:15:57Z.


@NickStallman Thanks, that explains the live numbers. After the picker the slowest jobs were ms_6_6 at default optimisation, and your largest-40 table shows why: 28 programs go over the 15 s limit, then -O0 and about 7x the dxil-spirv time.

Two things from this side:

  • In compile_dxil at 95480b5, the -disable-lifetime-markers candidate is not part of VARIANTS (dxil_store.py), so extending the rule to ms_6_6 would not start a new runtime cache. Mesh DXIL already cached stays as it is; only new compiles take the flag.
  • For the AMD check: when there is a branch, I can run it on the RX 9060 XT (RADV, Mesa 26.2.6). That would be the full python tuxbox.py check, then ProjectScarlett from a cold cache through the post-picker loading, sampled the same way as above, against the current rule. I have DXC 1.10.2605.37 installed, so it would also show whether the flag behaves the same on that version.

Is someone already opening the PR?

<!-- greyfinch-sync:brcly/TuxBox:comment:7218034270 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7218034270). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-27T12:15:57Z. --- @NickStallman Thanks, that explains the live numbers. After the picker the slowest jobs were `ms_6_6` at default optimisation, and your largest-40 table shows why: 28 programs go over the 15 s limit, then `-O0` and about 7x the dxil-spirv time. Two things from this side: - In `compile_dxil` at `95480b5`, the `-disable-lifetime-markers` candidate is not part of `VARIANTS` (`dxil_store.py`), so extending the rule to `ms_6_6` would not start a new runtime cache. Mesh DXIL already cached stays as it is; only new compiles take the flag. - For the AMD check: when there is a branch, I can run it on the RX 9060 XT (RADV, Mesa 26.2.6). That would be the full `python tuxbox.py check`, then ProjectScarlett from a cold cache through the post-picker loading, sampled the same way as above, against the current rule. I have DXC 1.10.2605.37 installed, so it would also show whether the flag behaves the same on that version. Is someone already opening the PR?
brcly commented 2026-11-29 21:58:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:58:26Z.


Status, since compile time and shader size are the current focus.

Landed: lifetime markers off for every profile; -fnew-inlining-behavior; structured control flow (#489, about −25% DXC on a sample); the slow-shader retry for every profile; the loop watchdog counted inside the body (−3.6% DXC on the slowest programs); #520, which removed the local arrays that put 21 KB a lane into the BVH walks (DXIL −7% on those).

Measured (DXC 1.9, recorded ProjectScarlett requests): about 2.7 CPU-hours of DXC for 34.7k requests, extrapolated from a 600-request sample. The slowest 5% of programs take half the time, and they're all large compute programs (13k–18k instructions). The HLSL is already close to one or two lines per instruction; the remaining DXC flag changes are worth 5–6% at most, and identical translations are already compiled once.

Next: fewer compiles, by recording pipelines and replaying them in preparation (#497), and driver time, which follows DXIL size.

One warning for anyone changing code generation: #523's output crashes DXC 1.9 with -fnew-inlining-behavior on about half the programs, so check new HLSL forms with the runtime's flags, not only DXC's defaults.

<!-- greyfinch-sync:brcly/TuxBox:comment:7263301355 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7263301355). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T21:58:26Z. --- Status, since compile time and shader size are the current focus. **Landed:** lifetime markers off for every profile; `-fnew-inlining-behavior`; structured control flow (#489, about −25% DXC on a sample); the slow-shader retry for every profile; the loop watchdog counted inside the body (−3.6% DXC on the slowest programs); #520, which removed the local arrays that put 21 KB a lane into the BVH walks (DXIL −7% on those). **Measured** (DXC 1.9, recorded ProjectScarlett requests): about 2.7 CPU-hours of DXC for 34.7k requests, extrapolated from a 600-request sample. The slowest 5% of programs take half the time, and they're all large compute programs (13k–18k instructions). The HLSL is already close to one or two lines per instruction; the remaining DXC flag changes are worth 5–6% at most, and identical translations are already compiled once. **Next:** fewer compiles, by recording pipelines and replaying them in preparation (#497), and driver time, which follows DXIL size. One warning for anyone changing code generation: #523's output crashes DXC 1.9 with `-fnew-inlining-behavior` on about half the programs, so check new HLSL forms with the runtime's flags, not only DXC's defaults.
NickStallman commented 2026-11-29 23:33:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T23:33:46Z.


A data point on the replay of recorded pipelines (#497), since it's part of the plan here. On an RTX 5090 (620.70.10, GE-Proton11-14, Linux, 32 threads), ProjectScarlett, a build on 007b982d with our PRs:

  • The prefix held 60,040 records (2.5 GB), written by about ten short runs of different builds within 75 minutes.
  • Preparation reported "11080 built for this translator, 2646 reused from the shader cache, 46313 replayed as recorded", then replayed them. pso_replay_guest.cpp does that on one thread. It ran at 98% of one core; after 10 minutes the driver cache had 258 MB, and I stopped it. A warm driver cache for this game is about 3.9 GB here, so I'd guess hours, but I didn't let it finish.
  • The launch waits for it. An empty TUXBOX_PIPELINE_RECIPES folder skips it.

Two questions: should records be capped or aged across runs as well as within one (the cap is per run), and could the replay use more than one thread? I haven't tried either. Most people won't collect records as fast as my tests do.

<!-- greyfinch-sync:brcly/TuxBox:comment:7264554324 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7264554324). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T23:33:46Z. --- A data point on the replay of recorded pipelines (#497), since it's part of the plan here. On an RTX 5090 (620.70.10, GE-Proton11-14, Linux, 32 threads), ProjectScarlett, a build on 007b982d with our PRs: - The prefix held 60,040 records (2.5 GB), written by about ten short runs of different builds within 75 minutes. - Preparation reported "11080 built for this translator, 2646 reused from the shader cache, 46313 replayed as recorded", then replayed them. `pso_replay_guest.cpp` does that on one thread. It ran at 98% of one core; after 10 minutes the driver cache had 258 MB, and I stopped it. A warm driver cache for this game is about 3.9 GB here, so I'd guess hours, but I didn't let it finish. - The launch waits for it. An empty `TUXBOX_PIPELINE_RECIPES` folder skips it. Two questions: should records be capped or aged across runs as well as within one (the cap is per run), and could the replay use more than one thread? I haven't tried either. Most people won't collect records as fast as my tests do.
brcly commented 2026-11-30 11:37:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T11:37:33Z.


@NickStallman, answers to both questions:

  • More than one thread: done in #579, merged today. TUXBOX_REPLAY_THREADS defaults to half the cores (2 to 8), and the overall limit is now 4 h (TUXBOX_REPLAY_TIMEOUT). @NathansDomainSolutions measured a full replay of 23,142 records at about 18 min on 8 threads.
  • Capping across runs: yes, I think records should age. A record whose pipeline hasn't been created in the last few runs (or the last N days) should be dropped at preparation, oldest first, until the folder is under a byte cap. Your 60,040 records from ten builds in 75 minutes are mostly duplicates of a few thousand pipelines, translated for builds that no longer exist. If you or Nathan pick it up, please say so on #533.

A related finding: #585 found that records made under a reflected table root kept the title's root, so about 73% of graphics records failed to replay. Its fix is waiting on a measured receipt.

<!-- greyfinch-sync:brcly/TuxBox:comment:7277290198 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7277290198). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T11:37:33Z. --- @NickStallman, answers to both questions: - **More than one thread:** done in #579, merged today. `TUXBOX_REPLAY_THREADS` defaults to half the cores (2 to 8), and the overall limit is now 4 h (`TUXBOX_REPLAY_TIMEOUT`). @NathansDomainSolutions measured a full replay of 23,142 records at about 18 min on 8 threads. - **Capping across runs:** yes, I think records should age. A record whose pipeline hasn't been created in the last few runs (or the last N days) should be dropped at preparation, oldest first, until the folder is under a byte cap. Your 60,040 records from ten builds in 75 minutes are mostly duplicates of a few thousand pipelines, translated for builds that no longer exist. If you or Nathan pick it up, please say so on #533. A related finding: #585 found that records made under a reflected table root kept the title's root, so about 73% of graphics records failed to replay. Its fix is waiting on a measured receipt.
gtb-sbe commented 2026-11-30 19:09:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-30T19:09:04Z.


@brcly I looked into why the pipeline replay in preparation warmed nothing on my RX 9060 XT (RADV, GE-Proton11-14, main 8345699c). I used a local patch that logs each record's HRESULT. The prep's receipt was records=27237 compute=2590 graphics=5244 failed=19403, and replaying the same records on their own gives the same numbers, record for record.

  • The 30-minute load after it wasn't the replay's fault. My system updated Mesa from 26.2.6 to 26.3.1 two minutes before the launch. The prep had warmed 26.2.6. The launch then refused vkd3d-proton's archive (Cannot load existing on-disk cache due to driver version mismatch) and compiled 631 programs cold, although their DXIL hadn't changed since my earlier runs. 607 of them (93 % of the ~12,100 s) had a record that the replay builds fine. The stamp from f7afdd16 wouldn't catch this: the old entries stay on disk, so the cache never shrinks. Putting the Vulkan driver's version or pipeline-cache UUID into the stamp would.
  • Otherwise the compute replay builds the right thing. For 45 records, the rebuilt DXIL is byte-identical to the .cso the launch used. With a fresh Mesa cache, the replay's environment (no force_raw_va_cbv) and the launch's (with it) hit the same driver entries, 6 of 6.
  • Graphics fails for #585's reason, on AMD too. All 18,501 "replayed as recorded" records fail, plus 846 rebuilt ones. Every one I sampled stops at dxil-spirv: Failed to remap CBV 1:n (one at SRV 1:n). The rebuilds fell back to "as recorded" because xshader refuses the pixel stage against the title's root: root table slot at 0x.. conflicts with the pixel stage physical binding, 18,483 of 18,501. @NathansDomainSolutions, it's the same signature as yours. On RADV no single one of them is slow, though: only one raster pipeline took over 5 s in that run (shorter creates aren't logged, so I don't have their total).
  • 56 compute failures come from a second recorder gap. They're the inline ray-query programs (fb8e97e0 among them), and they fail on Failed to remap SRV 900:n or SRV 901:0. In device/compute_scene.rs, SceneRoot.serialized is set to base.bytes.clone() (still the case on bbc26254). That is the root before the scene SRVs (space 900) and the BVH bindings (space 901) are appended, but native is created from the newly serialized blob. None of the 2,646 recorded compute roots has a space-900/901 parameter. Storing bytes there should fix it, but I haven't tested that with a recording run. 19 of these programs took 483 s to compile in my run.
  • pci=0000:0000 (also still on bbc26254): the guest asks the D3D12 device for IDXGIDevice, which only D3D11 devices implement, so the adapter description stays zeroed. With device->GetAdapterLuid() and IDXGIFactory4::EnumAdapterByLuid, I get pci=1002:7590 (AMD Radeon RX 9060 XT). So the right card was used all along.

If it helps, I can produce #585's end-to-end receipt on this card: a recording run with the branch, then preparation. You're welcome to take the two small fixes (scene root bytes, adapter lookup) directly, or I can open a PR for them, whichever you prefer.

<!-- greyfinch-sync:brcly/TuxBox:comment:7288920793 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7288920793). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-30T19:09:04Z. --- @brcly I looked into why the pipeline replay in preparation warmed nothing on my RX 9060 XT (RADV, GE-Proton11-14, `main` `8345699c`). I used a local patch that logs each record's HRESULT. The prep's receipt was `records=27237 compute=2590 graphics=5244 failed=19403`, and replaying the same records on their own gives the same numbers, record for record. - **The 30-minute load after it wasn't the replay's fault.** My system updated Mesa from 26.2.6 to 26.3.1 two minutes before the launch. The prep had warmed 26.2.6. The launch then refused vkd3d-proton's archive (`Cannot load existing on-disk cache due to driver version mismatch`) and compiled 631 programs cold, although their DXIL hadn't changed since my earlier runs. 607 of them (93 % of the ~12,100 s) had a record that the replay builds fine. The stamp from `f7afdd16` wouldn't catch this: the old entries stay on disk, so the cache never shrinks. Putting the Vulkan driver's version or pipeline-cache UUID into the stamp would. - **Otherwise the compute replay builds the right thing.** For 45 records, the rebuilt DXIL is byte-identical to the `.cso` the launch used. With a fresh Mesa cache, the replay's environment (no `force_raw_va_cbv`) and the launch's (with it) hit the same driver entries, 6 of 6. - **Graphics fails for #585's reason, on AMD too.** All 18,501 "replayed as recorded" records fail, plus 846 rebuilt ones. Every one I sampled stops at `dxil-spirv: Failed to remap CBV 1:n` (one at `SRV 1:n`). The rebuilds fell back to "as recorded" because xshader refuses the pixel stage against the title's root: `root table slot at 0x.. conflicts with the pixel stage physical binding`, 18,483 of 18,501. @NathansDomainSolutions, it's the same signature as yours. On RADV no single one of them is slow, though: only one raster pipeline took over 5 s in that run (shorter creates aren't logged, so I don't have their total). - **56 compute failures come from a second recorder gap.** They're the inline ray-query programs (`fb8e97e0` among them), and they fail on `Failed to remap SRV 900:n` or `SRV 901:0`. In `device/compute_scene.rs`, `SceneRoot.serialized` is set to `base.bytes.clone()` (still the case on `bbc26254`). That is the root before the scene SRVs (space 900) and the BVH bindings (space 901) are appended, but `native` is created from the newly serialized blob. None of the 2,646 recorded compute roots has a space-900/901 parameter. Storing `bytes` there should fix it, but I haven't tested that with a recording run. 19 of these programs took 483 s to compile in my run. - **`pci=0000:0000`** (also still on `bbc26254`): the guest asks the D3D12 device for `IDXGIDevice`, which only D3D11 devices implement, so the adapter description stays zeroed. With `device->GetAdapterLuid()` and `IDXGIFactory4::EnumAdapterByLuid`, I get `pci=1002:7590` (AMD Radeon RX 9060 XT). So the right card was used all along. If it helps, I can produce #585's end-to-end receipt on this card: a recording run with the branch, then preparation. You're welcome to take the two small fixes (scene root bytes, adapter lookup) directly, or I can open a PR for them, whichever you prefer.
JeffreyBytes commented 2026-12-01 00:15:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-01T00:15:12Z.


I had a go at the DXC time that's left, mostly the large compute programs. The DXC helper (tools/dxc_worker.cpp) already runs DXC's optimizer through the API with the -Odump pass list, so it can replace the general optimizer (the passes after -dxil-fix-array-init through -alignment-from-assumptions) with a shorter list. That isn't limited by what the command line can switch off. The HLSL lowering before that range and the DXIL finalization after it stay as DXC arranges them, and -O0 and the other profiles are untouched.

For cs_6_6 with the runtime flags (-O1 -disable-lifetime-markers -fnew-inlining-behavior) the list is:

-targetlibinfo -tbaa -scoped-noalias -basicaa -globalopt
-inline,InlineThreshold=225,InsertLifetime=t -sroa -simplifycfg -gvn -loop-rotate
-instcombine,NoSink=0 -simplifycfg -dce

ps_6_6, ms_6_6 and cs_6_0 are compiled at DXC's default level and get the same pass list from -Odump, so they share a second list: DXC's own inline threshold, an -instcombine before -gvn, -dxil-gvn-hoist -dxil-gvn-eliminate-region, -loop-unroll and a last -instcombine. Without those, pixel shaders came out about 2% bigger, mostly int/float bitcast pairs that stock's extra instcombines fold.

Per program, DXC 1.9.2609.5, recorded ProjectScarlett programs, ratio to the current helper:

programs DXC CPU slowest tenth blocks instructions DXIL
cs_6_6 101 0.48 0.41 1.01 1.01 1.00
ps_6_6 136 0.66 0.60 1.003 1.007 0.999
ms_6_6 136 0.77 0.72 1.000 1.000 0.999
cs_6_0 46 0.45 0.43 1.000 1.001 0.999

The slowest cs_6_6 program (1.39 MB of HLSL, registers kept in a uint tb_v[256] array) went from 37.6 s to 7.8 s. Most of its optimizer time was InstCombine on that array before GVN, which is why the compute list runs -instcombine only once, after -gvn. The six largest cs_6_0 programs (6.8 to 8 MB of HLSL) went from 83-176 s to 46-73 s each; they're still over the 15 s limit, so they still end up in the slow-shader pass, just shorter. The lists keep a late -loop-rotate, since Nick found dxil-spirv crashing without one. All outputs pass DXV.

On a whole prep it's less, because the pass waits on the big compute programs at the start. A cold --prepare-only of my full cache (36,712 recorded requests) on 8345699c, before #593, took the DXC pass from 3,700 s to 2,626 s with the cs_6_6, ps_6_6 and ms_6_6 lists, and the helper's CPU time from 51,737 s to 30,543 s, with the same programs compiled and none failed. The pixel and mesh list mostly saves CPU there, not wall time, since those compiles already ran alongside the compute ones.

On current main (82109205, with #593), with all four lists, a random 4,000 of the recorded requests, TUXBOX_SCARLETT_SEED_PACK=0, no replay, default jobs (15 here), only the helper different:

main with the lists
DXC pass 467 s 311 s
total 580 s 373 s
DXC helper CPU 6,013 s 3,981 s

Both compiled 3,856, 144 unsupported, 0 failed, and no helper output was rejected. The rest of the gap after the DXC pass is the slow-shader pass, where the cs_6_0 list helps. That's recorded requests only: since 82109205 a default prep also compiles the 6,841 pack programs no run has recorded, so a full prep on main has more DXC work for the lists to cut. I haven't timed that one.

On the GPU, tools/execute_recorded_shaders.py (RX 6700 XT, RADV, seed 293) compared the outputs with the current helper's. cs_6_6, 300 sampled: 77 ran on both sides, 73 equivalent, 3 unstable on the baseline itself, 1 changed. cs_6_0, all 495 requests: 475 ran, 470 equivalent, 2 unstable, 3 changed, 0 lost. Three of the four changed programs use atomics and write the same values in a different order (one is an append buffer whose writes are clamped to its last slot, so the last thread to write wins). The fourth, aeb9a6c6, has 256 floats that differ by 1 or 2 ULP: its ops carry fast, and stock folds 1.0 - x and power-of-two constant multiplies differently, which is allowed under fast math either way. That harness only runs programs up to 4 MB of HLSL, so the largest ones aren't in it.

For pixel and mesh output I ran the game on 34be158 (with #389) and both lists, GE-Proton11-15: it reached the world, no GPU faults, 0 failed pipelines, and the cutscene looks and runs the same as it does without the change (still not right, but no different).

The DXV rejections in these preps (13 to 14 per run, plus some timeouts) were the FP64 programs from #592, the same on main, and #593 has fixed those since.

If this is worth having I can open a PR with the helper change and its tests on current main. The compute list could also go in on its own first.

<!-- greyfinch-sync:brcly/TuxBox:comment:7296114953 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7296114953). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-01T00:15:12Z. --- I had a go at the DXC time that's left, mostly the large compute programs. The DXC helper (`tools/dxc_worker.cpp`) already runs DXC's optimizer through the API with the `-Odump` pass list, so it can replace the general optimizer (the passes after `-dxil-fix-array-init` through `-alignment-from-assumptions`) with a shorter list. That isn't limited by what the command line can switch off. The HLSL lowering before that range and the DXIL finalization after it stay as DXC arranges them, and `-O0` and the other profiles are untouched. For `cs_6_6` with the runtime flags (`-O1 -disable-lifetime-markers -fnew-inlining-behavior`) the list is: ``` -targetlibinfo -tbaa -scoped-noalias -basicaa -globalopt -inline,InlineThreshold=225,InsertLifetime=t -sroa -simplifycfg -gvn -loop-rotate -instcombine,NoSink=0 -simplifycfg -dce ``` `ps_6_6`, `ms_6_6` and `cs_6_0` are compiled at DXC's default level and get the same pass list from `-Odump`, so they share a second list: DXC's own inline threshold, an `-instcombine` before `-gvn`, `-dxil-gvn-hoist -dxil-gvn-eliminate-region`, `-loop-unroll` and a last `-instcombine`. Without those, pixel shaders came out about 2% bigger, mostly int/float bitcast pairs that stock's extra instcombines fold. Per program, DXC 1.9.2609.5, recorded ProjectScarlett programs, ratio to the current helper: | | programs | DXC CPU | slowest tenth | blocks | instructions | DXIL | |---|---:|---:|---:|---:|---:|---:| | `cs_6_6` | 101 | 0.48 | 0.41 | 1.01 | 1.01 | 1.00 | | `ps_6_6` | 136 | 0.66 | 0.60 | 1.003 | 1.007 | 0.999 | | `ms_6_6` | 136 | 0.77 | 0.72 | 1.000 | 1.000 | 0.999 | | `cs_6_0` | 46 | 0.45 | 0.43 | 1.000 | 1.001 | 0.999 | The slowest `cs_6_6` program (1.39 MB of HLSL, registers kept in a `uint tb_v[256]` array) went from 37.6 s to 7.8 s. Most of its optimizer time was InstCombine on that array before GVN, which is why the compute list runs `-instcombine` only once, after `-gvn`. The six largest `cs_6_0` programs (6.8 to 8 MB of HLSL) went from 83-176 s to 46-73 s each; they're still over the 15 s limit, so they still end up in the slow-shader pass, just shorter. The lists keep a late `-loop-rotate`, since Nick found dxil-spirv crashing without one. All outputs pass DXV. On a whole prep it's less, because the pass waits on the big compute programs at the start. A cold `--prepare-only` of my full cache (36,712 recorded requests) on 8345699c, before #593, took the DXC pass from 3,700 s to 2,626 s with the `cs_6_6`, `ps_6_6` and `ms_6_6` lists, and the helper's CPU time from 51,737 s to 30,543 s, with the same programs compiled and none failed. The pixel and mesh list mostly saves CPU there, not wall time, since those compiles already ran alongside the compute ones. On current main (82109205, with #593), with all four lists, a random 4,000 of the recorded requests, `TUXBOX_SCARLETT_SEED_PACK=0`, no replay, default jobs (15 here), only the helper different: | | main | with the lists | |---|---:|---:| | DXC pass | 467 s | 311 s | | total | 580 s | 373 s | | DXC helper CPU | 6,013 s | 3,981 s | Both compiled 3,856, 144 unsupported, 0 failed, and no helper output was rejected. The rest of the gap after the DXC pass is the slow-shader pass, where the `cs_6_0` list helps. That's recorded requests only: since 82109205 a default prep also compiles the 6,841 pack programs no run has recorded, so a full prep on main has more DXC work for the lists to cut. I haven't timed that one. On the GPU, `tools/execute_recorded_shaders.py` (RX 6700 XT, RADV, seed 293) compared the outputs with the current helper's. `cs_6_6`, 300 sampled: 77 ran on both sides, 73 equivalent, 3 unstable on the baseline itself, 1 changed. `cs_6_0`, all 495 requests: 475 ran, 470 equivalent, 2 unstable, 3 changed, 0 lost. Three of the four changed programs use atomics and write the same values in a different order (one is an append buffer whose writes are clamped to its last slot, so the last thread to write wins). The fourth, `aeb9a6c6`, has 256 floats that differ by 1 or 2 ULP: its ops carry `fast`, and stock folds `1.0 - x` and power-of-two constant multiplies differently, which is allowed under fast math either way. That harness only runs programs up to 4 MB of HLSL, so the largest ones aren't in it. For pixel and mesh output I ran the game on 34be158 (with #389) and both lists, GE-Proton11-15: it reached the world, no GPU faults, 0 failed pipelines, and the cutscene looks and runs the same as it does without the change (still not right, but no different). The DXV rejections in these preps (13 to 14 per run, plus some timeouts) were the FP64 programs from #592, the same on main, and #593 has fixed those since. If this is worth having I can open a PR with the helper change and its tests on current main. The compute list could also go in on its own first.
brcly commented 2026-12-01 15:13:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by brcly on 2026-12-01T15:13:53Z.


@JeffreyBytes yes, this is worth having, thank you. Halving DXC CPU time on cs_6_6 with the same blocks, instructions and DXIL, outputs that pass DXV, and GPU outputs checked against the current helper is the kind of evidence we need. Please open the PR, the compute list first on its own as you suggest, then the pixel/mesh list.

One thing changed since your measurements: #523 (merged today as 61a64d31) rewrites a lot of the generated HLSL (select instead of ?:, constant 64-bit shifts, power-of-two structured strides). Please re-time on current main, since the passes see different input now. The atomics and fast ULP differences you describe are fine to call out in the PR as they are.

<!-- greyfinch-sync:brcly/TuxBox:comment:7315564285 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7315564285). Originally posted by [brcly](https://github.com/brcly) on 2026-12-01T15:13:53Z. --- @JeffreyBytes yes, this is worth having, thank you. Halving DXC CPU time on `cs_6_6` with the same blocks, instructions and DXIL, outputs that pass DXV, and GPU outputs checked against the current helper is the kind of evidence we need. Please open the PR, the compute list first on its own as you suggest, then the pixel/mesh list. One thing changed since your measurements: #523 (merged today as 61a64d31) rewrites a lot of the generated HLSL (`select` instead of `?:`, constant 64-bit shifts, power-of-two structured strides). Please re-time on current main, since the passes see different input now. The atomics and `fast` ULP differences you describe are fine to call out in the PR as they are.
1093i3511 commented 2026-12-01 17:20:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T17:20:36Z.


A data point for compile time, after e40d8052, from an 8 GB RX 6600 with a 6-core/12-thread CPU, DXC 1.9.2609 (the helper path), Series S prepare of all 25,889 pack programs:

717a74c4 (this morning) fb17e160
Shader preparation 1,694.8 s 4,492.5 s (2.65x)
Compiled / unsupported / failed 23,748 / 2,173 / 0 23,738 / 2,171 / 12 (Part A)
Slow shaders to optimise 9 20

Almost all the extra time is at the start. Progress every 5 minutes:

Time into the prepare Compiled Rate per minute
40 min 1,078
45 min 1,471 ~79
50 min 2,111 ~128
55 min 2,863 ~150
60 min 3,761 ~180
65 min 5,598 ~370
70 min 10,876 ~1,050

The pipeline replay at the end shows the merges paying off:

Pipeline replay 717a74c4 fb17e160
Compute / graphics built 2,636 / 1,689 2,626 / 2,581
Failed 5,986 2,912
driver_ms (summed over 6 threads) 86,410 2,841,052

The driver time includes the ~900 extra graphics pipelines and a RADV cache that was cold for the new translation, so I would not read it as a slowdown by itself.

So the first ~4,000 programs became much more expensive to compile, and the rest compile at about this morning's rate or faster. The translator changes between the two are #522, #523, #555 and #558, plus #613-#616; I have not bisected which one makes the early programs slower.

<!-- greyfinch-sync:brcly/TuxBox:comment:7319146871 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7319146871). Originally posted by [1093i3511](https://github.com/1093i3511) on 2026-12-01T17:20:36Z. --- A data point for compile time, after e40d8052, from an 8 GB RX 6600 with a 6-core/12-thread CPU, DXC 1.9.2609 (the helper path), Series S prepare of all 25,889 pack programs: | | 717a74c4 (this morning) | fb17e160 | | --- | --- | --- | | Shader preparation | 1,694.8 s | 4,492.5 s (2.65x) | | Compiled / unsupported / failed | 23,748 / 2,173 / 0 | 23,738 / 2,171 / 12 (Part A) | | Slow shaders to optimise | 9 | 20 | Almost all the extra time is at the start. Progress every 5 minutes: | Time into the prepare | Compiled | Rate per minute | | --- | --- | --- | | 40 min | 1,078 | | | 45 min | 1,471 | ~79 | | 50 min | 2,111 | ~128 | | 55 min | 2,863 | ~150 | | 60 min | 3,761 | ~180 | | 65 min | 5,598 | ~370 | | 70 min | 10,876 | ~1,050 | The pipeline replay at the end shows the merges paying off: | Pipeline replay | 717a74c4 | fb17e160 | | --- | --- | --- | | Compute / graphics built | 2,636 / 1,689 | 2,626 / 2,581 | | Failed | 5,986 | 2,912 | | `driver_ms` (summed over 6 threads) | 86,410 | 2,841,052 | The driver time includes the ~900 extra graphics pipelines and a RADV cache that was cold for the new translation, so I would not read it as a slowdown by itself. So the first ~4,000 programs became much more expensive to compile, and the rest compile at about this morning's rate or faster. The translator changes between the two are #522, #523, #555 and #558, plus #613-#616; I have not bisected which one makes the early programs slower.
JeffreyBytes commented 2026-12-01 21:24:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-01T21:24:09Z.


@1093i3511 thanks for the numbers. I tried to reproduce the prepare slowdown and couldn't. What I measured is per-program DXC cost, not a whole prepare on your pack, so this doesn't prove your 2.65x is something else, but it points away from the translator changes.

Measured: the 4,000 largest recorded requests from my archive, translated at 717a74c4, fb17e160 and 9a19c767, a random sample of them compiled with the stock helper and the runtime flags, 8 jobs, both sides interleaved, same machine. DXC CPU, fb17e160 against 717a74c4:

programs 717a74c4 fb17e160 ratio
cs_6_6 101 1,444 s 1,455 s 1.01
ps_6_6 136 386 s 391 s 1.01
ms_6_6 136 442 s 427 s 0.97

No compile failed and every output passed DXV. The 30 programs with the largest ratio on the first pass were mostly noise (8 jobs on a hybrid CPU): re-timed they came out around 1.0. So there is nothing to bisect between #522, #523, #555, #558 and #613-#616 per program. I also checked 9a19c767: 3,831 of the 3,840 translatable programs have byte-identical HLSL to fb17e160, so it behaves the same.

Inferred, not measured on your machine: your prepare at 717a74c4 probably reused DXIL that an earlier prepare had stored. Every one of the 4,000 largest requests translates to different HLSL at fb17e160 (measured), so none of those can be reused. #535 also changed tools/dxc_worker.cpp, and the helper digest is part of the DXIL store identity, so fb17e160 starts a new store anyway. 717a74c4 translates those 4,000 identically to b3873ec4, and the helper source is unchanged since 11-29, so a prepare from any recent main before that would have let 717a74c4 skip most of them. For scale, I estimate about 23,500 helper CPU-seconds to compile the first 4,000 from scratch. That doesn't fit in 1,694.8 s on 12 threads (about 20,300 CPU-s at best), but it does fit your 60 minutes for roughly 3,800 programs. The slow shaders going from 9 to 20 fits too, if the slow-shader marks live in that store. In my sample the number of programs over the 15 s limit is the same on both sides.

Could you check the log from the 717a74c4 prepare for the line "ProjectScarlett DXIL reused for N of the compiled shaders"? If N is in the thousands, that's it. If it's near 0 and the prepare still took 1,694.8 s, I'm wrong and I'd like to know.

Measured, and small: #523 (61a64d31) does add a little. On dd7c730f, a cs_6_6 program, DXC takes 5.1 s before and 5.4 s after (GVN 0.23 s to 0.51 s, instcombine 1.18 s to 1.38 s in -ftime-report), and 8af81503 went from 5.12 s to 5.40 s in the bisect, though not in a later re-run (5.15 s). That's a few percent on a couple of programs, not a 2.65x. I haven't isolated which of #523's HLSL forms does it. The shorter cs_6_6 pass list from the PR pays the same: +7% on dd7c730f, with 3.55 s going to 3.78 s, so it doesn't avoid that increase.

The 12 failures I can't place. None of my compiles failed, and your comment doesn't say which programs or which stage. If you have the log lines for them, could you tell me which ones?

The cs_6_6 PR is here: https://github.com/brcly/TuxBox/pull/638

<!-- greyfinch-sync:brcly/TuxBox:comment:7326198170 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7326198170). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-01T21:24:09Z. --- @1093i3511 thanks for the numbers. I tried to reproduce the prepare slowdown and couldn't. What I measured is per-program DXC cost, not a whole prepare on your pack, so this doesn't prove your 2.65x is something else, but it points away from the translator changes. Measured: the 4,000 largest recorded requests from my archive, translated at 717a74c4, fb17e160 and 9a19c767, a random sample of them compiled with the stock helper and the runtime flags, 8 jobs, both sides interleaved, same machine. DXC CPU, fb17e160 against 717a74c4: | | programs | 717a74c4 | fb17e160 | ratio | |---|---:|---:|---:|---:| | `cs_6_6` | 101 | 1,444 s | 1,455 s | 1.01 | | `ps_6_6` | 136 | 386 s | 391 s | 1.01 | | `ms_6_6` | 136 | 442 s | 427 s | 0.97 | No compile failed and every output passed DXV. The 30 programs with the largest ratio on the first pass were mostly noise (8 jobs on a hybrid CPU): re-timed they came out around 1.0. So there is nothing to bisect between #522, #523, #555, #558 and #613-#616 per program. I also checked 9a19c767: 3,831 of the 3,840 translatable programs have byte-identical HLSL to fb17e160, so it behaves the same. Inferred, not measured on your machine: your prepare at 717a74c4 probably reused DXIL that an earlier prepare had stored. Every one of the 4,000 largest requests translates to different HLSL at fb17e160 (measured), so none of those can be reused. #535 also changed `tools/dxc_worker.cpp`, and the helper digest is part of the DXIL store identity, so fb17e160 starts a new store anyway. 717a74c4 translates those 4,000 identically to b3873ec4, and the helper source is unchanged since 11-29, so a prepare from any recent main before that would have let 717a74c4 skip most of them. For scale, I estimate about 23,500 helper CPU-seconds to compile the first 4,000 from scratch. That doesn't fit in 1,694.8 s on 12 threads (about 20,300 CPU-s at best), but it does fit your 60 minutes for roughly 3,800 programs. The slow shaders going from 9 to 20 fits too, if the slow-shader marks live in that store. In my sample the number of programs over the 15 s limit is the same on both sides. Could you check the log from the 717a74c4 prepare for the line "ProjectScarlett DXIL reused for N of the compiled shaders"? If N is in the thousands, that's it. If it's near 0 and the prepare still took 1,694.8 s, I'm wrong and I'd like to know. Measured, and small: #523 (61a64d31) does add a little. On dd7c730f, a `cs_6_6` program, DXC takes 5.1 s before and 5.4 s after (GVN 0.23 s to 0.51 s, instcombine 1.18 s to 1.38 s in `-ftime-report`), and 8af81503 went from 5.12 s to 5.40 s in the bisect, though not in a later re-run (5.15 s). That's a few percent on a couple of programs, not a 2.65x. I haven't isolated which of #523's HLSL forms does it. The shorter `cs_6_6` pass list from the PR pays the same: +7% on dd7c730f, with 3.55 s going to 3.78 s, so it doesn't avoid that increase. The 12 failures I can't place. None of my compiles failed, and your comment doesn't say which programs or which stage. If you have the log lines for them, could you tell me which ones? The `cs_6_6` PR is here: https://github.com/brcly/TuxBox/pull/638
1093i3511 commented 2026-12-01 22:24:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T22:24:19Z.


@JeffreyBytes thank you, and sorry: that was my oversight. I compared the two prepares without the DXIL reuse line, and it explains the whole difference:

Prepare Compiled requests DXIL reused Through DXC Time
717a74c4 40,959 28,429 ~12,500 1,694.8 s
fb17e160 41,296 6,643 ~34,650 4,492.5 s

About 2.8x the DXC work for 2.65x the time, so the cost per program didn't change, as you measured. The slow start of my rate curve was only the order: the programs that needed DXC came first, the reused ones later. Please disregard the "first ~4,000 programs became more expensive" reading in my comment.

<!-- greyfinch-sync:brcly/TuxBox:comment:7327789146 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7327789146). Originally posted by [1093i3511](https://github.com/1093i3511) on 2026-12-01T22:24:19Z. --- @JeffreyBytes thank you, and sorry: that was my oversight. I compared the two prepares without the DXIL reuse line, and it explains the whole difference: | Prepare | Compiled requests | DXIL reused | Through DXC | Time | | --- | --- | --- | --- | --- | | 717a74c4 | 40,959 | 28,429 | ~12,500 | 1,694.8 s | | fb17e160 | 41,296 | 6,643 | ~34,650 | 4,492.5 s | About 2.8x the DXC work for 2.65x the time, so the cost per program didn't change, as you measured. The slow start of my rate curve was only the order: the programs that needed DXC came first, the reused ones later. Please disregard the "first ~4,000 programs became more expensive" reading in my comment.
JeffreyBytes commented 2026-12-02 22:31:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-02T22:31:16Z.


The pixel/mesh list changes (already built just rebase and tests) is queued behind some other testing. Should be a PR by tonight.

<!-- greyfinch-sync:brcly/TuxBox:comment:7360805017 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/293#issuecomment-7360805017). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-02T22:31:16Z. --- The pixel/mesh list changes (already built just rebase and tests) is queued behind some other testing. Should be a PR by tonight.
Sign in to join this conversation.
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
brcly/TuxBox#293
No description provided.