Skip to content

Shaders: fail safe on unknown cache settings - #3470

Open
bmjask wants to merge 2 commits into
xcl-dev:mainfrom
bmjask:shaders/cache-unknown-setting-fail-safe
Open

bmjask wants to merge 2 commits into
xcl-dev:mainfrom
bmjask:shaders/cache-unknown-setting-fail-safe

Conversation

@bmjask

@bmjask bmjask commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3484. Only the top cache-settings commit belongs to this PR; the prerequisite corrects a test that did not account for the existing deferred-release path.

The prepared-cache settings identity introduced by #3447 hashes an allowlist of known semantic switches. That avoids churn, but a newly added semantic XCL_* variable could be omitted accidentally and allow stale native libraries to be reused.

This follow-up keeps the exact current identity for every known semantic and operational setting. Unknown XCL_* variables fail safe into the identity until they are explicitly reviewed and classified as cache-neutral.

What is in it

  • shaders.rs: centralizes the existing cache-neutral setting list.
  • Known semantic settings continue to override the neutral classification.
  • Unknown XCL_* settings are included in the canonical v2 settings hash.
  • Unit tests verify known operational switches remain neutral and unknown settings invalidate.

Tested

  • Hardware: NVIDIA GeForce RTX 4090, Windows, debug and release.
  • cargo test -p xcl --lib warm_settings -- --test-threads=1: 3 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib warm_library -- --test-threads=4: 10 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • .\scripts\test.ps1 was attempted twice on c2393f82: one run aborted in the pre-existing asynchronous PSO test harness on an invalid synthetic COM pointer; the retry completed 2,653 tests before the unrelated hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was test failed. The affected focused tests above pass, and Tests: account for deferred stand-in pipeline release #3484 passed the full suite before stacking: 2,793 passed, 0 failed, 49 ignored.

Regression run
Base:

xcl-smoke v1
commit: 5b0d5fa3d65d9aa61567f8603154d818a9307846
gpu: NVIDIA GeForce RTX 4090
title: retail-fixture
seconds: 60
exit: 0x0
frames shown: 1516 (PresentX 1516)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16888 MB

Head:

xcl-smoke v1
commit: c2393f82f8f6fa9440f85bfc0a51224a23bc1066
gpu: NVIDIA GeForce RTX 4090
title: retail-fixture
seconds: 60
exit: 0x0
frames shown: 1531 (PresentX 1531)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15309 MB

Not tested

  • AMD hardware.
  • An environment containing a real unknown XCL_* setting; synthetic settings cover the identity behavior.
  • A clean local full-suite completion on the stacked head because of the two unrelated main-branch flakes documented above; the required no-GPU CI run is authoritative for the pushed head.

AI use
Codex with GPT-5 reviewed the merged cache-identity behavior, implemented the fail-safe classification and tests, rebased and stacked the prerequisite test correction, and ran the reported verification.

@github-actions github-actions Bot added area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Prime1997 Prime1997 added the test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md) label Nov 29, 2026
The concurrent stand-in test expected the winning pipeline to be released synchronously with its last shell. Production intentionally routes that pipeline through late_release, so the assertion raced the deferred release and failed in no-GPU CI.

Capture the deferred release deterministically, verify the winning reference, and release it before checking final counts.

Assisted-by: Codex (GPT-5)
The prepared-cache settings identity accepted only an allowlist of known semantic switches. A future semantic XCL setting could therefore be omitted accidentally and reuse stale native libraries.

Keep the existing identity for every known semantic and operational setting, but include unknown XCL settings until they are explicitly reviewed as cache-neutral.

Tested with the full scripts/test.ps1 suite and focused settings and receipt tests.

Assisted-by: Codex (GPT-5)
@bmjask
bmjask force-pushed the shaders/cache-unknown-setting-fail-safe branch from ea53304 to c2393f8 Compare November 30, 2026 00:27
@github-actions github-actions Bot added the area:d3d12 D3D12.X runtime, command lists, resources, sparse memory label Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head c2393f8, diff read, not a merge-check; it conflicts with main, so not built or run):

  • The conflict only comes from the Tests: account for deferred stand-in pipeline release #3484 commit (standin.rs), which main already superseded with 5454468. shaders.rs merges into main cleanly, so dropping that commit and rebasing fixes it.
  • This reverses Shaders: stabilize prepared cache identities #3447's design. In warm_settings (shaders.rs ~66) every XCL_* variable not on the neutral list now enters the key. Every semantic name starts with XCL_ and none is on that list, so the semantic_pipeline_setting term no longer decides anything. The key covers what the pre-Shaders: stabilize prepared cache identities #3447 key covered, with the v2 hash. The runtime reads far more XCL_ names than the ~50 on the neutral list, so diagnostic switches not on it (e.g. XCL_DUMP_ON from d0832e6, XCL_LATE_RELEASE, XCL_GPU_TIMING, XCL_STALL_TRACE, XCL_WINDOW_POS) now discard the native libraries and force a rebuild of several minutes, and with XCL_PREPARE_CACHE_ONLY=1 they make preparation fail. XCL_DEVICE_TYPE (set by the menu, main.rs ~146, and forced by pipeline_worker_command) also enters the key, so switching between the menu and a plain CLI run rebuilds. A fail-safe with less churn: a unit test that fails when an XCL_ name read under gpu/ or hle/d3d12x/ is on neither list.
  • The commit body says it was tested with the full scripts/test.ps1 suite, but the PR's Tested section says the full suite never completed on c2393f8. One of the two is wrong.
  • Minor: the test is still named ..._only_hash_semantic_switches but now checks that XCL_NEW_LOG changes the key. The two flipped assertions match the new intent, so this isn't a weakened test.

Fine: with no unknown XCL_ variables set, the key is the same as on main (no invalidation for default users), the neutral list moved over word for word, and legacy_warm_settings and the warm_library.rs migration are unchanged.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants