tooling: isolate the DXC GVN cost to conditional UAV stores #911

Merged
rasptum merged 1 commit from upstream-pr/918 into main 2026-11-23 17:30:38 +00:00
rasptum commented 2026-11-23 17:09:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T17:09:11Z.


Refs #775. This advances the #676 replay-profile compile-time investigation and touches one interface: tools/dxc_compile_time.py plus the new compile-only CTest dxc_compile_time_gvn.

What this isolates

Reducing the merged samplebranch_N family one element at a time shows the GVN cost needs no sampler. Removing the samples, the else arm, the static gl_WorkGroupID reads or the shared condition operand left the superlinear growth in place. Making the stores unconditional removed it. The minimal pair, added to the tool:

  • condstore_N: N if (((gl_WorkGroupID.x + k) & 1u) != 0u) _4.Store(...) into the raw UAV, with no sampling beyond the fixture's two control stores.
  • stores_N: the same source without the if wrappers. The test checks that this is the only difference.

-print-before gvn (DXC 1.9) shows each conditional block re-creating the UAV handle (createHandleForLib + annotateHandle), with no memory operations in the join blocks between them. A plausible mechanism is a non-local memory-dependence walk per handle call over all earlier joins, with cached results, which would be quadratic in time and memory. That mechanism is a hypothesis about DXC internals. The measured facts are below.

The tool also now accepts the three-column -ftime-report table that LLVM prints when no pass records system time. Without that, small variants reported no passes (the issue raised in the #801 review). The existing variant sizes are unchanged (--list-variants).

Measurements (compiler only, no PSO or dispatch)

Ryzen 7 3700X (8C/16T, 32 GiB), Windows 10 build 19045, one compile at a time, -T cs_6_6 -E main -enable-16bit-types. The DXC builds are 1.7.2308.16 (52da17e29, Windows SDK 10.0.26100) and 1.9.0.5512 (01b62ad47, LunarG Vulkan SDK 1.4.363.0). The maintainer's 1.8.2502.11 build was not available on this machine.

variant setting HLSL bytes 1.7 wall s 1.7 peak MiB 1.7 outcome 1.9 wall s 1.9 peak MiB 1.9 outcome
stores_16384 default 663,813 2.598 90.2 DXIL 2.519 91.4 DXIL
condstore_1024 default 107,095 0.948 51.5 DXIL 1.278 54.2 DXIL
condstore_2048 default 214,615 3.259 141.2 DXIL 5.045 145.8 DXIL
condstore_4096 default 429,655 12.993 480.1 DXIL 23.906 485.3 DXIL
condstore_8192 90 s policy 859,735 68.794 1,806.0 DXIL 90.093 1,807.8 timeout
condstore_16384 90 s policy 1,734,047 90.269 2,548.6 timeout 90.261 2,735.4 timeout
condstore_16384 900 s limit 1,734,047 382.221 6,917.9 DXIL 645.364 6,918.6 DXIL
condstore_16384 -opt-disable gvn 1,734,047 7.138 221.3 DXIL 6.351 228.7 DXIL

The rows up to condstore_4096 are medians of three runs; the others are single runs. In -ftime-report for condstore_4096, GVN takes 93.1 % of pass time on 1.7 and 95.3 % on 1.9. stores_4096 has no GVN among its top two passes. The policy timeout falls at 0.86-1.73 MB here, against 2.9-3.9 MB for samplebranch_N. The independent rerun of the merged samplebranch variants on both builds is in docs/experiments.md. -opt-disable gvn there brings samplebranch_16384 to 18-28 s. -opt-disable gvn is a labelled diagnostic setting only. Its DXIL is not GPU-checked and it is not proposed as a replay flag. This does not attribute the archive cohort: the loop-rotate/Jump Threading archive profile is different.

Test

dxc_compile_time_gvn (TIMEOUT 300, SKIP_RETURN_CODE 77) has no wall-time threshold. It checks:

  • source shape, and pinned sizes for the recorded variants;
  • 3- and 4-column parser input;
  • DXIL outcome for control, condstore_256 and stores_256;
  • negative controls: a forced 1 ms timeout must classify as timeout and an invalid profile cs_9_9 as diagnostic;
  • GVN share of the pass wall time: at least 50 % for condstore_1024, below 25 % for stores_1024, and absent under -opt-disable gvn.

If a future DXC loses the GVN profile, the test exits 77 instead of failing. Test-only negative controls, run by hand: putting the old 4-column regex back fails the parser check, and changing the condstore condition fails the source-shape check.

Commands and results (commit 47be65f, rebased on da9bc9c)

.\tools\dev.ps1
cmake --preset dev; cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^dxc_compile_time_gvn$' -V      # Passed 3.38 s (GVN 76.0 % / 6.9 % / 0)
cmake --preset release; cmake --build --preset release
ctest --preset release --no-tests=error -R '^dxc_compile_time_gvn$' -V  # Passed 1.92 s (77.3 % / 4.8 % / 0)
ctest --preset dev --no-tests=error -R '^(docs_links|script_state_literals|script_path_links)$'      # 3/3 passed (also release)
python -B tests/dxc_compile_time_check.py <dxc>   # OK on 1.7.2308.16 and 1.9.0.5512
python -B tests/form_coverage_check.py; python -B tests/docs_links_check.py; python -B tests/bidi_controls_check.py   # all pass

Both presets built and tested at ae65994 on the previous base. After rebasing onto da9bc9c (clean merge, no conflicts), the fast checks above and tests/dxc_compile_time_check.py were rerun. The full dev/release builds were not repeated on the final commit. No capability skips were seen. The configured CTest DXC is 1.7.2308.16.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6564618762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/918). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T17:09:11Z. --- Refs #775. This advances the #676 replay-profile compile-time investigation and touches one interface: `tools/dxc_compile_time.py` plus the new compile-only CTest `dxc_compile_time_gvn`. ## What this isolates Reducing the merged `samplebranch_N` family one element at a time shows the GVN cost needs no sampler. Removing the samples, the else arm, the static `gl_WorkGroupID` reads or the shared condition operand left the superlinear growth in place. Making the stores unconditional removed it. The minimal pair, added to the tool: - `condstore_N`: N `if (((gl_WorkGroupID.x + k) & 1u) != 0u) _4.Store(...)` into the raw UAV, with no sampling beyond the fixture's two control stores. - `stores_N`: the same source without the `if` wrappers. The test checks that this is the only difference. `-print-before gvn` (DXC 1.9) shows each conditional block re-creating the UAV handle (`createHandleForLib` + `annotateHandle`), with no memory operations in the join blocks between them. A plausible mechanism is a non-local memory-dependence walk per handle call over all earlier joins, with cached results, which would be quadratic in time and memory. That mechanism is a hypothesis about DXC internals. The measured facts are below. The tool also now accepts the three-column `-ftime-report` table that LLVM prints when no pass records system time. Without that, small variants reported no passes (the issue raised in the #801 review). The existing variant sizes are unchanged (`--list-variants`). ## Measurements (compiler only, no PSO or dispatch) Ryzen 7 3700X (8C/16T, 32 GiB), Windows 10 build 19045, one compile at a time, `-T cs_6_6 -E main -enable-16bit-types`. The DXC builds are 1.7.2308.16 (`52da17e29`, Windows SDK 10.0.26100) and 1.9.0.5512 (`01b62ad47`, LunarG Vulkan SDK 1.4.363.0). The maintainer's 1.8.2502.11 build was not available on this machine. | variant | setting | HLSL bytes | 1.7 wall s | 1.7 peak MiB | 1.7 outcome | 1.9 wall s | 1.9 peak MiB | 1.9 outcome | |---|---|---:|---:|---:|---|---:|---:|---| | stores_16384 | default | 663,813 | 2.598 | 90.2 | DXIL | 2.519 | 91.4 | DXIL | | condstore_1024 | default | 107,095 | 0.948 | 51.5 | DXIL | 1.278 | 54.2 | DXIL | | condstore_2048 | default | 214,615 | 3.259 | 141.2 | DXIL | 5.045 | 145.8 | DXIL | | condstore_4096 | default | 429,655 | 12.993 | 480.1 | DXIL | 23.906 | 485.3 | DXIL | | condstore_8192 | 90 s policy | 859,735 | 68.794 | 1,806.0 | DXIL | 90.093 | 1,807.8 | timeout | | condstore_16384 | 90 s policy | 1,734,047 | 90.269 | 2,548.6 | timeout | 90.261 | 2,735.4 | timeout | | condstore_16384 | 900 s limit | 1,734,047 | 382.221 | 6,917.9 | DXIL | 645.364 | 6,918.6 | DXIL | | condstore_16384 | `-opt-disable gvn` | 1,734,047 | 7.138 | 221.3 | DXIL | 6.351 | 228.7 | DXIL | The rows up to `condstore_4096` are medians of three runs; the others are single runs. In `-ftime-report` for `condstore_4096`, GVN takes 93.1 % of pass time on 1.7 and 95.3 % on 1.9. `stores_4096` has no GVN among its top two passes. The policy timeout falls at 0.86-1.73 MB here, against 2.9-3.9 MB for `samplebranch_N`. The independent rerun of the merged `samplebranch` variants on both builds is in `docs/experiments.md`. `-opt-disable gvn` there brings `samplebranch_16384` to 18-28 s. `-opt-disable gvn` is a labelled diagnostic setting only. Its DXIL is not GPU-checked and it is not proposed as a replay flag. This does not attribute the archive cohort: the `loop-rotate`/Jump Threading archive profile is different. ## Test `dxc_compile_time_gvn` (TIMEOUT 300, SKIP_RETURN_CODE 77) has no wall-time threshold. It checks: - source shape, and pinned sizes for the recorded variants; - 3- and 4-column parser input; - DXIL outcome for control, `condstore_256` and `stores_256`; - negative controls: a forced 1 ms timeout must classify as `timeout` and an invalid profile `cs_9_9` as `diagnostic`; - GVN share of the pass wall time: at least 50 % for `condstore_1024`, below 25 % for `stores_1024`, and absent under `-opt-disable gvn`. If a future DXC loses the GVN profile, the test exits 77 instead of failing. Test-only negative controls, run by hand: putting the old 4-column regex back fails the parser check, and changing the condstore condition fails the source-shape check. ## Commands and results (commit 47be65f, rebased on `da9bc9c`) ```powershell .\tools\dev.ps1 cmake --preset dev; cmake --build --preset dev ctest --preset dev --no-tests=error -R '^dxc_compile_time_gvn$' -V # Passed 3.38 s (GVN 76.0 % / 6.9 % / 0) cmake --preset release; cmake --build --preset release ctest --preset release --no-tests=error -R '^dxc_compile_time_gvn$' -V # Passed 1.92 s (77.3 % / 4.8 % / 0) ctest --preset dev --no-tests=error -R '^(docs_links|script_state_literals|script_path_links)$' # 3/3 passed (also release) python -B tests/dxc_compile_time_check.py <dxc> # OK on 1.7.2308.16 and 1.9.0.5512 python -B tests/form_coverage_check.py; python -B tests/docs_links_check.py; python -B tests/bidi_controls_check.py # all pass ``` Both presets built and tested at `ae65994` on the previous base. After rebasing onto `da9bc9c` (clean merge, no conflicts), the fast checks above and `tests/dxc_compile_time_check.py` were rerun. The full dev/release builds were not repeated on the final commit. No capability skips were seen. The configured CTest DXC is 1.7.2308.16. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:45:24 +00:00
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!911
No description provided.