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 |
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.0The 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.mdif applicable[WIP]to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormatto make sure that the source files are formatted@getquill/maintainers
Note:
sbt scalariformFormat test:scalariformFormatgive me error: