-
-
Notifications
You must be signed in to change notification settings - Fork 227
Optimise Ajv cache usage #1062
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
Optimise Ajv cache usage #1062
Conversation
Co-authored-by: Roberto Bruggemann <1833249+rbruggem@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Appreciate this update! Looks good 👍
I'm noticing in our test suite that I have a feeling that this change might (ironically) be the cause of that: It turns out that despite the recommendation in |
A small follow-up on this: I have now taken version |
I believe you're right, and |
This reverts commit 990995b.
Introducing a key which can be used to for caching in by Ajv library.
Currently the whole schema is used as a cache key in each
ajv
instance1,for very large schemas this leads to a lot of unnecessary memory usage since
a whole string representation of the schema is stored with each
compile()
.The
ajv
cache is never used, since there's already a cache implementationin the code base, but by passing a much shorter key to
ajv
we optimisememory usage.
Footnotes
https://ajv.js.org/guide/managing-schemas.html#cache-key-schema-vs-key-vs-id ↩