Shaders: share verified compute blobs across preparation worker counts #3086

Merged
Royalflamejlh merged 1 commit from upstream-pr/3086 into main 2026-11-28 03:27:04 +00:00
Royalflamejlh commented 2026-11-28 02:42:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-28T02:42:35Z.


The launch pass keeps a receipt of the compute blobs it validated on this adapter and driver (warm_blobs::Verified), so a later launch takes them without validating them again. The receipt's file name hashed XCL_PRECOMPILE_SLICE, the worker's i/count, into its key. A launch with another worker count (another machine, a different XCL_PREPARE_WORKERS, or the count #2705's fix changes) found none of its receipts and validated every blob again.

This keeps one receipt per native identity (verified-compute-v2-<native>.bin), imports the v1 files of every slice of the same identity once, merges concurrent writers under a lock file before it replaces the receipt, and saves every 64 new entries so an interrupted pass keeps what it validated (a failed save is tried again after 64 more).

What is in it

  • crates/xcl/src/shaders/warm_blobs.rs: the v2 receipt, the v1 import, the locked merge and the checkpoints; a test with two workers opened before either writes, a v1 slice file to import, another device's identity, and the checkpoint a dropped worker leaves.
  • README.md: one line.

Tested

  • Linux, Wine 11.21 Staging, Mesa lavapipe (no GPU), Rust 1.98.0, release, x86_64-pc-windows-gnu: cargo test -p xcl --lib warm_blobs -- --test-threads=4 at fdbac840: 3 passed, 0 failed, 0 ignored (1408 filtered out), with a_failed_checkpoint_is_tried_again_after_64_more_entries

Regression run

  • not made: scripts/smoke.ps1 needs Windows (see Not tested).

Not tested

  • Windows; the whole suite; scripts/smoke.ps1 on main and on this head; a launch with and without it, to count the validations it saves.

AI use

  • The change was written with OpenAI Codex (the model is to be added by the author). Claude Code (Claude Opus 5.5) ran the tests and wrote this description.
<!-- greyfinch-sync:ivall/xcl:issue:5535905829 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-11-28T02:42:35Z. --- The launch pass keeps a receipt of the compute blobs it validated on this adapter and driver (`warm_blobs::Verified`), so a later launch takes them without validating them again. The receipt's file name hashed `XCL_PRECOMPILE_SLICE`, the worker's `i/count`, into its key. A launch with another worker count (another machine, a different `XCL_PREPARE_WORKERS`, or the count #2705's fix changes) found none of its receipts and validated every blob again. This keeps one receipt per native identity (`verified-compute-v2-<native>.bin`), imports the v1 files of every slice of the same identity once, merges concurrent writers under a lock file before it replaces the receipt, and saves every 64 new entries so an interrupted pass keeps what it validated (a failed save is tried again after 64 more). **What is in it** - `crates/xcl/src/shaders/warm_blobs.rs`: the v2 receipt, the v1 import, the locked merge and the checkpoints; a test with two workers opened before either writes, a v1 slice file to import, another device's identity, and the checkpoint a dropped worker leaves. - `README.md`: one line. **Tested** - Linux, Wine 11.21 Staging, Mesa lavapipe (no GPU), Rust 1.98.0, release, `x86_64-pc-windows-gnu`: `cargo test -p xcl --lib warm_blobs -- --test-threads=4` at `fdbac840`: 3 passed, 0 failed, 0 ignored (1408 filtered out), with `a_failed_checkpoint_is_tried_again_after_64_more_entries` **Regression run** - not made: `scripts/smoke.ps1` needs Windows (see Not tested). **Not tested** - Windows; the whole suite; `scripts/smoke.ps1` on `main` and on this head; a launch with and without it, to count the validations it saves. **AI use** - The change was written with OpenAI Codex (the model is to be added by the author). Claude Code (Claude Opus 5.5) ran the tests and wrote this description.
andrewDoing commented 2026-11-28 03:10:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T03:10:37Z.


I checked the checkpoint failure path at head f147360f with a deterministic Windows Rust probe. It uses the exact receipt open/record/save/flush/merge methods, real per-receipt file locking and disk reads, and a mocked final writer that either succeeds or persistently fails. Each arm records 1,024 distinct synthetic keys.

Final writer Checkpoint attempts Bytes serialized
Success 16 209,024
Persistent failure 961 12,554,504

After the first failed checkpoint, the dirty count remains at or above the threshold, so every subsequent record serializes and retries while taking the locks. When the writer was restored, an explicit final save succeeded and all keys, including the last, were present on reopen in both arms.

This is failure-path amplification, not observed title timing or evidence of data loss in the successful final-save control. A separate next-attempt threshold or backoff could bound retries while keeping unsaved entries dirty and preserving the final save; any change needs to retain recovery semantics. The final replacement failure was injected in the probe, not produced by a real filesystem failure.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the probe; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7232854888 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7232854888). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T03:10:37Z. --- I checked the checkpoint failure path at head `f147360f` with a deterministic Windows Rust probe. It uses the exact receipt open/record/save/flush/merge methods, real per-receipt file locking and disk reads, and a mocked final writer that either succeeds or persistently fails. Each arm records 1,024 distinct synthetic keys. | Final writer | Checkpoint attempts | Bytes serialized | | --- | ---: | ---: | | Success | 16 | 209,024 | | Persistent failure | 961 | 12,554,504 | After the first failed checkpoint, the dirty count remains at or above the threshold, so every subsequent record serializes and retries while taking the locks. When the writer was restored, an explicit final save succeeded and all keys, including the last, were present on reopen in both arms. This is failure-path amplification, not observed title timing or evidence of data loss in the successful final-save control. A separate next-attempt threshold or backoff could bound retries while keeping unsaved entries dirty and preserving the final save; any change needs to retain recovery semantics. The final replacement failure was injected in the probe, not produced by a real filesystem failure. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the probe; Codex reviewed and prepared this report.
fromthemoonx commented 2026-11-28 03:14:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-28T03:14:59Z.


Windows run (listed under Not tested): the whole suite passes. The new test passes 40 of 40, and it catches each part of the change when that part is removed.

Tested: f147360 (its base is current main 753e8b1, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 1513 passed, 0 failed, 47 ignored; 25 SKIPPED lines (no wave64, refused per-lane f16/f32 forms, heap_window_out_of_memory_falls_back_to_the_switch_form)
the 2 warm_blobs tests alone, 40 runs each; shaders:: (41 tests) at --test-threads=8, 40 runs 40 of 40 each; 40 of 40

Scratch mutations, 10 runs of each test (warm_receipt_matches_only_the_validated_blob_and_layout passes under all four):

mutation workers_reuse_previous_slices_and_merge_concurrent_checkpoints
merge_and_save does not read the saved receipt before writing fails 10 of 10 (merged.contains(&[2, i, 0]) && merged.contains(&[3, i, 0]))
lock.lock() removed fails 10 of 10 (same assertion)
no checkpoint at 64 unsaved entries fails 10 of 10 (contains(&[4, 63, 0]))
v1 slice files not imported fails 10 of 10 (a.contains(&first))

So on Windows the lock holds between two handles in one process, and the replace under it works.

Not tested: a launch with and without the change (no title here), a release build.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch mutations and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7232918376 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7232918376). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-11-28T03:14:59Z. --- **Windows run (listed under Not tested): the whole suite passes. The new test passes 40 of 40, and it catches each part of the change when that part is removed.** **Tested:** `f147360` (its base is current `main` `753e8b1`, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug. | | result | |---|---| | `cargo test --workspace --no-fail-fast -- --test-threads=4` | 1513 passed, 0 failed, 47 ignored; 25 `SKIPPED` lines (no wave64, refused per-lane f16/f32 forms, `heap_window_out_of_memory_falls_back_to_the_switch_form`) | | the 2 `warm_blobs` tests alone, 40 runs each; `shaders::` (41 tests) at `--test-threads=8`, 40 runs | 40 of 40 each; 40 of 40 | Scratch mutations, 10 runs of each test (`warm_receipt_matches_only_the_validated_blob_and_layout` passes under all four): | mutation | `workers_reuse_previous_slices_and_merge_concurrent_checkpoints` | |---|---| | `merge_and_save` does not read the saved receipt before writing | fails 10 of 10 (`merged.contains(&[2, i, 0]) && merged.contains(&[3, i, 0])`) | | `lock.lock()` removed | fails 10 of 10 (same assertion) | | no checkpoint at 64 unsaved entries | fails 10 of 10 (`contains(&[4, 63, 0])`) | | v1 slice files not imported | fails 10 of 10 (`a.contains(&first)`) | So on Windows the lock holds between two handles in one process, and the replace under it works. **Not tested:** a launch with and without the change (no title here), a release build. **AI use:** Claude Code (Claude Opus 5.5) ran the tests and the scratch mutations and wrote this report.
Royalflamejlh commented 2026-11-28 03:16:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-28T03:16:10Z.


Confirmed and fixed in fdbac840 (squashed into the PR's commit): after a failed checkpoint, record tries again only once 64 more entries are unsaved (Entries::failed_at), and a successful save clears it. The final save still writes whatever is unsaved.

New test a_failed_checkpoint_is_tried_again_after_64_more_entries: a directory sits where the receipt goes, so its replacement fails; after 100 records the only attempt was at 64; with the directory gone, the next attempt at 128 saves all of them. With the old unsaved >= 64 it fails (left: 100, right: 64: an attempt on every record from 64 on).

cargo test -p xcl --lib warm_blobs -- --test-threads=4 under Wine 11.21 (Linux, no GPU, Rust 1.98.0, release): 3 passed, 0 failed.

AI use: Claude Code (Claude Opus 5.5) wrote the fix and the test, ran them and wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7232935141 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7232935141). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-11-28T03:16:10Z. --- Confirmed and fixed in `fdbac840` (squashed into the PR's commit): after a failed checkpoint, `record` tries again only once 64 more entries are unsaved (`Entries::failed_at`), and a successful save clears it. The final `save` still writes whatever is unsaved. New test `a_failed_checkpoint_is_tried_again_after_64_more_entries`: a directory sits where the receipt goes, so its replacement fails; after 100 records the only attempt was at 64; with the directory gone, the next attempt at 128 saves all of them. With the old `unsaved >= 64` it fails (`left: 100, right: 64`: an attempt on every record from 64 on). `cargo test -p xcl --lib warm_blobs -- --test-threads=4` under Wine 11.21 (Linux, no GPU, Rust 1.98.0, release): 3 passed, 0 failed. **AI use:** Claude Code (Claude Opus 5.5) wrote the fix and the test, ran them and wrote this reply.
andrewDoing commented 2026-11-28 03:24:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T03:24:50Z.


I retested the checkpoint retry fix with a real Windows replacement failure, comparing original f147360f and updated fdbac840. The probe uses each revision's exact receipt methods and production temp-create/write/rename/cleanup path, with two test-only counters.

Each run seeded one key, then held the existing receipt open with read/write sharing but without delete sharing while recording 1,024 new keys. Under that lock:

Revision Replacement attempts Bytes serialized
Original 961 12,577,568
Updated 16 209,408

Healthy controls were 16 attempts / 209,408 bytes on both revisions. The locked on-disk receipt remained at its seeded key; after closing the handle and explicitly saving, all 1,025 exact keys were present on reopen in both cases.

This verifies bounded checkpoint retries and eventual explicit-save recovery under the tested sharing violation. It does not measure retail startup time or other filesystem failure modes.

AI use: OpenAI Codex with GPT-6.2 Astra ran the tests; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7233053634 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7233053634). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T03:24:50Z. --- I retested the checkpoint retry fix with a real Windows replacement failure, comparing original `f147360f` and updated `fdbac840`. The probe uses each revision's exact receipt methods and production temp-create/write/rename/cleanup path, with two test-only counters. Each run seeded one key, then held the existing receipt open with read/write sharing but without delete sharing while recording 1,024 new keys. Under that lock: | Revision | Replacement attempts | Bytes serialized | | --- | ---: | ---: | | Original | 961 | 12,577,568 | | Updated | 16 | 209,408 | Healthy controls were 16 attempts / 209,408 bytes on both revisions. The locked on-disk receipt remained at its seeded key; after closing the handle and explicitly saving, all 1,025 exact keys were present on reopen in both cases. This verifies bounded checkpoint retries and eventual explicit-save recovery under the tested sharing violation. It does not measure retail startup time or other filesystem failure modes. AI use: OpenAI Codex with GPT-6.2 Astra ran the tests; Codex reviewed and prepared this report.
thehollowedone commented 2026-11-28 03:34:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T03:34:04Z.


Independent Windows check of #3086 head fdbac840, completed as the PR merged. Windows 11 build 26300, RTX 3080 Ti (driver 621.35), rustc 1.99.1 MSVC, DXC/DXIL 1.8.2502.11.

Tested

  • cargo build --offline --locked -j 4 --workspace: passed.
  • cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4: 1,513 passed, 1 failed, 47 ignored, with 25 SKIPPED GPU notices. All three shaders::warm_blobs::tests passed, including the new failed-checkpoint retry test.
  • The sole failure was gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (cached_only console_mesh hit: "DXIL not compiled yet"). I ran that fully qualified test alone on the PR's untouched parent 753e8b1a: 0 passed, 1 failed, 0 ignored, with the same error. The full-suite failure is therefore not introduced by this PR.

Regression run
Clean cargo build --release --offline --locked -j 4 -p xcl builds, same local title, adapter, XCL_PREPARE=0, XCL_ADAPTER=nvidia, and 60-second duration in both runs. These are the blocks printed by scripts/smoke.ps1:

xcl-smoke v1
commit: d85f2c6c34a7a349def5893d9af22bb79614e774
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1364 (PresentX 1364)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14286 MB
xcl-smoke v1
commit: fdbac840ba68b1706136564fbcfa8ddffb1d5b8d
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1672 (PresentX 1673)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14169 MB

The pair is a runtime regression check, not a measurement of this PR's startup saving: XCL_PREPARE=0 bypassed shader preparation, and the two commits include other upstream changes. No input was supplied, so progress beyond the initial screens was not verified. I did not run a prepared title launch or measure receipt reuse across different worker counts on this hardware.

AI use: Codex (GPT-6.2 Sol) ran the builds, suite, parent control and paired smoke, checked the outputs, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7233179888 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7233179888). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T03:34:04Z. --- Independent Windows check of [#3086 head `fdbac840`](https://github.com/xcl-dev/xcl/commit/fdbac840ba68b1706136564fbcfa8ddffb1d5b8d), completed as the PR merged. Windows 11 build 26300, RTX 3080 Ti (driver 621.35), rustc 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. **Tested** - `cargo build --offline --locked -j 4 --workspace`: passed. - `cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4`: **1,513 passed, 1 failed, 47 ignored**, with 25 `SKIPPED` GPU notices. All three `shaders::warm_blobs::tests` passed, including the new failed-checkpoint retry test. - The sole failure was `gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk` (`cached_only console_mesh hit: "DXIL not compiled yet"`). I ran that fully qualified test alone on the PR's untouched parent [`753e8b1a`](https://github.com/xcl-dev/xcl/commit/753e8b1a2568c37248133880328f5fe1d5220193): **0 passed, 1 failed, 0 ignored**, with the same error. The full-suite failure is therefore not introduced by this PR. **Regression run** Clean `cargo build --release --offline --locked -j 4 -p xcl` builds, same local title, adapter, `XCL_PREPARE=0`, `XCL_ADAPTER=nvidia`, and 60-second duration in both runs. These are the blocks printed by `scripts/smoke.ps1`: ```text xcl-smoke v1 commit: d85f2c6c34a7a349def5893d9af22bb79614e774 gpu: NVIDIA GeForce RTX 3080 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1364 (PresentX 1364) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14286 MB ``` ```text xcl-smoke v1 commit: fdbac840ba68b1706136564fbcfa8ddffb1d5b8d gpu: NVIDIA GeForce RTX 3080 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1672 (PresentX 1673) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14169 MB ``` The pair is a runtime regression check, not a measurement of this PR's startup saving: `XCL_PREPARE=0` bypassed shader preparation, and the two commits include other upstream changes. No input was supplied, so progress beyond the initial screens was not verified. I did not run a prepared title launch or measure receipt reuse across different worker counts on this hardware. AI use: Codex (GPT-6.2 Sol) ran the builds, suite, parent control and paired smoke, checked the outputs, and drafted this report.
JJAutoCompare commented 2026-11-28 03:35:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T03:35:36Z.


Tested — post-merge verification of the final PR head

I reran the pinned CPU test executable for fdbac840ba68b1706136564fbcfa8ddffb1d5b8d on native Windows 11 25H2 build 26200.9974, AMD Ryzen 7 3800X, Rust 1.100.1 MSVC x64 debug. The binary used the verified Git archive with a private test fixture appended to the unchanged production module. warm_blobs.rs has the same Git blob in merge commit e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd. The executable was built from the PR head.

  • <libtest.exe> --exact shaders::warm_blobs::cross_process_probe::native_receipt_child --nocapture --test-threads=1 ran as two writers and a fresh reader. Both writer PIDs opened empty snapshots before the harness released them. Each recorded 65 disjoint keys, with zero unsaved entries after its automatic 64-key checkpoint and again after its final explicit save. The reader found the exact 130-key union and zero keys for a second synthetic identity. A separate parse checked 130 unique rows in the 3,128-byte receipt.
  • <libtest.exe> --exact shaders::warm_blobs::tests::workers_reuse_previous_slices_and_merge_concurrent_checkpoints --nocapture --test-threads=1 passed as the stock merge control.

4 passed, 0 failed, 0 ignored, 0 runtime skips. All four native processes and the harness exited 0.

Not tested

Simultaneous lock contention, forced write failure, real driver identities, GPU execution, retail launch, performance, and the full workspace suite.

AI use

T3 Code through the Codex harness (gpt-6.2-sol) verified the source and executable, ran the native processes, checked the receipt and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7233200166 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3086#issuecomment-7233200166). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-28T03:35:36Z. --- **Tested — post-merge verification of the final PR head** I reran the pinned CPU test executable for `fdbac840ba68b1706136564fbcfa8ddffb1d5b8d` on native Windows 11 25H2 build 26200.9974, AMD Ryzen 7 3800X, Rust 1.100.1 MSVC x64 debug. The binary used the verified Git archive with a private test fixture appended to the unchanged production module. `warm_blobs.rs` has the same Git blob in merge commit `e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd`. The executable was built from the PR head. - `<libtest.exe> --exact shaders::warm_blobs::cross_process_probe::native_receipt_child --nocapture --test-threads=1` ran as two writers and a fresh reader. Both writer PIDs opened empty snapshots before the harness released them. Each recorded 65 disjoint keys, with zero unsaved entries after its automatic 64-key checkpoint and again after its final explicit save. The reader found the exact 130-key union and zero keys for a second synthetic identity. A separate parse checked 130 unique rows in the 3,128-byte receipt. - `<libtest.exe> --exact shaders::warm_blobs::tests::workers_reuse_previous_slices_and_merge_concurrent_checkpoints --nocapture --test-threads=1` passed as the stock merge control. **4 passed, 0 failed, 0 ignored, 0 runtime skips.** All four native processes and the harness exited 0. **Not tested** Simultaneous lock contention, forced write failure, real driver identities, GPU execution, retail launch, performance, and the full workspace suite. **AI use** T3 Code through the Codex harness (`gpt-6.2-sol`) verified the source and executable, ran the native processes, checked the receipt and wrote this report.
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!3086
No description provided.