feat: add async cache for segment indexes #472
Merged
AnatolyPopov merged 2 commits intomainfrom Jan 11, 2024
Merged
Conversation
aed6581 to
becc24a
Compare
05c66b1 to
399dc2a
Compare
ivanyu
reviewed
Jan 2, 2024
core/src/main/java/io/aiven/kafka/tieredstorage/RemoteStorageManager.java
Outdated
Show resolved
Hide resolved
ivanyu
reviewed
Jan 2, 2024
core/src/main/java/io/aiven/kafka/tieredstorage/fetch/index/MemorySegmentIndexesCache.java
Outdated
Show resolved
Hide resolved
ivanyu
reviewed
Jan 2, 2024
ivanyu
reviewed
Jan 2, 2024
Comment on lines
+59
to
+66
| public RemovalListener<SegmentIndexKey, byte[]> removalListener() { | ||
| return (key, content, cause) -> log.debug("Deleted cached value for key {} from cache." | ||
| + " The reason of the deletion is {}", key, cause); | ||
| } | ||
|
|
||
| public Weigher<SegmentIndexKey, byte[]> weigher() { | ||
| return (key, value) -> value.length; | ||
| } |
Contributor
There was a problem hiding this comment.
Do these two need to be higher-order functions?
Suggested change
| public RemovalListener<SegmentIndexKey, byte[]> removalListener() { | |
| return (key, content, cause) -> log.debug("Deleted cached value for key {} from cache." | |
| + " The reason of the deletion is {}", key, cause); | |
| } | |
| public Weigher<SegmentIndexKey, byte[]> weigher() { | |
| return (key, value) -> value.length; | |
| } | |
| private static void removalListener(final SegmentIndexKey key, final byte[] value, RemovalCause cause) { | |
| log.debug("Deleted cached value for key {} from cache. The reason of the deletion is {}", key, cause); | |
| } | |
| private static int weigher(final SegmentIndexKey key, byte[] value) { | |
| return value.length; | |
| } |
ivanyu
reviewed
Jan 2, 2024
core/src/main/java/io/aiven/kafka/tieredstorage/fetch/index/SegmentIndexKey.java
Show resolved
Hide resolved
ivanyu
reviewed
Jan 2, 2024
| verifyNoMoreInteractions(offsetIndexSupplier); | ||
| assertThat(cache.cache.asMap()).hasSize(1); | ||
|
|
||
| Thread.sleep(100); |
Contributor
There was a problem hiding this comment.
It's worth adding a comment that this sleep is needed to spread away in time the creation (and eviction) of the cache entries, or something like this
Contributor
Author
There was a problem hiding this comment.
Good point, let's do the latter.
Contributor
Author
There was a problem hiding this comment.
@AnatolyPopov, falling back to using thread sleep (same as in ChunkCacheTest) as adding a stronger condition (e.g. waiting for cache to be empty) takes unknown amount of time github actions--unless there's a better approach here.
ivanyu
reviewed
Jan 2, 2024
core/src/test/java/io/aiven/kafka/tieredstorage/fetch/index/MemorySegmentIndexesCacheTest.java
Outdated
Show resolved
Hide resolved
AnatolyPopov
reviewed
Jan 3, 2024
core/src/main/java/io/aiven/kafka/tieredstorage/config/RemoteStorageManagerConfig.java
Outdated
Show resolved
Hide resolved
AnatolyPopov
reviewed
Jan 3, 2024
core/src/test/java/io/aiven/kafka/tieredstorage/fetch/index/MemorySegmentIndexesCacheTest.java
Outdated
Show resolved
Hide resolved
AnatolyPopov
reviewed
Jan 3, 2024
core/src/test/java/io/aiven/kafka/tieredstorage/config/CacheConfigTest.java
Outdated
Show resolved
Hide resolved
AnatolyPopov
reviewed
Jan 3, 2024
core/src/main/java/io/aiven/kafka/tieredstorage/fetch/index/MemorySegmentIndexesCache.java
Outdated
Show resolved
Hide resolved
973aed6 to
c49d3f3
Compare
Indexes are currently cached on broker-side but with a synchronous cache that is not able to source value when interrupted. This new cache will fetch index asynchronously, and retries would have chances to find the value sourced already.
6ac772f to
9d260c2
Compare
AnatolyPopov
approved these changes
Jan 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Indexes are currently cached on broker-side but with a synchronous cache that is not able to source value when interrupted.
This new cache will fetch index asynchronously, and retries would have chances to find the value sourced already.