pipeline cache: version the driver cache file by format, not git revision #982

Closed
github-bot wants to merge 1 commit from gh-pr/982/head into gh-pr/982/base
Owner

@⁠wuboo on GitHub · 2026-10-02 19:24 UTC · original
wuboo:pr/pipeline-cache-format → main · +8 −14 · 1 files · 1 commits · closed without merging

Problem

The driver pipeline cache file (_PipelineCache/<title>.bin) is keyed by KYTY_GIT_REVISION. Any new build, including one that does not touch the renderer, discards the whole cache, and the next start recompiles every pipeline. Builds with an unknown revision or a dirty tree have the cache disabled entirely, so local development builds never get a warm cache.

On macOS/MoltenVK with Astro Bot this costs about 16 s of pipeline compilation (275 pipelines) in the first minutes of the game after every rebuild. Much of that shows up as hitches.

Change

  • The file signature uses a hand-bumped kPipelineCacheFormat plus the driver identity it already had (vendor, device, driver version, pipelineCacheUUID) instead of the git revision. The prefix becomes KytyPC2, so existing files are invalidated once.
  • The unknown-revision and dirty-build checks are removed; they only existed because of the revision key. The Release-only gate stays.

This is safe because the payload is the driver's own vkGetPipelineCacheData blob. The driver validates its header and keys entries by pipeline content (SPIR-V and state), so pipelines whose shaders or state changed simply miss and get compiled. The file holds nothing emulator-specific besides the signature and payload hash. If the emulator-side layout of the file ever changes, bump kPipelineCacheFormat.

Trade-off: entries for shaders that no longer exist are kept until the format is bumped or the driver identity changes, so the file can grow across many builds.

Testing

  • Release build on macOS (x86_64 under Rosetta, MoltenVK) on this branch.
  • Runtime check of the same change on the macOS bring-up stack (#715 and related): a binary with a different sha loaded the blob written by the previous build (Vulkan pipeline cache: loaded 60931195 bytes). Pipeline compile time in a short Astro Bot run dropped to 0.11 s, from about 16 s with the revision key.
**@⁠wuboo** on GitHub · 2026-10-02 19:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/982) `wuboo:pr/pipeline-cache-format` → `main` · +8 −14 · 1 files · 1 commits · closed without merging ### Problem The driver pipeline cache file (`_PipelineCache/<title>.bin`) is keyed by `KYTY_GIT_REVISION`. Any new build, including one that does not touch the renderer, discards the whole cache, and the next start recompiles every pipeline. Builds with an unknown revision or a dirty tree have the cache disabled entirely, so local development builds never get a warm cache. On macOS/MoltenVK with Astro Bot this costs about 16 s of pipeline compilation (275 pipelines) in the first minutes of the game after every rebuild. Much of that shows up as hitches. ### Change - The file signature uses a hand-bumped `kPipelineCacheFormat` plus the driver identity it already had (vendor, device, driver version, `pipelineCacheUUID`) instead of the git revision. The prefix becomes `KytyPC2`, so existing files are invalidated once. - The unknown-revision and dirty-build checks are removed; they only existed because of the revision key. The Release-only gate stays. This is safe because the payload is the driver's own `vkGetPipelineCacheData` blob. The driver validates its header and keys entries by pipeline content (SPIR-V and state), so pipelines whose shaders or state changed simply miss and get compiled. The file holds nothing emulator-specific besides the signature and payload hash. If the emulator-side layout of the file ever changes, bump `kPipelineCacheFormat`. Trade-off: entries for shaders that no longer exist are kept until the format is bumped or the driver identity changes, so the file can grow across many builds. ### Testing - Release build on macOS (x86_64 under Rosetta, MoltenVK) on this branch. - Runtime check of the same change on the macOS bring-up stack (#715 and related): a binary with a different sha loaded the blob written by the previous build (`Vulkan pipeline cache: loaded 60931195 bytes`). Pipeline compile time in a short Astro Bot run dropped to 0.11 s, from about 16 s with the revision key.
The driver cache file was keyed by KYTY_GIT_REVISION, so every new build,
including ones that do not touch the renderer, discarded the whole cache and
recompiled every pipeline on the next start. Dirty and unknown-revision builds
had the cache disabled entirely.

The payload is the driver's own vkGetPipelineCacheData blob. The driver checks
its header (vendor, device, pipelineCacheUUID) and keys entries by pipeline
content, so pipelines whose SPIR-V or state changed simply miss. Key the file
by a hand-bumped format version plus the driver identity instead, and drop the
revision-based checks. The Release-only gate stays.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:39:13 +00:00
github-bot closed this pull request 2026-11-26 09:39:13 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 19:31 UTC · original · edited 2026-10-02 19:43 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3240ffc0-b4cd-4b25-b9cd-80fe32455bf0

📥 Commits

Reviewing files that changed from the base of the PR and between cadf1a3d33678f40419640e2d75fa95fe7f32baa and 67aec222ac.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 80839596-1b81-4b40-ad16-c07ad3c5ce78

📥 Commits

Reviewing files that changed from the base of the PR and between e317465d8a and cadf1a3d33678f40419640e2d75fa95fe7f32baa.

📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The pipeline cache format is now version 2. Its signature uses the format version and physical-device identifiers instead of the emulator Git revision. Git-version checks that disabled cache initialization were removed. The invalidation message now refers to driver, format, or data mismatches.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to cadf1

Different Release builds can now reuse the versioned driver cache; incompatible data should reduce to cache misses, with possible cache growth. No actionable merge-blocking risk is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to cadf1

The change preserves device matching, corruption checks, and empty-cache recovery. No exploitable regression was established, but trusting stored cache files and reusing them across builds still depend on the launch environment and driver behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported exposure is a title-named cache in the process working directory feeding the host Vulkan driver. A party able to replace a matching wrapper can supply driver initial data; replacing one filename can affect subsequent launches using that title and compatible device identity. The evidence does not establish directory trust or a cross-user privilege boundary.

Trust Boundaries and Controls

  • observed — Title character validation prevents direct path separators in the derived filename. Device and format matching, exact reads, and hashing filter mismatches and corruption. These controls do not authenticate a local writer or establish that arbitrary crafted driver data is safe; empty-cache retry operates only after a driver call returns an error.

Resilience and Maintainability Implications

  • observed — The fixed temporary filename and delete-before-rename replacement predate this PR. Replacement is not atomic across the deletion window, and the inspected Linux flush is fflush rather than a durability barrier. Thus interruption can lose a warm cache, while concurrent publishers can interfere; the reader's checks provide corruption filtering, not transaction or writer isolation.

Hardening Proposals

  • proposed — If supported launch environments permit less-trusted users to modify the working directory, use a protected per-user cache location and explicit ownership controls before passing persisted bytes to the driver. This is conditional hardening, not an established PR-introduced vulnerability.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the pipeline cache key change, its rationale, trade-offs, and testing. It directly relates to the changeset.
Title check ✅ Passed The title clearly and concisely identifies the main change: versioning the driver pipeline cache by format instead of Git revision.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-02 19:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/982#issuecomment-5959933263) · edited 2026-10-02 19:43 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/982?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: skip review by coderabbit.ai --> > [!IMPORTANT] > ## Review skipped > > Review was skipped as selected files did not have any reviewable changes. > > > > > > <details> > <summary>⚙️ Run configuration</summary> > > **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml > > **Review profile**: CHILL > > **Plan**: Advanced > > **Run ID**: `3240ffc0-b4cd-4b25-b9cd-80fe32455bf0` > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between cadf1a3d33678f40419640e2d75fa95fe7f32baa and 67aec222ac2542ab4861b620edde77d09ed09566. > > </details> > > You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file. > > Use the checkbox below for a quick retry: > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: skip review by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `80839596-1b81-4b40-ad16-c07ad3c5ce78` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e317465d8a773b33482ad367ad2f856154c8bc6d and cadf1a3d33678f40419640e2d75fa95fe7f32baa. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The pipeline cache format is now version 2. Its signature uses the format version and physical-device identifiers instead of the emulator Git revision. Git-version checks that disabled cache initialization were removed. The invalidation message now refers to driver, format, or data mismatches. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"cadf1a3d33678f40419640e2d75fa95fe7f32baa" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `cadf1` <!-- final_review_risk_coverage:{"sourceCommitId":"cadf1a3d33678f40419640e2d75fa95fe7f32baa","coveredCommitId":"cadf1a3d33678f40419640e2d75fa95fe7f32baa","kind":"reviewed"} --> Different Release builds can now reuse the versioned driver cache; incompatible data should reduce to cache misses, with possible cache growth. No actionable merge-blocking risk is established. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `cadf1` The change preserves device matching, corruption checks, and empty-cache recovery. No exploitable regression was established, but trusting stored cache files and reusing them across builds still depend on the launch environment and driver behavior. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The supported exposure is a title-named cache in the process working directory feeding the host Vulkan driver. A party able to replace a matching wrapper can supply driver initial data; replacing one filename can affect subsequent launches using that title and compatible device identity. The evidence does not establish directory trust or a cross-user privilege boundary. **Trust Boundaries and Controls** - _observed_ — Title character validation prevents direct path separators in the derived filename. Device and format matching, exact reads, and hashing filter mismatches and corruption. These controls do not authenticate a local writer or establish that arbitrary crafted driver data is safe; empty-cache retry operates only after a driver call returns an error. **Resilience and Maintainability Implications** - _observed_ — The fixed temporary filename and delete-before-rename replacement predate this PR. Replacement is not atomic across the deletion window, and the inspected Linux flush is fflush rather than a durability barrier. Thus interruption can lose a warm cache, while concurrent publishers can interfere; the reader's checks provide corruption filtering, not transaction or writer isolation. **Hardening Proposals** - _proposed_ — If supported launch environments permit less-trusted users to modify the working directory, use a protected per-user cache location and explicit ownership controls before passing persisted bytes to the driver. This is conditional hardening, not an established PR-introduced vulnerability. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ✅ Passed | The description clearly explains the pipeline cache key change, its rationale, trade-offs, and testing. It directly relates to the changeset. | | Title check | ✅ Passed | The title clearly and concisely identifies the main change: versioning the driver pipeline cache by format instead of Git revision. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts > Autopilot is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=982)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-03 13:25 UTC · original

