d3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT) #1950

Merged
kurrutako merged 5 commits from upstream-pr/1950 into main 2026-11-25 19:15:16 +00:00
kurrutako commented 2026-11-25 16:33:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kurrutako on 2026-11-25T16:33:10Z.


RT-SESSION-CACHE-AT-EXIT, claimed in #1608.

What

pipeline_cache.session.bin was written only in ~Device. A title never releases its device, so a real boot kept none of what it compiled, and every boot built the world start again.

  • save_pipeline_caches_at_exit(wait_ms) (shims/d3d12_compile_exit.h) writes the session cache of every live device. The live devices are a list that the Device constructor and destructor maintain. It runs once per process, after stop_pipeline_compiles.
  • gta6rt calls it at the run's exit, at a console close (Ctrl+C, Ctrl+Break, close), and from an unhandled-exception filter: a fault in the title or one of its DLLs, or the int3 after a device loss. The filter then passes the exception on, so the exit code is the exception's, as before.
  • The retail title installs its own filter. It imports SetUnhandledExceptionFilter from api-ms-win-core-errorhandling-l1-1-0, which replaced the runtime's filter (measured: a title fault at 354 s wrote nothing). The runtime now serves that call: its own filter stays first and hands the exception to the title's, as Windows would.
  • Builds still running. A large build takes minutes, and at a crash the faulting thread may be inside one. A build still running gets wait_ms (1 s); then the cache is written with the pipelines finished so far. This is valid because the cache is not created EXTERNALLY_SYNCHRONIZED. Unlike at teardown, the previous file is not kept: the process is ending, so keeping it would throw away the whole run (measured: a 1,308 s boot ended with 2 builds running).
  • The write itself is bounded. It runs on its own thread and gets 3 s, so a driver that blocks the read cannot hold the ending process. CacheStagingFile publishes by rename, so a write cut off leaves the previous file whole.
  • Threads that fault together (measured: eight within a second) wait for the first one's write (std::call_once), so none reaches the title's filter, which may end the process, in the middle of it.

~Device and the checkpoints are unchanged. The size limit is #1886's subject; see below.

Measured

Retail boots on Windows 11, RTX 5070 12 GB, NVIDIA 621.01. Build: main + #1851, #1827, #1849, #1862 (shaders retranslated with it: 29/29 FSPX) + #1886, with LEONIDA_HOST_IMAGE_COPY=0 LEONIDA_ASYNC_PIPELINES=1 LEONIDA_DEVICE_TYPE=6 LEONIDA_ARENA_MB=2048 LEONIDA_TITLE_WATCHDOG=0 LEONIDA_DEVICE_FAULT=1, a person at the keyboard pad. Counted: the runtime's took N s to build lines.

