Skip to content

Preserve the last complete Vulkan pipeline cache when a checkpoint fails - #535

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
nschlaepfer:codex/preserve-pipeline-cache
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
nschlaepfer:codex/preserve-pipeline-cache

Conversation

@nschlaepfer

Copy link
Copy Markdown
Contributor

vk_pipeline_check could replace a good cache with a truncated file and still tell the build the checkpoint succeeded. On an Apple M3 Max, a one-pipeline synthetic run loaded a valid 15,244-byte cache. With a file-size limit of 16 bytes on the checker process, both Vulkan cache queries succeeded. The file write failed, but the checker printed “15,244 bytes” and exited 0. An uncapped control preserved the original cache byte for byte.

The checker now retrieves a complete snapshot before staging it. It retries a growing cache on VK_INCOMPLETE, checks the returned byte count, and writes in bounded chunks to an exclusively created file beside the destination. Only a successful write, flush and close permits replacement. A failed periodic save warns while compilation continues. A failed final save returns nonzero, so make_game.py can report the failure. A pre-existing .partial file is left alone. An abrupt kill during writing can leave an unpublished staging file alongside the last published checkpoint.

Verification on synthetic data

  • On the physical Apple M3 Max (MoltenVK) and software Mesa llvmpipe, failed saves preserved the previous bytes and file identity, or left an absent destination absent. Both drivers passed the uncapped retry. No staging file was left after the handled failures.
  • The stock make_game.py --stages pipelines entry point returned 1 for an unwritable output directory, without printing a completion message.
  • The exact file writer replaced an existing destination with 4 GiB + 37 bytes of synthetic data. All bytes were verified in chunks. This exercised large-file I/O with synthetic contents.
  • The eight available macOS CTests passed. The two new regression tests cover filesystem publication and Vulkan snapshot retrieval. Both compiled as Windows x64 programs with MinGW and passed under Wine. A Windows handle denying delete sharing prevented replacement while preserving the previous file. Native Windows GPU execution was not tested.

This fixes the checker's checkpoint writer. PR #367 covers runtime cache seeding and a separate pipeline-layout change. AI-assisted. Coordination claim

@kacper-serewis

Copy link
Copy Markdown
Contributor

Tested e27749f on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200 (native Windows, MSVC 19.50, Vulkan SDK 1.4.363.0): pass.

  • runtime built with build_runtime.ps1; ctest 25/25, including the new pipeline_cache_file and pipeline_cache_snapshot tests
  • pipeline_cache_file_test and pipeline_cache_snapshot_test also run directly: exit 0

@VictorJulianiR

Copy link
Copy Markdown
Contributor

I tested the final-save error path in the actual vk_pipeline_check executable on the rebased head 9833d7d. The GitHub-hosted Windows Server 2022 runner used MSVC and Mesa 26.3.1 llvmpipe. Each run compiled one synthetic compute pipeline with zero failures and zero skips.

The first run created a 32-byte checkpoint. I then held that file open with CreateFileW, allowing reads and writes but withholding FILE_SHARE_DELETE. Pipeline creation still succeeded. The checker reported Access is denied at the final save and exited 1. The existing file retained its bytes and NTFS file ID, and no staging file remained. After releasing the handle, the checker read the 32-byte checkpoint, published a new checkpoint and exited 0.

Both standalone cache tests also passed. This exercises publication and recovery on a software Vulkan driver. AI-assisted, synthetic inputs. Hosted run and output

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants