tooling: measure DXC compile time on a generated mixed-sampler shader #795

Merged
FZNull merged 5 commits from upstream-pr/801 into main 2026-11-23 07:02:04 +00:00
FZNull commented 2026-11-23 05:41:19 +00:00 (Migrated from github.com)

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.py generates HLSL from the shape of the source-built sampler fixture (tests/spirv_window/sampler.py through 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 existing offscreen_check --spirv-sampler-views oracle 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: --timeout is 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 independent SampleLevel stores, flat control flow.
  • branches_B: B extra if/else regions with observable stores.
  • samplebranch_N: one SampleLevel inside each divergent region.

--list-variants reproduces 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). --out writes 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. --repeat takes medians, --extra-arg=-Od adds flags, --work-dir keeps 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 (--repeat 3 up to 1024, 2 for 4096-16384, 1 for rows above 30 s):

out\pe-env\Scripts\python.exe -B tools\dxc_compile_time.py --dxc <path-to-dxc.exe> --variants control,samples_1024,branches_1024,samplebranch_4096,samplebranch_8192 --repeat 3 --timeout 90 --out out\dxc-compile-time\measurements.csv
variant HLSL bytes DXC wall s peak MiB outcome
control 685 0.023 16.6 DXIL
samples_1024 107,889 0.314 36.7 DXIL
samples_16384 1,735,137 7.804 313.0 DXIL
branches_1024 148,909 0.333 41.0 DXIL
branches_16384 2,465,494 13.904 369.1 DXIL
samplebranch_4096 968,577 8.083 171.3 DXIL
samplebranch_8192 1,946,457 33.726 325.2 DXIL
samplebranch_12288 2,929,337 90.044 438.3 timeout (marginal)
samplebranch_16384 3,915,833 90.046 625.8 timeout
samplebranch_16384, -Od 3,915,833 9.604 442.6 DXIL

Log-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_8192 compiled in every run (27.9-46.9 s across four runs, 33.73 s in the repetition batch) while samplebranch_16384 exceeded 90 s every time (193.12 s with a raised limit); samplebranch_12288 is 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-report from a separate diagnostic run with the same flags (Total counts LLVM/DXIL passes only) attributes 81.8 % of the pass time at samplebranch_8192 to the two "Global Value Numbering" instances (14.94 + 7.42 of 27.34 s); the shares are 70.5 % at samplebranch_4096 and 48.0 % at branches_16384 (plus 9.5 % "DXIL simple GVN hoist"). -Od removes 25 %, 64 %, 73 %, 84 % and >95 % of the wall time for samples_16384, branches_16384, samplebranch_4096, samplebranch_8192 and samplebranch_16384 respectively (9.60 s vs 193.12 s); -Vd saves 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:

  • RTX 4060 (driver 32.0.16.2124) passed for control, samples_1024, samples_16384, branches_1024, branches_16384 and samplebranch_1024/4096/8192;
  • WARP (10.0.26100.10068) passed for the smaller subset: control, samples_1024, branches_1024 and samplebranch_4096;
  • a negative control with one UV constant changed failed on both adapters;
  • every emitted CSO was accepted by the DXC validator from the same package.

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_12288 was 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 with dxv and 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-report from 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 --help exits 0.
  • control + samplebranch_1024 + samplebranch_4096 with --repeat 3 --timeout 90 produced 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 5 recorded outcome timeout with DXC exit code 1 (the tool exits 0 because a timeout is a measured outcome).
  • --ftime-report parsed the GVN share; --extra-arg=-Od and --work-dir were exercised.
  • python -B tests/docs_links_check.py passes (13 Markdown files, 155 links); python -B tests/bidi_controls_check.py passes (652 files).
  • No new dependencies, no game files, no CI registration.

Refs #775

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6553078109 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/801). Originally posted by [FZNull](https://github.com/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.py` generates HLSL from the shape of the source-built sampler fixture (`tests/spirv_window/sampler.py` through 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 existing `offscreen_check --spirv-sampler-views` oracle 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: `--timeout` is 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 independent `SampleLevel` stores, flat control flow. - `branches_B`: B extra if/else regions with observable stores. - `samplebranch_N`: one `SampleLevel` inside each divergent region. `--list-variants` reproduces 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). `--out` writes 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. `--repeat` takes medians, `--extra-arg=-Od` adds flags, `--work-dir` keeps 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 (`--repeat` 3 up to 1024, 2 for 4096-16384, 1 for rows above 30 s): ```powershell out\pe-env\Scripts\python.exe -B tools\dxc_compile_time.py --dxc <path-to-dxc.exe> --variants control,samples_1024,branches_1024,samplebranch_4096,samplebranch_8192 --repeat 3 --timeout 90 --out out\dxc-compile-time\measurements.csv ``` | variant | HLSL bytes | DXC wall s | peak MiB | outcome | |---|---:|---:|---:|---| | control | 685 | 0.023 | 16.6 | DXIL | | samples_1024 | 107,889 | 0.314 | 36.7 | DXIL | | samples_16384 | 1,735,137 | 7.804 | 313.0 | DXIL | | branches_1024 | 148,909 | 0.333 | 41.0 | DXIL | | branches_16384 | 2,465,494 | 13.904 | 369.1 | DXIL | | samplebranch_4096 | 968,577 | 8.083 | 171.3 | DXIL | | samplebranch_8192 | 1,946,457 | 33.726 | 325.2 | DXIL | | samplebranch_12288 | 2,929,337 | 90.044 | 438.3 | timeout (marginal) | | samplebranch_16384 | 3,915,833 | 90.046 | 625.8 | timeout | | samplebranch_16384, `-Od` | 3,915,833 | 9.604 | 442.6 | DXIL | Log-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_8192` compiled in every run (27.9-46.9 s across four runs, 33.73 s in the repetition batch) while `samplebranch_16384` exceeded 90 s every time (193.12 s with a raised limit); `samplebranch_12288` is 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-report` from a separate diagnostic run with the same flags (Total counts LLVM/DXIL passes only) attributes 81.8 % of the pass time at `samplebranch_8192` to the two "Global Value Numbering" instances (14.94 + 7.42 of 27.34 s); the shares are 70.5 % at `samplebranch_4096` and 48.0 % at `branches_16384` (plus 9.5 % "DXIL simple GVN hoist"). `-Od` removes 25 %, 64 %, 73 %, 84 % and >95 % of the wall time for `samples_16384`, `branches_16384`, `samplebranch_4096`, `samplebranch_8192` and `samplebranch_16384` respectively (9.60 s vs 193.12 s); `-Vd` saves 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: - RTX 4060 (driver 32.0.16.2124) passed for **control**, `samples_1024`, `samples_16384`, `branches_1024`, `branches_16384` and `samplebranch_1024/4096/8192`; - WARP (10.0.26100.10068) passed for the smaller subset: **control**, `samples_1024`, `branches_1024` and `samplebranch_4096`; - a negative control with one UV constant changed failed on both adapters; - every emitted CSO was accepted by the DXC validator from the same package. 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_12288` was **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 with `dxv` and 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-report` from 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 --help` exits 0. - control + `samplebranch_1024` + `samplebranch_4096` with `--repeat 3 --timeout 90` produced 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 5` recorded outcome `timeout` with DXC exit code 1 (the tool exits 0 because a timeout is a measured outcome). - `--ftime-report` parsed the GVN share; `--extra-arg=-Od` and `--work-dir` were exercised. - `python -B tests/docs_links_check.py` passes (13 Markdown files, 155 links); `python -B tests/bidi_controls_check.py` passes (652 files). - No new dependencies, no game files, no CI registration. Refs #775 AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:51 +00:00
MatyEjsr commented 2026-11-24 06:49:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-23T06:52:51Z.


Verdict: Request changes (reviewed head 721dc1d97f02207ab4a6d74f8d3394f942b303c4, compared against main 20e4357).

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) and python -B tests/bidi_controls_check.py (656 files): both passed.
  • git merge-tree --write-tree main 721dc1d: clean against 20e4357 (exit 0).
  • python -B tools/dxc_compile_time.py --list-variants: exit 0; all 9 table HLSL byte sizes in docs/experiments.md (control 685 B through samplebranch_16384 3,915,833 B) matched byte-for-byte.
  • Live DXC runs (--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, Windows psapi peak working set recorded (16.4–19.4 MiB), CSV and JSON serialization worked cleanly.
  • Negative controls:
    • Diagnostic (--target cs_9_9 --variants control --repeat 2): stopped after 1 rep, recorded outcome=diagnostic and first_diagnostic='error: invalid profile cs_9_9'.
    • Timeout (--variants samplebranch_1024 --repeat 2 --timeout 0.001): killed DXC cleanly without hanging, stopped after 1 rep, recorded outcome=timeout.
    • CLI validation (missing --timeout, --timeout 0, --repeat 0, unknown variant, samples_65537, samples_0, missing --dxc path): 7/7 rejected.

Issue to address

FTIME_RE silently drops 3-column -ftime-report tables when System Time is zero:

On DXC 1.9.0.5512 (01b62ad47), LLVM's TimerGroup omits the --System Time-- column whenever system time is 0.0000 across all passes, printing 3 time columns instead of 4:

  • samplebranch_64 (wall=0.039s):
    ;    ---User Time---   --User+System--   ---Wall Time---  --- Name ---
    ;    0.0156 (100.0%)   0.0156 (100.0%)   0.0161 (100.0%)  Total
    
    parse_ftime() returned 0 rows and total=None (so --ftime-report recorded pass_total_s=None and passes=[] for control, samples_64, branches_64, and samplebranch_64).
  • samplebranch_1024 (wall=0.522s):
    ;    ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
    ;    0.2969 (100.0%)   0.0781 (100.0%)   0.3750 (100.0%)   0.3782 (100.0%)  Total
    
    parse_ftime() returned 166 rows and total={'combined_s': 0.375, 'wall_s': 0.3782}.

Making the optional System Time column optional in FTIME_RE (for example matching 3 or 4 ([\d.]+)\s+\(\s*[\d.]+%\) columns and taking the last two numbers as combined and wall) will make --ftime-report work across both small and large variants.

AI-assisted review (local Python and offline DXC checks executed locally).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7093766744 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/801#issuecomment-7093766744). Originally posted by [MatyEjsr](https://github.com/MatyEjsr) on 2026-11-23T06:52:51Z. --- **Verdict: Request changes** (reviewed head `721dc1d97f02207ab4a6d74f8d3394f942b303c4`, compared against `main` `20e4357`). ### 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) and `python -B tests/bidi_controls_check.py` (656 files): both passed. - `git merge-tree --write-tree main 721dc1d`: clean against `20e4357` (exit 0). - `python -B tools/dxc_compile_time.py --list-variants`: exit 0; all 9 table HLSL byte sizes in `docs/experiments.md` (`control` 685 B through `samplebranch_16384` 3,915,833 B) matched byte-for-byte. - Live DXC runs (`--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, Windows `psapi` peak working set recorded (`16.4`–`19.4 MiB`), CSV and JSON serialization worked cleanly. - Negative controls: - Diagnostic (`--target cs_9_9 --variants control --repeat 2`): stopped after 1 rep, recorded `outcome=diagnostic` and `first_diagnostic='error: invalid profile cs_9_9'`. - Timeout (`--variants samplebranch_1024 --repeat 2 --timeout 0.001`): killed DXC cleanly without hanging, stopped after 1 rep, recorded `outcome=timeout`. - CLI validation (missing `--timeout`, `--timeout 0`, `--repeat 0`, unknown variant, `samples_65537`, `samples_0`, missing `--dxc` path): 7/7 rejected. ### Issue to address **`FTIME_RE` silently drops 3-column `-ftime-report` tables when `System Time` is zero:** On DXC `1.9.0.5512 (01b62ad47)`, LLVM's `TimerGroup` omits the `--System Time--` column whenever system time is `0.0000` across all passes, printing 3 time columns instead of 4: - `samplebranch_64` (`wall=0.039s`): ```text ; ---User Time--- --User+System-- ---Wall Time--- --- Name --- ; 0.0156 (100.0%) 0.0156 (100.0%) 0.0161 (100.0%) Total ``` `parse_ftime()` returned `0` rows and `total=None` (so `--ftime-report` recorded `pass_total_s=None` and `passes=[]` for `control`, `samples_64`, `branches_64`, and `samplebranch_64`). - `samplebranch_1024` (`wall=0.522s`): ```text ; ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- ; 0.2969 (100.0%) 0.0781 (100.0%) 0.3750 (100.0%) 0.3782 (100.0%) Total ``` `parse_ftime()` returned `166` rows and `total={'combined_s': 0.375, 'wall_s': 0.3782}`. Making the optional `System Time` column optional in `FTIME_RE` (for example matching 3 or 4 `([\d.]+)\s+\(\s*[\d.]+%\)` columns and taking the last two numbers as `combined` and `wall`) will make `--ftime-report` work across both small and large variants. *AI-assisted review (local Python and offline DXC checks executed locally).*
Sign in to join this conversation.
No reviewers
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
R0Y00/Xbox2Windows!795
No description provided.