boot how it ended session cache
before this change (dozen boots) title faults, device losses never written
A title fault at 652 s, 1 build running wrote 436563293 bytes
B (loads A's file: loaded 436563293 bytes) int3 at 687 s, 2 builds running wrote 510225527 bytes
  • A had 97 slow builds (550 s in all). In B, none of those 97 programs was slow again. B's 34 slow builds (647 s) are all programs A never reached, the largest 83 s.
  • Without #1886, a 345 MB cache stopped at the 256 MiB limit (over the 268435456-byte write limit). This change makes the write happen; #1886 lets it through at this size.

Tests

d3d12_compile_teardown_test, exit case: with the device still alive after stop_pipeline_compiles, save_pipeline_caches_at_exit writes the session file, and a second call does nothing. It passes on the RTX 5070 (MSVC 2022, RelWithDebInfo); on llvmpipe the file stays absent, as in the existing cache case. The exception-filter path is checked by the boots above. Counts, offsets and program names only; no game data; python -I scripts/check_no_game_data.py passes.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5495185661 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950). Originally posted by [kurrutako](https://github.com/kurrutako) on 2026-11-25T16:33:10Z. --- RT-SESSION-CACHE-AT-EXIT, claimed in #1608. ## What `pipeline_cache.session.bin` was written only in `~Device`. A title never releases its device, so a real boot kept none of what it compiled, and every boot built the world start again. - `save_pipeline_caches_at_exit(wait_ms)` (`shims/d3d12_compile_exit.h`) writes the session cache of every live device. The live devices are a list that the `Device` constructor and destructor maintain. It runs once per process, after `stop_pipeline_compiles`. - `gta6rt` calls it at the run's exit, at a console close (Ctrl+C, Ctrl+Break, close), and from an **unhandled-exception filter**: a fault in the title or one of its DLLs, or the int3 after a device loss. The filter then passes the exception on, so the exit code is the exception's, as before. - **The retail title installs its own filter.** It imports `SetUnhandledExceptionFilter` from `api-ms-win-core-errorhandling-l1-1-0`, which replaced the runtime's filter (measured: a title fault at 354 s wrote nothing). The runtime now serves that call: its own filter stays first and hands the exception to the title's, as Windows would. - **Builds still running.** A large build takes minutes, and at a crash the faulting thread may be inside one. A build still running gets `wait_ms` (1 s); then the cache is written with the pipelines finished so far. This is valid because the cache is not created `EXTERNALLY_SYNCHRONIZED`. Unlike at teardown, the previous file is not kept: the process is ending, so keeping it would throw away the whole run (measured: a 1,308 s boot ended with 2 builds running). - **The write itself is bounded.** It runs on its own thread and gets 3 s, so a driver that blocks the read cannot hold the ending process. `CacheStagingFile` publishes by rename, so a write cut off leaves the previous file whole. - **Threads that fault together** (measured: eight within a second) wait for the first one's write (`std::call_once`), so none reaches the title's filter, which may end the process, in the middle of it. `~Device` and the checkpoints are unchanged. The size limit is #1886's subject; see below. ## Measured Retail boots on Windows 11, RTX 5070 12 GB, NVIDIA 621.01. Build: `main` + #1851, #1827, #1849, #1862 (shaders retranslated with it: 29/29 FSPX) + #1886, with `LEONIDA_HOST_IMAGE_COPY=0 LEONIDA_ASYNC_PIPELINES=1 LEONIDA_DEVICE_TYPE=6 LEONIDA_ARENA_MB=2048 LEONIDA_TITLE_WATCHDOG=0 LEONIDA_DEVICE_FAULT=1`, a person at the keyboard pad. Counted: the runtime's `took N s to build` lines. | boot | how it ended | session cache | |---|---|---| | before this change (dozen boots) | title faults, device losses | never written | | A | title fault at 652 s, 1 build running | `wrote 436563293 bytes` | | B (loads A's file: `loaded 436563293 bytes`) | int3 at 687 s, 2 builds running | `wrote 510225527 bytes` | - A had 97 slow builds (550 s in all). In B, **none of those 97 programs was slow again**. B's 34 slow builds (647 s) are all programs A never reached, the largest 83 s. - Without #1886, a 345 MB cache stopped at the 256 MiB limit (`over the 268435456-byte write limit`). This change makes the write happen; #1886 lets it through at this size. ## Tests `d3d12_compile_teardown_test`, exit case: with the device still alive after `stop_pipeline_compiles`, `save_pipeline_caches_at_exit` writes the session file, and a second call does nothing. It passes on the RTX 5070 (MSVC 2022, RelWithDebInfo); on llvmpipe the file stays absent, as in the existing cache case. The exception-filter path is checked by the boots above. Counts, offsets and program names only; no game data; `python -I scripts/check_no_game_data.py` passes. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Tyrannys commented 2026-11-25 18:12:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T18:12:05Z.


Test report from a combined build on a second NVIDIA machine. Counts only.

Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.

Build: main fe1553456 (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts.

Shaders: translated on 3de22a190 + #674 + #1662 with --wave64-emulate. 29,279 of 29,280 translated, and all 29,279 pass spirv-val. That is 2,683 library programs and 29 of 29 FSPX. main's translator changes since then are correctness fixes only.

Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).

  • Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes ActivateRays, ActivateProbes and ActivateProbesTarget programs of indirect diffuse lighting.
  • Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes).

Recipe: scripts/windows-boot/boot.ps1 -Seconds 480, LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1, LEONIDA_PIPELINE_CACHE_DIR pointing at the offline cache. Host image copy: off (auto: NVIDIA) from #1851. One run per row.

