tooling: measure DXC compile time on a generated mixed-sampler shader #795
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/801"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by FZNull on 2026-11-23T05:41:19Z.
tooling: measure DXC compile time on a generated mixed-sampler shader
Follow-up to #775: this is the generator plus the compact reproduction record the maintainer asked for. It adds one standalone tool and one documentation section; there is no translator, runtime, CI or test behavior change.
Generator
tools/dxc_compile_time.pygenerates HLSL from the shape of the source-built sampler fixture (tests/spirv_window/sampler.pythrough the named SPIR-V bridge) and times one DXC run per variant. The emitted fixture declarations and its two control stores are kept verbatim, so words 0-3 of the UAV are identical in every variant and the existingoffscreen_check --spirv-sampler-viewsoracle applies to any variant that compiles. The tool needs only the Python standard library plus an external DXC executable. It is not registered in CI and has no built-in timeout or threshold:--timeoutis required from the caller as local policy.Families (one property changed each):
control: fixture source unchanged (685 bytes with LF line ends).samples_N: N additional independentSampleLevelstores, flat control flow.branches_B: B extra if/else regions with observable stores.samplebranch_N: oneSampleLevelinside each divergent region.--list-variantsreproduces the recorded source sizes exactly (control 685, samples_1024 107,889, branches_1024 148,909, samplebranch_4096 968,577, 8192 1,946,457, 12288 2,929,337, 16384 3,915,833).--outwrites a compact CSV, or JSON (which also records the DXC version and exact command) when the name ends in.json: HLSL and DXIL bytes, median/min/max wall time, peak working set, outcome (DXIL / timeout / diagnostic), exit codes and, with--ftime-report, the dominant passes and their share of pass time.--repeattakes medians,--extra-arg=-Odadds flags,--work-dirkeeps the generated sources and DXIL.Aggregate reproduction record (
docs/experiments.md)DXC 1.9.2609.5 (
01b62ad47), Windows 11 build 26300, Ryzen 5 5500 (6C/12T, 15.9 GiB), one compile at a time, 90 s local policy. Protocol command shape (--repeat3 up to 1024, 2 for 4096-16384, 1 for rows above 30 s):-OdLog-log slopes are 1.10 (
samples_N), 1.21 (branches_B) and 1.51 (samplebranch_N, 256-8192). Minimal pair, same generator and command:samplebranch_8192compiled in every run (27.9-46.9 s across four runs, 33.73 s in the repetition batch) whilesamplebranch_16384exceeded 90 s every time (193.12 s with a raised limit);samplebranch_12288is the threshold bracket (67.77 s in one session, 90.04 s timeout and 97.68 s with a raised limit in another). Times at the largest sizes vary by 20-45 % across sessions.-ftime-reportfrom a separate diagnostic run with the same flags (Total counts LLVM/DXIL passes only) attributes 81.8 % of the pass time atsamplebranch_8192to the two "Global Value Numbering" instances (14.94 + 7.42 of 27.34 s); the shares are 70.5 % atsamplebranch_4096and 48.0 % atbranches_16384(plus 9.5 % "DXIL simple GVN hoist").-Odremoves 25 %, 64 %, 73 %, 84 % and >95 % of the wall time forsamples_16384,branches_16384,samplebranch_4096,samplebranch_8192andsamplebranch_16384respectively (9.60 s vs 193.12 s);-Vdsaves 4 %. Why the two GVN instances do not scale is a hypothesis about DXC internals and is not established here.Outputs the oracle checked (a)
The existing oracle
offscreen_check <adapter> --spirv-sampler-views <cso>was run on the compiled variants and compares their four control words with the fixture:samples_1024,samples_16384,branches_1024,branches_16384andsamplebranch_1024/4096/8192;samples_1024,branches_1024andsamplebranch_4096;This checks the four control words of each compiled variant against the fixture, not GPU equivalence for arbitrary inputs.
Driver JIT timeout is separate (b)
samplebranch_12288was not dispatched at all: creating its pipeline on the RTX 4060 did not return within about 9 minutes for its 2.77 MB DXIL. That is NVIDIA driver shader JIT during PSO creation, outside DXC, and it is excluded from every DXC time above; it is not part of the compile-time attribution. Its DXIL validates withdxvand keeps the control stores that the smaller variants pass.Archive-replay attribution remains open (c)
The replay profile is not public and this family reaches the policy timeout only at multi-MB HLSL (fixture-scale sources compile in about 0.02 s; the worst measured case below 0.5 MB is 2.54 s). These aggregate measurements therefore cannot say which real records time out or how large their HLSL is. Closing the attribution needs a failing local record that supplies its input size and pass-time totals, for example a
-ftime-reportfrom the same command. Aggregate measurements are enough for this reproduction record, not for a corpus claim. No translator change is proposed and no GPU behavior is claimed.Verification
python -B tools/dxc_compile_time.py --helpexits 0.samplebranch_1024+samplebranch_4096with--repeat 3 --timeout 90produced a consistent CSV: median 0.024 / 0.914 / 8.515 s, DXIL 4004 / 199940 / 827384 bytes, source sizes identical to the record above.samplebranch_8192 --timeout 5recorded outcometimeoutwith DXC exit code 1 (the tool exits 0 because a timeout is a measured outcome).--ftime-reportparsed the GVN share;--extra-arg=-Odand--work-dirwere exercised.python -B tests/docs_links_check.pypasses (13 Markdown files, 155 links);python -B tests/bidi_controls_check.pypasses (652 files).Refs #775
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-23T06:52:51Z.
Verdict: Request changes (reviewed head
721dc1d97f02207ab4a6d74f8d3394f942b303c4, compared againstmain20e4357).Verification
Environment: Windows 11 x64, Python 3.12.10, DXC
1.9.0.5512 (01b62ad47)(C:\VulkanSDK\1.4.363.0\Bin\dxc.exe). Zero-GPU review (offline DXC compilation and Python checks only).Commands and results on
721dc1d:python -B tests/docs_links_check.py(13 files, 155 links) andpython -B tests/bidi_controls_check.py(656 files): both passed.git merge-tree --write-tree main 721dc1d: clean against20e4357(exit 0).python -B tools/dxc_compile_time.py --list-variants: exit 0; all 9 table HLSL byte sizes indocs/experiments.md(control685 B throughsamplebranch_163843,915,833 B) matched byte-for-byte.--variants control,samples_64,branches_64,samplebranch_64 --repeat 2 --timeout 30 --ftime-report --out out.json): exit 0, valid DXIL produced for all 4 variants, Windowspsapipeak working set recorded (16.4–19.4 MiB), CSV and JSON serialization worked cleanly.--target cs_9_9 --variants control --repeat 2): stopped after 1 rep, recordedoutcome=diagnosticandfirst_diagnostic='error: invalid profile cs_9_9'.--variants samplebranch_1024 --repeat 2 --timeout 0.001): killed DXC cleanly without hanging, stopped after 1 rep, recordedoutcome=timeout.--timeout,--timeout 0,--repeat 0, unknown variant,samples_65537,samples_0, missing--dxcpath): 7/7 rejected.Issue to address
FTIME_REsilently drops 3-column-ftime-reporttables whenSystem Timeis zero:On DXC
1.9.0.5512 (01b62ad47), LLVM'sTimerGroupomits the--System Time--column whenever system time is0.0000across all passes, printing 3 time columns instead of 4:samplebranch_64(wall=0.039s):parse_ftime()returned0rows andtotal=None(so--ftime-reportrecordedpass_total_s=Noneandpasses=[]forcontrol,samples_64,branches_64, andsamplebranch_64).samplebranch_1024(wall=0.522s):parse_ftime()returned166rows andtotal={'combined_s': 0.375, 'wall_s': 0.3782}.Making the optional
System Timecolumn optional inFTIME_RE(for example matching 3 or 4([\d.]+)\s+\(\s*[\d.]+%\)columns and taking the last two numbers ascombinedandwall) will make--ftime-reportwork across both small and large variants.AI-assisted review (local Python and offline DXC checks executed locally).