Skip to content

Conversation

@DJMcNab
Copy link
Member

@DJMcNab DJMcNab commented Mar 18, 2024

Supercedes #459

This is the version of pipeline caching using gfx-rs/wgpu#5319

This leads to massive improvements in startup time, especially on Android.

@DJMcNab DJMcNab changed the title Pipeline cache 2 Pipeline caching, this time not jankily Mar 18, 2024
@DJMcNab DJMcNab force-pushed the pipeline-cache-repeat branch from 34ebdd2 to 22138de Compare March 19, 2024 08:37
@waywardmonkeys waywardmonkeys added this to the Vello 0.3 release milestone Aug 1, 2024
@DJMcNab DJMcNab removed this from the Vello 0.3 release milestone Sep 20, 2024
@DJMcNab DJMcNab force-pushed the pipeline-cache-repeat branch from 22138de to 4bb38e8 Compare April 2, 2025 14:34
@DJMcNab DJMcNab changed the title Pipeline caching, this time not jankily Pipeline caching! Apr 2, 2025
@DJMcNab DJMcNab marked this pull request as ready for review April 2, 2025 14:36
@DJMcNab DJMcNab force-pushed the pipeline-cache-repeat branch from 4e90142 to 9d32238 Compare April 2, 2025 19:59
@PoignardAzur
Copy link
Collaborator

Not a blocker for this PR, but RendererOptions should probably be non_exhaustive to avoid breaking changes in cases like this?

Comment on lines +66 to +71
/// # Safety
///
/// The directory should only have been written into by [`write_pipeline_cache`].
///
/// We recognise that this is an impossible standard, but that's because Vulkan
/// makes UB unavoidable around invalid pipeline caches, so just do your best.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate. Can we at least embed a checksum in the cache file? If possible, one with a program-local salt so it's extra hard to get the wrong cache by accident?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle to see the point. wgpu already does some sanity checks here, and it's still possible to do UB (if something decides to write to the wrong place with a forged cache with our hash in place).

I don't believe adding it here for this example to be a good use of my time.

If you think this would be a good use of your time, there is space reserved for a hash in the header wgpu writes. The place to contribute that hashing is: https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-core/src/pipeline_cache.rs. The thing that you'd need to use as salt is probably instead (most of) the data in PipelineCacheHeader

@DJMcNab
Copy link
Member Author

DJMcNab commented Apr 4, 2025

I'll make it non-exhaustive here. There's little advantage to splitting it out.

Edit: Actually, I forgot how bad non_exhaustive is (it doesn't let you use ..Default::default. I've added a Default implementation, but stopped short of marking it actually non_exhaustive.

Copy link
Member

@xorgy xorgy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This is self contained, and errors therein are failsafe (apart from if JVM stuff explodes, but that will never be safe).

@DJMcNab DJMcNab force-pushed the pipeline-cache-repeat branch from a2cbd96 to 0021ec1 Compare April 30, 2025 20:13
@DJMcNab DJMcNab added this pull request to the merge queue May 1, 2025
Merged via the queue into linebender:main with commit a2fd838 May 1, 2025
17 checks passed
@DJMcNab DJMcNab deleted the pipeline-cache-repeat branch May 1, 2025 10:10
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