Skip to content
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

[core] Separate index cache and data cache #4438

Merged
merged 6 commits into from
Nov 11, 2024

Conversation

Aitozi
Copy link
Contributor

@Aitozi Aitozi commented Nov 4, 2024

Purpose

Linked issue: close #4437

Tests

API and Format

Documentation

<tr>
<td><h5>lookup.hash-load-factor</h5></td>
<td style="word-wrap: break-word;">0.75</td>
<td>Float</td>
<td>The index load factor for lookup.</td>
</tr>
<tr>
<td><h5>lookup.index-cache-max-memory-size</h5></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/deployment/config/#rocksdb-state-backend

Can we just introduce an option like state.backend.rocksdb.memory.high-prio-pool-ratio?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

@@ -915,6 +915,13 @@ public class CoreOptions implements Serializable {
.defaultValue(MemorySize.parse("256 mb"))
.withDescription("Max memory size for lookup cache.");

public static final ConfigOption<Double> LOOKUP_CACHE_HIGH_PRIO_POOL_RATIO =
key("lookup.cache.high-prio-pool-ratio")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lookup.cache.high-priority-pool-ratio may be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

public CacheManager(
Cache.CacheType cacheType, MemorySize maxMemorySize, double highPrioPoolRatio) {
Preconditions.checkArgument(
highPrioPoolRatio >= 0 && highPrioPoolRatio < 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pay attention to the accuracy of floating-point numbers here, which may lead to judgment errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e, I think it's ok here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -61,9 +60,9 @@ private byte[] readFrom(long offset, int length) throws IOException {
}

public MemorySegment getBlock(
long position, int length, Function<byte[], byte[]> decompressFunc) {
long position, int length, Function<byte[], byte[]> decompressFunc, boolean index) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be isIndex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -423,6 +423,12 @@
<td>Double</td>
<td>Define the default false positive probability for lookup cache bloom filters.</td>
</tr>
<tr>
<td><h5>lookup.cache.high-priority-pool-ratio</h5></td>
<td style="word-wrap: break-word;">0.25</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the source of this default value? 0.1 or 0.25?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 0.1, the size is 25MB, 0.25 is 64MB. When I test, the bloom filter may occupy 5-10MB. So, I give a bigger (64MB) default index cache here.

static CacheKey forPosition(RandomAccessFile file, long position, int length) {
return new PositionCacheKey(file, position, length);
static CacheKey forPosition(RandomAccessFile file, long position, int length, boolean isIndex) {
return new PositionCacheKey(file, position, length, isIndex);
}

static CacheKey forPageIndex(RandomAccessFile file, int pageSize, int pageIndex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this method? The invoker should always set the isIndex.

Copy link
Contributor Author

@Aitozi Aitozi Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But for the pageIndex, we always store it in the data cache now. Because we are unsure if this page is an index page.

@JingsongLi
Copy link
Contributor

Hi @Aitozi , consider modifying old hash store, can you test it in your production env? I am not sure if this modification is good for old hash store.

@Aitozi
Copy link
Contributor Author

Aitozi commented Nov 5, 2024

Hi @Aitozi , consider modifying old hash store, can you test it in your production env? I am not sure if this modification is good for old hash store.

Sure, will test it first

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi JingsongLi merged commit 85f563b into apache:master Nov 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Separate index cache and data cache in look up cache
3 participants