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

Add a maximum size to the Delta Lake metadata cache #14571

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DeltaLakeConfig
static final DataSize DEFAULT_DATA_FILE_CACHE_SIZE = DataSize.succinctBytes(Math.floorDiv(Runtime.getRuntime().maxMemory(), 10L));

private Duration metadataCacheTtl = new Duration(5, TimeUnit.MINUTES);
private long metadataCacheMaxSize = 1000;
private DataSize dataFileCacheSize = DEFAULT_DATA_FILE_CACHE_SIZE;
private Duration dataFileCacheTtl = new Duration(30, TimeUnit.MINUTES);
private int domainCompactionThreshold = 100;
Expand Down Expand Up @@ -86,6 +87,19 @@ public DeltaLakeConfig setMetadataCacheTtl(Duration metadataCacheTtl)
return this;
}

public long getMetadataCacheMaxSize()
{
return metadataCacheMaxSize;
}

@Config("delta.metadata.cache-size")
@ConfigDescription("Maximum number of Delta table metadata entries to cache")
public DeltaLakeConfig setMetadataCacheMaxSize(long metadataCacheMaxSize)
{
this.metadataCacheMaxSize = metadataCacheMaxSize;
return this;
}

public DataSize getDataFileCacheSize()
{
return dataFileCacheSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public TransactionLogAccess(

tableSnapshots = EvictableCacheBuilder.newBuilder()
.expireAfterWrite(deltaLakeConfig.getMetadataCacheTtl().toMillis(), TimeUnit.MILLISECONDS)
.maximumSize(deltaLakeConfig.getMetadataCacheMaxSize())
.shareNothingWhenDisabled()
.recordStats()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void testDefaults()
.setDataFileCacheSize(DeltaLakeConfig.DEFAULT_DATA_FILE_CACHE_SIZE)
.setDataFileCacheTtl(new Duration(30, MINUTES))
.setMetadataCacheTtl(new Duration(5, TimeUnit.MINUTES))
.setMetadataCacheMaxSize(1000)
.setDomainCompactionThreshold(100)
.setMaxSplitsPerSecond(Integer.MAX_VALUE)
.setMaxOutstandingSplits(1_000)
Expand Down Expand Up @@ -71,6 +72,7 @@ public void testExplicitPropertyMappings()
{
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put("delta.metadata.cache-ttl", "10m")
.put("delta.metadata.cache-size", "10")
.put("delta.metadata.live-files.cache-size", "0 MB")
.put("delta.metadata.live-files.cache-ttl", "60m")
.put("delta.domain-compaction-threshold", "500")
Expand Down Expand Up @@ -101,6 +103,7 @@ public void testExplicitPropertyMappings()
.setDataFileCacheSize(DataSize.succinctBytes(0))
.setDataFileCacheTtl(new Duration(60, MINUTES))
.setMetadataCacheTtl(new Duration(10, TimeUnit.MINUTES))
.setMetadataCacheMaxSize(10)
.setDomainCompactionThreshold(500)
.setMaxOutstandingSplits(200)
.setMaxSplitsPerSecond(10)
Expand Down