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: cache getCollection() calls in production #6503

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Mar 10, 2023

Changes

Follows up on a performance bottleneck we found while migrating the Astro docs to content collections. @delucis noted that repeat calls to getCollection('docs') slowed production builds, and centralizing to a single, top-level getCollection() call resolved the issue. This PR introduces a production-only cache to mirror this experience.

Testing

  • Created a branch on the docs repo to measure production build changes in CI: [DRAFT] getCollection perf improvements when called multiple times docs#2816 Found a ~10% improvement
  • Built three times locally with caching and three times without. Noticed the same ~10% improvement
  • Tracked memory usage building locally with and without caching. Each peeked at roughly the same 4.30 GB figure.

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2023

🦋 Changeset detected

Latest commit: 0c1b5ea

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 10, 2023
@bholmesdev bholmesdev merged commit f6eddff into main Mar 10, 2023
@bholmesdev bholmesdev deleted the collections-perf-improvements branch March 10, 2023 18:50
@astrobot-houston astrobot-houston mentioned this pull request Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants