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

Missing documentation around cache size limits before 3.11 #12068

Open
CamJohnson26 opened this issue Sep 19, 2024 · 2 comments
Open

Missing documentation around cache size limits before 3.11 #12068

CamJohnson26 opened this issue Sep 19, 2024 · 2 comments

Comments

@CamJohnson26
Copy link

Hi there, we upgraded to 3.11 in prod and had to revert since users were hitting extremely slow performance when making large queries. On investigation, users are exceeding the 50,000 cache limit on executeSelectionSet or the 10,000 limit on executeSubSelectedArray.

To fix the issue and reupgrade we're planning to increase the cacheLimit to what it was before 3.11, but can't find this information in the upgrade guide. From https://github.com/benjamn/optimism/blob/main/src/index.ts#L142 and https://github.com/apollographql/apollo-client/pull/8107/files#diff-aba857f65aabe3dce87a57f153d5cc33fe292065af0dcc6c1742b116b226893aR111 we believe it was set to 2**16 previously, but would love it if this can be verified.

Thanks so much, and thanks for these new cache configuration parameters, they'll be huge for us.

@jerelmiller
Copy link
Member

Hey @CamJohnson26 👋

I believe what you're looking for is this doc: https://www.apollographql.com/docs/react/caching/memory-management. This was something added in 3.9.0. Are you perhaps upgrading from a version before that? I don't believe we've touched these values since we released 3.9.

If you're also looking for a bit more in-depth dive on it, check out Lenz's blog post on memory management in 3.9: https://www.apollographql.com/blog/apollo-3-9-beta-feature-spotlight-the-memory-story

Regardless, let me know if that helps!

@CamJohnson26
Copy link
Author

We also believe that our cache limits were too generous, so we revisited every internal memoization cache, double-checked our key usage, replaced all WeakMaps with a new Weak LRU Cache implementation, and made sure that each cache has a more reasonable maximum size that better represents the results it stores.

While those defaults should be sufficient in 90% of applications, we know that some applications will need to make different trade-offs, so we made each cache size individually configurable. You can read up on all the new configuration options in this new documentation page on memory management.

This is the bit I think it would be useful to clarify, what those previous generous cache limits were. I think they were 2**16 but would be good if you can verify that. Pretty sure it was using the optimism library's built in default.

And yes exactly, we're all the way back on 3.6

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

No branches or pull requests

2 participants