-
Notifications
You must be signed in to change notification settings - Fork 346
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
Add a max size for normalize cache #2878
Conversation
f8da003
to
19412f0
Compare
Pushed a new commit to make the default cache size 1024. However from my profiling, each AST seems to have pretty different sizes. I'm wondering if there is a way to get memory footprint from an AST efficiently so that we can use CacheBuilder.weigher(Weigher) to make the cache size smarter |
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.
03a8850
to
2b81fc5
Compare
Oh seems |
We're sorry for you and we're sorry to have to maintain Scala 2.12 compat 😄 |
Latest version of Caffeine doesn't support Java8 anymore apparently: [error] java.lang.UnsupportedClassVersionError: com/github/benmanes/caffeine/cache/Caffeine has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 The good news is that we're about to drop support of JDK8 too! FYI: #2878 |
This fixes zio#2484. Added a capacity to normalize cache. Default to 1024 and can be override by `quill.query.cacheDynamicMaxSize`. Added a new dependency Caffeine to use its cache implementation, which is recommended by Guava. For a critical use case in quill, I think it's better to have a widely tested implementation than reinventing the wheel.
@guizmaii oh I didn't realize you are working on dropping Java 8. I added a check for Java version so we can use it without breaking Java 8 |
The ZIO environment in its entirety decided to remove Java8 support (triggered by some needs in zio-quill) |
Thanks again for your work @wb14123! ❤️ |
This fixes #2484. Added a capacity to normalize cache. Default to 1024 and can be override by `quill.query.cacheDynamicMaxSize`. Added a new dependency Caffeine to use its cache implementation, which is recommended by Guava. For a critical use case in quill, I think it's better to have a widely tested implementation than reinventing the wheel. Co-authored-by: Jules Ivanic <[email protected]>
Fixes #2484
Problem
There is no bound for normalize cache which results memory usage increase without limit for dynamic queries.
Solution
Added a capacity to normalize cache. Default to 1024 and can be override by
quill.query.cacheDynamicMaxSize
.Notes
Added a new dependency Google Guava to use its cache implementation. I know it's better to avoid new dependency but Google Guava is a pretty widely adopted library. It's cache implementation is widely tested. For such a critical use case in quill, I think it's better to have a widely tested implementation than reinventing the wheel.
Checklist
README.md
if applicable[WIP]
to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormat
to make sure that the source files are formatted@getquill/maintainers
Note:
sbt scalariformFormat test:scalariformFormat
give me error: