Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-plugin-sharp): cache image metadata #35791

Merged
merged 2 commits into from
Jun 1, 2022

Conversation

ascorbic
Copy link
Contributor

Description

Caches image metadata between builds

Documentation

Currently gatsby-plugin-sharp uses an in-memory cache to store image metadata during a build, but it is not persisted between builds. This means that the relatively expensive dominant color calculations need to be re-done each time. This PR switches to use the GatsbyCache if it is available, falling back to the in-memory cache otherwise. In my tests, this saved over a minute for warm-cache builds of a site with 100 images.

Related Issues

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 31, 2022
@pieh pieh added topic: media Related to gatsby-plugin-image, or general image/media processing topics and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 1, 2022
pieh
pieh previously approved these changes Jun 1, 2022
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Nice!

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

Thanks! I'll investigate what's going on with the development runtime tests and see if I can reproduce locally

@LekoArts
Copy link
Contributor

LekoArts commented Jun 1, 2022

The development/production have some flaky tests, I've restarted them and let's see

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

They failed when I opened the PR which I assumed was flakiness, but failed again today when @pieh restarted them, so I think it may be real

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

They're all failing on hot-reloading/new-file.js, which seems unlikely to be related. I'm failing to get them running properly on my machine

@LekoArts
Copy link
Contributor

LekoArts commented Jun 1, 2022

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

Aha. Another PR failing with the same test. Must be unrelated.

@LekoArts
Copy link
Contributor

LekoArts commented Jun 1, 2022

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

Hah. Jinx. OK, so should this wait til that fix lands?

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

Hmm. I don't understand what's happening with that one: https://dashboard.cypress.io/projects/5k8zbj/runs/641/overview/ee804400-e764-4d86-a9a5-362aae24bdab

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

I've pushed another commit with that ({ force: true }) change, just to see if the tests then pass

@LekoArts LekoArts merged commit 7d93d2e into gatsbyjs:master Jun 1, 2022
@LekoArts
Copy link
Contributor

LekoArts commented Jun 1, 2022

Published at next 👍

@ascorbic ascorbic deleted the mk/cache-dominant branch June 1, 2022 12:44
@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

I have another optimisation coming in shortly

@ascorbic
Copy link
Contributor Author

ascorbic commented Jun 1, 2022

@LekoArts #35814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants