Isolate DXC compile time in a source-built mixed-sampler compute shader #775
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#775
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@R0Y00 on GitHub · 2026-11-23 02:13 UTC · original
Refs #676. In the fixed-profile measurements, all 702 compute records previously blocked at SampleLevel emitted HLSL. Seven compiled within 90 seconds and the other 695 timed out. We need a public reproducer to identify where compilation time goes before changing the bridge. This is independent of the WARP output investigation in #768.
Start with tests/spirv_window/sampler.py and its source-built module. Keep one texture and both sampler views, and a distinguishable UAV result. Compare a small control with a generated family that varies one property at a time, initially repeated samples versus control-flow size. Claim the variable you are testing and name any overlapping PR.
@FZNull on GitHub · 2026-11-23 03:20 UTC · original
Source-built compile-time reproducer: DXC time concentrates in the two DXIL GVN passes
This is a measurement report for #775. I did not change the translator or the
repository; no branch was pushed. Repository
bd30209(origin/main), DXC1.9.2609.5 (01b62ad47), Windows 11 build 26300, Ryzen 5 5500 (6c/12t,
15.9 GiB RAM), RTX 4060 driver 32.0.16.2124, SPIRV-Tools v2025.5
262bdab,SPIRV-Cross
57e4efc. Compiles ran one at a time (sampled CPU load 1–16 %,median 5 %).
Variable claimed: repeated
SampleLevelcount and control-flow size(sample-in-branch regions) in source-built mixed-sampler compute HLSL. I found
no overlapping open PR: #676/#681 are the merged mixed-sampler bridge work and
#768 is a separate WARP readback investigation.
Fixture. The HLSL is emitted by
tests/spirv_window/sampler.pyunchanged(spirv-as -> spirv-val ->
tools/spirv_sampler_views.py-> spirv-cross). Itkeeps one texture, both sampler views and a raw UAV, so the existing
offscreen_check --spirv-sampler-viewsoracle still applies:Baseline command (the profile's cs_6_6 / native 16-bit / default O3 setup):
Protocol: 90 s wall timeout and 2 GiB per-process cap, warm-up discarded, three
repetitions at representative sizes, median reported. The control (685 bytes) was
re-measured at start/middle/end (0.0229/0.0229/0.0238 s, 4.3 % spread).
Families (each changes one property; the emitted prologue and the two control
stores are kept verbatim so words 0–3 of the UAV are identical everywhere):
samples_N: N extra independentSampleLevelstores, flat control flow.branches_B: B extra if/else regions with observable stores; sample count fixed.samplebranch_N: oneSampleLevelinside each divergent region, becausethat is the shape of the CS records blocked at
SampleLevel.-OdLog-log slopes (wall vs HLSL bytes): samples 1.10, branches 1.21,
samplebranch 1.51 (256–8192); the upper range is closer to quadratic
(8192 -> 12288 is 2.9x time for 1.5x size).
Where the time goes.
-ftime-report(separate labelled diagnostic run,same flags; "Total" is LLVM/DXIL passes only):
samplebranch_8192: 29.31 s wall, 27.34 s passes; the two "Global ValueNumbering" instances are 14.94 + 7.42 = 22.36 s (81.8 % of pass time),
inliner 0.80 s.
samplebranch_4096: 8.35 s wall, 7.20 s passes; GVN 3.38 + 1.70 = 5.08 s(70.5 %).
branches_16384: 15.27 s wall, 13.34 s passes; GVN 4.47 + 1.94 = 6.41 s(48.0 %), GVN hoist 1.27 s (9.5 %).
-Odremoves 25 % of the time forsamples_16384, 64 % forbranches_16384,73 % for
samplebranch_4096, 84 % forsamplebranch_8192, and >95 % forsamplebranch_16384(9.60 s instead of 193.12 s).-Vdsaves 0.33 s onsamples_16384(4 %), so validation is not the problem, and the frontend staysroughly linear (about 9.6 s of
-Odtime on the 3.9 MB source). Triggerreduction at fixed size: constant sampler index (-5 %), comparison sampling
instead of ordinary (+1 %), and hoisting the sample out of the branch (-3 %) all
leave the cost in place — the trigger is the coexistence of many sampling calls
and many branch/store regions in one function, not the sampler view kind or
divergence.
Minimal reproducible pair. Same generator and command, one property changed:
samplebranch_8192(1.95 MB HLSL) compiles in every run;samplebranch_16384(3.92 MB) exceeds the 90 s limit (193.1 s with a raised limit), and
samplebranch_12288(2.93 MB) is marginal (67.8 s one session, >90 s inanother). This crosses the profile's 90 s threshold only at multi-MB HLSL in
this shape.
Verification. Every emitted CSO is accepted by
dxv.exe(no compilerdiagnostics in any variant). The existing oracle
offscreen_check <adapter> --spirv-sampler-views <cso>passes on the RTX 4060(32.0.16.2124) for control,
samples_1024/16384,branches_1024/16384andsamplebranch_1024/4096/8192, and on WARP (10.0.26100.10068) for the smallerset; a negative control with one UV changed fails on both as expected. The 4
bridge tests (
spirv_sampler_views_*,spirv_compare_sampler_*) pass at thiscommit.
samplebranch_12288was not dispatched: NVIDIA pipeline creation for its2.77 MB DXIL did not return within ~9 minutes (driver JIT, outside DXC).
Limits — what did not reproduce. At fixture scale (<0.5 MB HLSL) the worst
case is 2.5 s; the 90 s timeout needs ~2.9 MB of HLSL (≈12,000 sample-in-branch
regions). I could not replay an archive record: the 26,503-record profile is not
public, so I cannot claim the 695 timeouts have this shape/size. This narrows the
mechanism and publishes the curve; the next step is to record HLSL size and one
-ftime-reportfor the first record that times out in the replay. The 90 s /2 GiB limits are local, machine-dependent policy and are not in CI. Timing
variance on the largest cases is ±20–45 % across sessions, so outcomes near the
threshold can flip; no translator change is proposed before the cause is
confirmed on a real record.
@R0Y00 on GitHub · 2026-11-23 04:07 UTC · original
Thanks for pinning the compiler and separating validation, optimization and driver JIT. The source-built pair crosses 90 seconds between roughly 1.95 and 3.92 MB, and the two GVN passes accounted for 81.8% of LLVM/DXIL pass time at 8,192 sample/branch regions. Please submit the generator and a compact reproduction record, including which outputs the oracle checked and the separate driver JIT timeout. Keep the archive-replay attribution open until a failing local record supplies input size and pass-time totals. Aggregate measurements are enough.
@R0Y00 on GitHub · 2026-11-23 05:08 UTC · original
Local archive follow-up using Windows SDK DXC 1.8.2502.11, cs_6_6, native 16-bit, one compiler process. The 695 previous SampleLevel timeout records represent 670 distinct HLSL files, median 17.19 MB (range 1.87–32.70 MB). The seven successful files have a median of 2.60 MB (range 1.36–4.66 MB). Median-size successful control: 32.54 s with -ftime-report, with Jump Threading taking 19.98 s (62.2% of reported pass wall time). Median-size timeout sample: default optimization still timed out after 480 s without a pass report. The same source at -Od emitted DXIL in 75.20 s. Its top reported passes were Dxil Erase Dead Region (31.09 s, 53.5%) and Dxil Conditional Mem2Reg (15.26 s, 26.3%). This reproduces strong optimization sensitivity on a package record, with a different measured profile from the source-built GVN case. The -Od output has not been established as equivalent on GPU. Keep attribution of the default-optimization stall and the broader cohort open.
@FZNull on GitHub · 2026-11-23 05:28 UTC · original
Thanks — the archive numbers change the scale of the question, and they are worth stating against the source-built curve explicitly.
Your median timeout record is 17.19 MB of HLSL (range 1.87–32.70 MB); my pair crosses 90 s between 1.95 and 3.92 MB. So the median record is 4.4x the upper end of the pair and 8.8x its lower end, and the successful files (median 2.60 MB, range 1.36–4.66 MB) overlap the pair almost exactly. That is the useful part: the source-built pair brackets the successful side of the cohort, not the failing side. Extrapolating my measured superlinear segment (2.9x time for 1.5x source, 8192 -> 12288) from 3.92 MB to 17.19 MB is well past 480 s, which is consistent with your default-optimization stall, but that is an extrapolation across 4.4x of source and I am not claiming it as a measurement.
Your profile also differs from what I measured, in a way that argues for keeping attribution open as you asked: source-built
samplebranchis dominated by the two GVN instances (81.8 % of pass time), while your successful control is dominated by Jump Threading (62.2 %) and your-Odtimeout sample by Dxil Erase Dead Region (53.5 %) plus Dxil Conditional Mem2Reg (26.3 %). Different HLSL shapes, different dominant passes — the common fact is only that default optimization is where the time goes and-Odcollapses it. I am also noting your point that the-Odoutput has not been established as equivalent on GPU; I would not treat it as a workaround until that is measured.Two things I can submit, as you asked:
tools/script: the same control plus the three families (samples_N,branches_B,samplebranch_N), the pinned compile command, and a compact CSV/JSON record of wall time, peak memory and outcome per variant. No CI registration and no machine-dependent thresholds in the tree.docs/experiments.md: the table above, plus explicitly (a) which outputs the oracle checked —offscreen_check <adapter> --spirv-sampler-viewson the RTX 4060 for control,samples_1024/16384,branches_1024/16384andsamplebranch_1024/4096/8192, and on WARP for the smaller set, with the UV-altered negative control failing on both; and (b) the separate driver JIT timeout, kept out of the DXC accounting:samplebranch_12288(2.77 MB of DXIL) never returned from NVIDIA pipeline creation within ~9 minutes on the RTX 4060, which is why that variant has no GPU readback.I will keep the archive-replay attribution open in the text and repeat your framing: the next useful datum is input size plus
-ftime-reporttotals from a failing local record.@R0Y00 on GitHub · 2026-11-23 05:31 UTC · original
Follow-up on the same 17,188,611-byte input and Windows SDK DXC 1.8.2502.11. With default optimization, the 240-second -print-before-all trace last entered Rotate Loops (loop-rotate). An independent 180-second run with only -print-before loop-rotate -print-after loop-rotate recorded six entries and five exits, with the final entry unmatched. This locates the observed stall at loop rotation (including the diagnostic IR emission), without estimating its share of an uninstrumented run or attributing all 695 timeouts to it. The same -Od DXIL created a compute PSO on WARP. RTX 4060 Laptop reached the process memory limit at both the standard 1,400 MiB limit and an isolated 3 GiB retry. These are pipeline results. An independent expected GPU result for this exact archive program still requires its guest descriptor bindings and inputs. No compiler flag or default runtime behavior changed.
@FZNull on GitHub · 2026-11-23 05:41 UTC · original
Submitted as #801:
tools/dxc_compile_time.py(the generator) plus the compact reproduction record indocs/experiments.md, with the three things you asked to keep explicit:offscreen_check <adapter> --spirv-sampler-viewson the RTX 4060 for control,samples_1024/16384,branches_1024/16384andsamplebranch_1024/4096/8192; on WARP for control,samples_1024,branches_1024andsamplebranch_4096; the UV-altered negative control fails on both. That checks the four control words of each compiled variant, not GPU equivalence for arbitrary inputs.samplebranch_12288was never dispatched: NVIDIA pipeline creation for its 2.77 MB of DXIL did not return within about 9 minutes on the RTX 4060. It is excluded from every DXC time above and is not part of the compile-time attribution.-ftime-reporttotals.The tool is not registered in CI, has no built-in threshold (
--timeoutis required from the caller as local policy), needs only the standard library plus DXC, and--list-variantsreproduces the recorded source sizes exactly, so the table can be re-measured rather than trusted.I took your point that the
-Odoutput is not established as equivalent on GPU; the doc does not offer it as a workaround, only as evidence that the optimizer is where the time goes.@R0Y00 on GitHub · 2026-11-23 07:02 UTC · original
The public generator and measurements merged in #801 (
869a825). I verified four small variants and a forced timeout with Windows SDK DXC. The report keeps the source-built compiler timing, the separate RTX pipeline creation timeout, and the instrumented archiveloop-rotatetrace distinct. This issue stays open for uninstrumented optimization attribution and evidence across the replay cohort.@rasptum on GitHub · 2026-11-23 15:16 UTC · original
Claiming a follow-up slice for #775 (milestone: #676 replay profile, mixed-sampler compute compile time; interface:
tools/dxc_compile_time.pyplus a new compile-only CTest).Variable: the loop constructs the bridge emits around structured control flow (loop-wrapped sample/store regions), to test whether a source-built family reaches the optimizer stall at fixture scale instead of multi-MB HLSL, and which pass (loop-rotate / jump threading / GVN) holds the time uninstrumented. Deliverable: a minimized source-built reproducer and a compile-only regression test with a forced-timeout negative control. No timing threshold goes into CI. No archive data will be shared. I found no overlapping open PR.
@rasptum on GitHub · 2026-11-23 17:09 UTC · original
Follow-up to my claim above. I submitted #918:
condstore_N/stores_Nintools/dxc_compile_time.pyand a compile-only CTestdxc_compile_time_gvn.The loop wrapper I claimed turned out not to be needed. Reducing
samplebranch_Nshows the GVN cost needs no sampler at all. N conditional raw-UAV stores are enough, and the same stores without theifscale linearly. Loop andfor (;;) switchwrappers only make it slower again. Pre-GVN IR re-creates the UAV handle in every conditional block. The quadratic memory-dependence walk that would explain this is a hypothesis, not established.Compiler only. No PSO or driver JIT numbers here. Ryzen 7 3700X, Windows 10 19045, one compile at a time,
-T cs_6_6 -E main -enable-16bit-types. The builds are DXC 1.7.2308.16 (52da17e29, Windows SDK 10.0.26100) and 1.9.0.5512 (01b62ad47, LunarG Vulkan SDK 1.4.363.0). 1.8.2502.11 was not available.-opt-disable gvn-opt-disable gvnThe rows up to
condstore_4096and the defaultsamplebranch_8192row are medians of three runs; the others are single runs. GVN takes 93.1 % (1.7) and 95.3 % (1.9) of the-ftime-reportpass time forcondstore_4096.-opt-disable gvnis a labelled diagnostic setting. Its DXIL is not GPU-checked and it is not proposed as a flag. This does not attribute the archive cohort, whoseloop-rotate/Jump Threading profile is different.Repro, from the #918 branch. The generator writes the HLSL under
--work-dirand records the exact dxc command line in the JSON:Independent runs on other pinned DXC versions are welcome, for example 1.9.2602.17 or 1.8.2502.11. Please give the version string, the source of the build, the input bytes, wall time, peak memory and outcome.
@R0Y00 on GitHub · 2026-11-23 17:31 UTC · original
#918 is merged. The source-built conditional-store family reproduces high GVN cost without a sampler or a PSO, and the compile-only test verifies the timeout and diagnostic paths. The next useful comparison is to take a small case that compiles in both configurations, dispatch both versions against identical inputs and compare the complete raw UAV outputs, including a wrong-output control. This would test the impact of the diagnostic option on the minimized case. The archive cohort and production flags remain open.
@rasptum on GitHub · 2026-11-23 17:37 UTC · original
Claiming the output-parity follow-up (milestone: #676 replay profile, mixed-sampler compute compile time; interface: a new CTest that compiles one small
condstore_Nfromtools/dxc_compile_time.pywith default optimization and with-opt-disable gvn, dispatches both on WARP plus a separate_hardwareentry, and compares the complete raw UAV against identical synthetic inputs bit for bit). A mutated store and a corrupted expected buffer serve as wrong-output controls. No claim about production flags or the archive cohort. I found no overlapping open PR.AI-assisted (Claude Code).
@rasptum on GitHub · 2026-11-23 18:58 UTC · original
Output parity is in #962.
condstore_256was compiled at cs_6_0 with default optimization and with-opt-disable gvn, and both blobs were dispatched with identical inputs: a pre-filled 70,656-byte raw UAV, the sampler fixture's texture and samplers, and 1-group and 2-group dispatches. The complete raw UAV was compared bit for bit, with each other and with an expected buffer computed from the HLSL.52da17e29) and 1.9.0.5512 (01b62ad47), each on WARP 10.0.19041.5794 (in-box) and on an RTX 3060 (driver 32.0.15.9636), Windows 10 build 19045: 0 of 17,664 words differ in every comparison, for both dispatches. The two containers differ (SHA-256 printed).This covers one minimized shader only. Production flags, cs_6_6 DXIL and the archive cohort remain open.
AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-23 19:24 UTC · original
The reproducible diagnosis is complete. #918 isolated the high compiler cost to a minimized conditional-store family and recorded the compile-only measurements across DXC versions. #962 adds the output comparison for condstore_256. Default optimization and the diagnostic no-GVN build matched all 70,656 UAV bytes against the reference on both WARP and an RTX 4060 Laptop, for one and two groups. Both wrong-output controls were detected. The archive-wide timing and any production compiler flag change remain separate.