@⁠wuboo the problem is that we now need to bump kPipelineCacheFormat each time renderer/shader recompiler changes "manually". That was the point of NOT doing it in first place

**@⁠Nmzik** on GitHub · 2026-10-03 13:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/982#issuecomment-5969604572) @⁠wuboo the problem is that we now need to bump kPipelineCacheFormat each time renderer/shader recompiler changes "manually". That was the point of NOT doing it in first place
Author
Owner

@⁠wuboo on GitHub · 2026-10-03 13:55 UTC · original

Thanks for looking at this. I don't think a manual bump is needed when the renderer or recompiler changes. Here is why, so you can tell me if I'm missing a case:

  • The file's payload is only the driver's vkGetPipelineCacheData blob. The driver, and MoltenVK on macOS, key every entry by the full pipeline create info: the SPIR-V itself plus all state.
  • If the recompiler emits different SPIR-V, or the renderer sets different state, the lookup misses and the pipeline is compiled fresh. A stale entry can't be returned for a different pipeline.
  • kPipelineCacheFormat only needs a bump if our wrapper around the blob changes (the header or signature layout), which should be rare.

What the change gives up is pruning: entries for pipelines that no longer exist stay in the file until the driver identity or the format changes.

If you would rather keep automatic invalidation, a middle ground is to key the file by a hash of the renderer and recompiler sources, computed at build time, instead of the git revision. #988 already does this for the recompiler cache (KYTY_RECOMPILER_SIGNATURE). The cache would then survive commits that don't touch those sources (docs, CI, HLE, loader…) and still reset on any renderer or recompiler change, with nothing to bump by hand. I can switch this PR to that if you prefer.

**@⁠wuboo** on GitHub · 2026-10-03 13:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/982#issuecomment-5969838634) Thanks for looking at this. I don't think a manual bump is needed when the renderer or recompiler changes. Here is why, so you can tell me if I'm missing a case: - The file's payload is only the driver's `vkGetPipelineCacheData` blob. The driver, and MoltenVK on macOS, key every entry by the full pipeline create info: the SPIR-V itself plus all state. - If the recompiler emits different SPIR-V, or the renderer sets different state, the lookup misses and the pipeline is compiled fresh. A stale entry can't be returned for a different pipeline. - `kPipelineCacheFormat` only needs a bump if *our* wrapper around the blob changes (the header or signature layout), which should be rare. What the change gives up is pruning: entries for pipelines that no longer exist stay in the file until the driver identity or the format changes. If you would rather keep automatic invalidation, a middle ground is to key the file by a hash of the renderer and recompiler sources, computed at build time, instead of the git revision. #988 already does this for the recompiler cache (`KYTY_RECOMPILER_SIGNATURE`). The cache would then survive commits that don't touch those sources (docs, CI, HLE, loader…) and still reset on any renderer or recompiler change, with nothing to bump by hand. I can switch this PR to that if you prefer.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-08 14:46 UTC · original

Lets leave it as it is. With this change users need to manually delete their caches in future full precompilation

**@⁠Nmzik** on GitHub · 2026-10-08 14:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/982#issuecomment-6062436480) Lets leave it as it is. With this change users need to manually delete their caches in future full precompilation

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.