Shaders: --explain --json writes a line per program; --explain-diff #1948

Closed
sombraSoft wants to merge 7 commits from upstream-pr/1958 into main
sombraSoft commented 2026-11-24 23:51:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sombraSoft on 2026-11-24T23:51:27Z.


Stacked on #1957; only the top commit belongs here. Part of #1269.

--explain --json writes JSON Lines (a header with the fingerprint, a line per program as it finishes, a footer with the digest), so a stopped run keeps what it finished. xcl shaders A.json --explain-diff B.json lists the portable numbers that changed per program and totals over the programs in both; local numbers (times, memory) only when both reports come from the same machine.

What is in it

  • Shaders: --explain --json writes a line per program; --explain-diff – crates/xcl/src/shaders/explain/diff.rs, JSON output in explain.rs, the hook in shaders.rs; help and README

Tested

  • NVIDIA GeForce RTX 3060 Ti (driver 32.0.16.2124), AMD Ryzen 9 5900X, Windows 11 Pro 10.0.26300, rustc 1.97.1; tests in debug, smoke run in release; DXC 1.8.2502.11 (Windows SDK 10.0.26100)
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on fb2eeec: 989 passed, 0 failed, 45 ignored
  • SKIPPED (all from existing tests): 18 × no wave64, 1 × no heap windows, 1 × cannot disable the driver cache (Developer Mode off), 3 × per-lane form refused (f16 / VOP3 modifiers)
  • unit tests: the changed numbers of two reports, largest relative change first; a report without a footer is read; other files are refused
  • retail pack, 20 sampled programs, fb2eeec against fb2eeec + #1529 (same machine): DXC −15.1 % in total (two runs of fb2eeec differ by 1.9 %), and 4.5 % more DXIL blocks on the HLSL path (36 391 → 38 013), bitcode +0.2 %

Regression run

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 3060 Ti
title: 55118d47
seconds: 60
exit: 0x0
frames shown: 1075 (PresentX 1075)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15431 MB

this PR (fb2eeec):

xcl-smoke v1
commit: fb2eeece84cca9bc4d50540e2a5b8e1e70c69801
gpu: NVIDIA GeForce RTX 3060 Ti
title: 55118d47
seconds: 60
exit: 0x0
frames shown: 1198 (PresentX 1198)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15334 MB

Not tested

  • AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton
  • the title run does not use --explain; it checks only that nothing else changed
  • --explain-diff does not show changed text fields (e.g. the DXC arguments), only numbers

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the tests and this description. The tests, the pack runs and the smoke runs were run on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5482354173 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1958). Originally posted by [sombraSoft](https://github.com/sombraSoft) on 2026-11-24T23:51:27Z. --- Stacked on #1957; only the top commit belongs here. Part of #1269. `--explain --json` writes JSON Lines (a header with the fingerprint, a line per program as it finishes, a footer with the digest), so a stopped run keeps what it finished. `xcl shaders A.json --explain-diff B.json` lists the portable numbers that changed per program and totals over the programs in both; local numbers (times, memory) only when both reports come from the same machine. **What is in it** - `Shaders: --explain --json writes a line per program; --explain-diff` – `crates/xcl/src/shaders/explain/diff.rs`, JSON output in `explain.rs`, the hook in `shaders.rs`; help and README **Tested** - NVIDIA GeForce RTX 3060 Ti (driver 32.0.16.2124), AMD Ryzen 9 5900X, Windows 11 Pro 10.0.26300, rustc 1.97.1; tests in debug, smoke run in release; DXC 1.8.2502.11 (Windows SDK 10.0.26100) - `cargo test --workspace --no-fail-fast -- --test-threads=4` on fb2eeec: 989 passed, 0 failed, 45 ignored - `SKIPPED` (all from existing tests): 18 × no wave64, 1 × no heap windows, 1 × cannot disable the driver cache (Developer Mode off), 3 × per-lane form refused (f16 / VOP3 modifiers) - unit tests: the changed numbers of two reports, largest relative change first; a report without a footer is read; other files are refused - retail pack, 20 sampled programs, fb2eeec against fb2eeec + #1529 (same machine): DXC −15.1 % in total (two runs of fb2eeec differ by 1.9 %), and 4.5 % more DXIL blocks on the HLSL path (36 391 → 38 013), bitcode +0.2 % **Regression run** main: ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: NVIDIA GeForce RTX 3060 Ti title: 55118d47 seconds: 60 exit: 0x0 frames shown: 1075 (PresentX 1075) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15431 MB ``` this PR (fb2eeec): ``` xcl-smoke v1 commit: fb2eeece84cca9bc4d50540e2a5b8e1e70c69801 gpu: NVIDIA GeForce RTX 3060 Ti title: 55118d47 seconds: 60 exit: 0x0 frames shown: 1198 (PresentX 1198) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15334 MB ``` **Not tested** - AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton - the title run does not use --explain; it checks only that nothing else changed - --explain-diff does not show changed text fields (e.g. the DXC arguments), only numbers **AI use** - Claude Code with Claude Opus 5.5: wrote the code, the tests and this description. The tests, the pack runs and the smoke runs were run on the hardware above.
DavidM1911 commented 2026-11-25 03:05:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:59:34Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (README.md + crates/xcl/src/shaders.rs) — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7151476213 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1958#issuecomment-7151476213). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:59:34Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`README.md` + `crates/xcl/src/shaders.rs`) — needs a rebase before it can be tested.
luckyteagirl commented 2026-11-26 09:04:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:04:57Z.

Review: COMMENTED


On fb2eeec, --explain-diff parses every JSONL line before it checks for a missing footer. If a report is interrupted midway through its final write, it can contain a valid header and completed program records followed by an unterminated fragment such as {"kind":"program". text.lines() passes that fragment to serde_json::from_str, so load returns an EOF parse error and the command exits 2 instead of comparing the completed records. The current interrupted-run test only removes the footer from otherwise complete lines.

Could the loader tolerate an incomplete, unterminated last line while continuing to reject malformed complete or interior lines? A JSONL fixture with one completed program and a truncated final program would exercise the interrupted-run promise. This is source review only; I did not run the CLI fixture.

<!-- greyfinch-sync:ivall/xcl:review:6071170019 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1958#pullrequestreview-6071170019). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T09:04:57Z. **Review:** COMMENTED --- On `fb2eeec`, `--explain-diff` parses every JSONL line before it checks for a missing footer. If a report is interrupted midway through its final write, it can contain a valid header and completed `program` records followed by an unterminated fragment such as `{"kind":"program"`. `text.lines()` passes that fragment to `serde_json::from_str`, so `load` returns an EOF parse error and the command exits 2 instead of comparing the completed records. The current interrupted-run test only removes the footer from otherwise complete lines. Could the loader tolerate an incomplete, unterminated *last* line while continuing to reject malformed complete or interior lines? A JSONL fixture with one completed program and a truncated final program would exercise the interrupted-run promise. This is source review only; I did not run the CLI fixture.

Pull request closed

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
xcl-dev/xcl!1948
No description provided.