run 1 run 2 (+ LEONIDA_TITLE_WATCHDOG=0)
end 344 s: the title's hang watchdog (null write at game_scarlett_master.exe+0x23cf683) full 484 s, stopped by the script
device loss / fault report none none
D3D12 calls 330,487 375,686
ExecuteCommandLists 5,490 6,017
Dispatch / DrawIndexedInstanced 2,435 / 2,726 2,779 / 6,026
PresentX 1,358 ok, 0 failed 1,465 ok, 0 failed
captures 23, all non-black 25, all non-black
indirect draws recorded / emitted / skipped 64 / 0 / 5,092 128 / 34 / 9,244 (#429 not included)
  • WRITE_INVALID: the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (main 42537e7b6 + #1631; my run table of 07:54 in #1608).
  • #1950 / #1886: in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7170581400 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7170581400). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-25T18:12:05Z. --- Test report from a combined build on a second NVIDIA machine. Counts only. **Machine:** Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. **Build:** `main` `fe1553456` (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts. **Shaders:** translated on `3de22a190` + #674 + #1662 with `--wave64-emulate`. 29,279 of 29,280 translated, and all 29,279 pass `spirv-val`. That is 2,683 library programs and 29 of 29 FSPX. `main`'s translator changes since then are correctness fixes only. **Pipeline cache:** warm and complete, 26,503 of 26,503 (9.6 GB). - Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes `ActivateRays`, `ActivateProbes` and `ActivateProbesTarget` programs of indirect diffuse lighting. - Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes). **Recipe:** `scripts/windows-boot/boot.ps1 -Seconds 480`, `LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1`, `LEONIDA_PIPELINE_CACHE_DIR` pointing at the offline cache. Host image copy: `off (auto: NVIDIA)` from #1851. One run per row. | | run 1 | run 2 (+ `LEONIDA_TITLE_WATCHDOG=0`) | |---|---|---| | end | 344 s: the title's hang watchdog (null write at `game_scarlett_master.exe+0x23cf683`) | full 484 s, stopped by the script | | device loss / fault report | none | none | | D3D12 calls | 330,487 | 375,686 | | ExecuteCommandLists | 5,490 | 6,017 | | Dispatch / DrawIndexedInstanced | 2,435 / 2,726 | 2,779 / 6,026 | | PresentX | 1,358 ok, 0 failed | 1,465 ok, 0 failed | | captures | 23, all non-black | 25, all non-black | | indirect draws recorded / emitted / skipped | 64 / 0 / 5,092 | 128 / 34 / 9,244 (#429 not included) | - **WRITE_INVALID:** the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (`main` `42537e7b6` + #1631; my run table of 07:54 in #1608). - **#1950 / #1886:** in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run. AI-assisted (Claude Code).
kurrutako commented 2026-11-25 18:44:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kurrutako on 2026-11-25T18:44:05Z.


Thanks for the test. Run 1 is the case this PR is for: the title's fatal exception went through the exit filter, the save ran while a build was still going, and it set out to write only the pipelines that had finished.

The write was then refused by the 4 GiB cap from #1886, not by this PR. With an offline seed loaded, the driver's cache data is the seed plus the session, so a 9.7 GB seed is over the cap before the session adds anything. That is the seeded case already raised on #1886, so I will leave the fix there and not change it here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171320741 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7171320741). Originally posted by [kurrutako](https://github.com/kurrutako) on 2026-11-25T18:44:05Z. --- Thanks for the test. Run 1 is the case this PR is for: the title's fatal exception went through the exit filter, the save ran while a build was still going, and it set out to write only the pipelines that had finished. The write was then refused by the 4 GiB cap from #1886, not by this PR. With an offline seed loaded, the driver's cache data is the seed plus the session, so a 9.7 GB seed is over the cap before the session adds anything. That is the seeded case already raised on #1886, so I will leave the fix there and not change it here. AI-assisted (Claude Code, Claude Opus 5.5).
GGandCo commented 2026-11-25 19:12:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GGandCo on 2026-11-25T19:12:55Z.


Intel integration verification (AI-assisted: OpenAI Codex): Windows 11, MSVC RelWithDebInfo, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314. Applied the four implementation commits through 98c457ec4 plus the documentation commit, onto main 73cc1a2ba and an existing private integration tree.

14/14 targeted tests passed: d3d12_compile_teardown (including the once-only live-device session-cache write), list_value_wait_budget, all nine xs_proxy_mock modes, d3d12_xmem_placed, d3d12_m2_textured, replay_copy_offset.

Also checked the actual gta6rt import/filter path with two synthetic, CRT-free guest PEs, one importing SetUnhandledExceptionFilter from KERNEL32.dll and one through api-ms-win-core-errorhandling-l1-1-0.dll. Each registers two filters, verifies the previous guest filter is returned, then raises a deliberate noncontinuable exception; the final guest filter exits with code 42. Both fixed-runtime runs log the cache-exit filter and then exit 42. The preceding runtime failed the filter-chain check (exit 43). These tiny fixtures create no graphics device; actual cache publication is covered by d3d12_compile_teardown, not by the PE fixtures.

This is a combined-tree, targeted result, not a full-suite or playability claim. No title data is included.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171977609 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7171977609). Originally posted by [GGandCo](https://github.com/GGandCo) on 2026-11-25T19:12:55Z. --- Intel integration verification (AI-assisted: OpenAI Codex): Windows 11, MSVC RelWithDebInfo, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314. Applied the four implementation commits through 98c457ec4 plus the documentation commit, onto main 73cc1a2ba and an existing private integration tree. 14/14 targeted tests passed: d3d12_compile_teardown (including the once-only live-device session-cache write), list_value_wait_budget, all nine xs_proxy_mock modes, d3d12_xmem_placed, d3d12_m2_textured, replay_copy_offset. Also checked the actual gta6rt import/filter path with two synthetic, CRT-free guest PEs, one importing SetUnhandledExceptionFilter from KERNEL32.dll and one through api-ms-win-core-errorhandling-l1-1-0.dll. Each registers two filters, verifies the previous guest filter is returned, then raises a deliberate noncontinuable exception; the final guest filter exits with code 42. Both fixed-runtime runs log the cache-exit filter and then exit 42. The preceding runtime failed the filter-chain check (exit 43). These tiny fixtures create no graphics device; actual cache publication is covered by d3d12_compile_teardown, not by the PE fixtures. This is a combined-tree, targeted result, not a full-suite or playability claim. No title data is included.
aslan2142 commented 2026-11-25 19:15:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T19:15:18Z.


Merged, thanks! Reviewed at 2e61d408:

  • Cache: the format and location are unchanged, so existing session files stay valid. An oversized or cut-off write keeps the previous file.
  • Merges: clean with main, including #1887 and #1798, which landed in between (the console-fix default stays 0). Also clean with #1889, #1886 and #1914; one trivial signature conflict with #1756, for whichever merges second.
  • Windows suite under Wine (llvmpipe + RADV iGPU): no regressions. d3d12_compile_teardown passes and writes the file on RADV.
  • Checked on main 490f5b9ec + 2e61d4080: it merges cleanly; the semantic suite passes (490 files, 6,310 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 5 changed files.
  • Non-blocking: no test covers handing the exception on to the title's own filter. A tiny-game test that installs a filter and faults would cover it.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172038070 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7172038070). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T19:15:18Z. --- Merged, thanks! Reviewed at `2e61d408`: - **Cache:** the format and location are unchanged, so existing session files stay valid. An oversized or cut-off write keeps the previous file. - **Merges:** clean with `main`, including #1887 and #1798, which landed in between (the console-fix default stays 0). Also clean with #1889, #1886 and #1914; one trivial signature conflict with #1756, for whichever merges second. - **Windows suite under Wine** (llvmpipe + RADV iGPU): no regressions. `d3d12_compile_teardown` passes and writes the file on RADV. - **Checked on `main` `490f5b9ec` + `2e61d4080`:** it merges cleanly; the semantic suite passes (490 files, 6,310 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 5 changed files. - **Non-blocking:** no test covers handing the exception on to the title's own filter. A tiny-game test that installs a filter and faults would cover it. AI-assisted (Claude Code, Claude Opus 5.5).
GGandCo commented 2026-11-25 20:43:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GGandCo on 2026-11-25T20:43:20Z.


Additional Intel diagnostic finding after the positive targeted tests above: with Khronos GPU-assisted validation enabled, a fatal shutdown while compute compilation was still active was followed by a driver access violation inside vkGetPipelineCacheData. Host symbols resolve the caller to save_session_pipeline_cache (d3d12_vulkan_device.cpp, the data query) from the bounded save_pipeline_caches_at_exit worker. The initial fatal exception occurred before this secondary driver failure; this does not explain or fix the initial shutdown.

Windows 11, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314, Vulkan SDK 1.4.363.1, current-main integration including #1950. An earlier non-GPUAV run successfully saved the session cache at exit. No minimal standalone concurrency reproducer yet, so this is an observed GPUAV/driver interaction, not a confirmed general cache synchronization bug. A useful follow-up would be a synthetic active-compilation plus exit-cache-query stress test on Intel with GPUAV. No game logs or data included. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174094593 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7174094593). Originally posted by [GGandCo](https://github.com/GGandCo) on 2026-11-25T20:43:20Z. --- Additional Intel diagnostic finding after the positive targeted tests above: with Khronos GPU-assisted validation enabled, a fatal shutdown while compute compilation was still active was followed by a driver access violation inside vkGetPipelineCacheData. Host symbols resolve the caller to save_session_pipeline_cache (d3d12_vulkan_device.cpp, the data query) from the bounded save_pipeline_caches_at_exit worker. The initial fatal exception occurred before this secondary driver failure; this does not explain or fix the initial shutdown. Windows 11, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314, Vulkan SDK 1.4.363.1, current-main integration including #1950. An earlier non-GPUAV run successfully saved the session cache at exit. No minimal standalone concurrency reproducer yet, so this is an observed GPUAV/driver interaction, not a confirmed general cache synchronization bug. A useful follow-up would be a synthetic active-compilation plus exit-cache-query stress test on Intel with GPUAV. No game logs or data included. AI-assisted with OpenAI Codex.
kurrutako commented 2026-11-25 21:52:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kurrutako on 2026-11-25T21:52:28Z.


Thanks, that's useful, and the caller you resolved is the expected one. Notes from the code at 2e61d408:

  • The read is allowed by Vulkan. The session cache is not created EXTERNALLY_SYNCHRONIZED, so vkGetPipelineCacheData while another thread's vkCreateComputePipelines uses the same cache is valid. The exit path counts on that: save_pipeline_caches_at_exit waits up to 1 s for active_compiles, then reads the pipelines finished so far. A driver that faults on that read in a valid call is a driver (or GPU-AV) problem, not missing locking on our side. That fits your clean non-GPU-AV exit save.
  • GPU-AV changes the call. It hooks pipeline creation and builds instrumented copies, so the driver sees different pipelines, and more of them, going into the same cache. The race window is therefore not the same as in a normal run.
  • Where did the first exception happen? This is the question that matters. If the first fatal exception was on a thread inside vkCreateComputePipelines (in the Intel driver or in the layer), that thread never leaves the build. active_compiles stays above zero, and the driver's cache can be left half-updated when we read it. A secondary access violation would then be likely, whatever the locking. A module and offset for the first exception, or just whether its stack shows a pipeline create, would settle it.
  • The secondary fault can't hang the exit. The write runs on its own detached thread. Its access violation goes back into the fatal filter, which waits on the call_once the first thread holds. The first thread stops waiting after 3 s (kExitCacheWriteMs) and hands the original exception to the title's filter. The previous pipeline_cache.session.bin stays whole, because it is only ever replaced by a rename.

If the first exception turns out to be inside a pipeline create, a narrow follow-up would be to skip the exit write when the faulting thread is in a build (a thread-local mark set by CompileActivity). The cost is losing that run's cache, not risking a second fault. I'd hold that until the first exception's location is known, and I agree a synthetic stress test (active compile plus exit-cache query, Intel, GPU-AV) is the way to tell a general race from this layer/driver combination.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7175648870 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1950#issuecomment-7175648870). Originally posted by [kurrutako](https://github.com/kurrutako) on 2026-11-25T21:52:28Z. --- Thanks, that's useful, and the caller you resolved is the expected one. Notes from the code at `2e61d408`: - **The read is allowed by Vulkan.** The session cache is not created `EXTERNALLY_SYNCHRONIZED`, so `vkGetPipelineCacheData` while another thread's `vkCreateComputePipelines` uses the same cache is valid. The exit path counts on that: `save_pipeline_caches_at_exit` waits up to 1 s for `active_compiles`, then reads the pipelines finished so far. A driver that faults on that read in a valid call is a driver (or GPU-AV) problem, not missing locking on our side. That fits your clean non-GPU-AV exit save. - **GPU-AV changes the call.** It hooks pipeline creation and builds instrumented copies, so the driver sees different pipelines, and more of them, going into the same cache. The race window is therefore not the same as in a normal run. - **Where did the first exception happen?** This is the question that matters. If the first fatal exception was on a thread inside `vkCreateComputePipelines` (in the Intel driver or in the layer), that thread never leaves the build. `active_compiles` stays above zero, and the driver's cache can be left half-updated when we read it. A secondary access violation would then be likely, whatever the locking. A module and offset for the first exception, or just whether its stack shows a pipeline create, would settle it. - **The secondary fault can't hang the exit.** The write runs on its own detached thread. Its access violation goes back into the fatal filter, which waits on the `call_once` the first thread holds. The first thread stops waiting after 3 s (`kExitCacheWriteMs`) and hands the original exception to the title's filter. The previous `pipeline_cache.session.bin` stays whole, because it is only ever replaced by a rename. If the first exception turns out to be inside a pipeline create, a narrow follow-up would be to skip the exit write when the faulting thread is in a build (a thread-local mark set by `CompileActivity`). The cost is losing that run's cache, not risking a second fault. I'd hold that until the first exception's location is known, and I agree a synthetic stress test (active compile plus exit-cache query, Intel, GPU-AV) is the way to tell a general race from this layer/driver combination.
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
ProjectLeonida/mandy!1950
No description provided.