-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Replace Guava caches with Caffeine caches #3198
Conversation
This is a follow-up commit to the 9a22a1a commit Migrates the rest 7 caches from Guava implementation to Caffeine implementation This commit also removes a previously added Benchmark class with the obsolate GuavaVertexCache.class. The benchmark is provided in the next GitHub PR: #3188 which shows that Caffeine has better performance characteristics in all scenarious. ConcurencyLevel is not provided for the cache implementation anymore. The reason for this can be found by the following link https://groups.google.com/g/guava-discuss/c/BnoN9q9fDgw/m/6kF6H2aLAgAJ Related to #3188 and #3185 Partially related to #2033 Fixes #871 Signed-off-by: Oleksandr Porunov <[email protected]>
a6859eb
to
1754863
Compare
I don’t understand ExpirationKCVSCache, but it seems to do expiration itself with a cleanup thread. Caffeine has richer support than Guava (variable, scheduler) and might simplify this code. |
I don't know for sure but I assume For example, I don't understand the reason behind this loop over the whole cache: Line 212 in 1754863
Is really more efficient to get the whole cache as map, traverse over all keys of that cache and invalidate them if they were expired? Why didn't we just traverse expired keys and sent them to Basically, to cleanup the code I guess we need to figure out complexity of invalidate method for keys which are in the cache and keys which are not in the cache. |
The benchmarks on GitHub side are unreliable because it looks they are executed differently all the time. Thus, I executed benchmarks in my local environment where no other processes or change in environment could influence the result. That said, the removed benchmark in this PR (https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-benchmark/src/main/java/org/janusgraph/VertexCacheBenchmark.java) shows that Caffeine cache access is much faster then Guava cache access (10 times at least). Thus, I believe this PR is safe to transition the rest of the caches to Caffeine implementation. |
@ben-manes pointed here we may see benefit from the higher hit rate.
|
@JanusGraph/committers In case anyone needs time to review this PR, please, let me know. Otherwise, I would like to merge this PR in 48 hours |
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.
@porunov Awesome work.
This is a follow-up commit to the 9a22a1a commit
Suppressing #3197 to be able to run benchmark tests on this PR
Migrates the rest 7 caches from Guava implementation to Caffeine implementation
This commit also removes a previously added Benchmark class with the obsolate GuavaVertexCache.class. The benchmark is provided in the next GitHub PR: #3188 which shows that Caffeine has better performance characteristics in all scenarious.
ConcurencyLevel is not provided for the cache implementation anymore. The reason for this can be found by the following link https://groups.google.com/g/guava-discuss/c/BnoN9q9fDgw/m/6kF6H2aLAgAJ
Current JanusGraph benchmarks: https://gist.github.com/porunov/d07178afea8658e41a4802d1fca14274?permalink_comment_id=4287139#gistcomment-4287139
Current PR didn't show neither improvement nor regression in performance for the executed benchmark tests.
Guava recommends using Caffeine cache in their documentation. The only situation when Guava cache makes sense is when using Java <= 7. As JanusGraph supports Java 8 and higher, we can switch to Caffeine. See Guava documentation tells about Caffeine here.
Related to #3188 and #3185
Partially related to #2033
Fixes #871
Signed-off-by: Oleksandr Porunov [email protected]
Thank you for contributing to JanusGraph!
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
master
)?For code changes:
For documentation related changes: