eric-maynard commented on code in PR #490:
URL: https://github.com/apache/polaris/pull/490#discussion_r1996498993
##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/cache/EntityCache.java:
##########
@@ -72,14 +75,21 @@ public EntityCache(@Nonnull PolarisMetaStoreManager
polarisMetaStoreManager) {
}
};
- // use a Caffeine cache to purge entries when those have not been used for
a long time.
- // Assuming 1KB per entry, 100K entries is about 100MB.
- this.byId =
+ long weigherTarget =
+
PolarisConfiguration.loadConfig(FeatureConfiguration.ENTITY_CACHE_WEIGHER_TARGET);
+ Caffeine<Long, ResolvedPolarisEntity> byIdBuilder =
Caffeine.newBuilder()
- .maximumSize(100_000) // Set maximum size to 100,000 elements
+ .maximumWeight(weigherTarget)
+ .weigher(EntityWeigher.asWeigher())
.expireAfterAccess(1, TimeUnit.HOURS) // Expire entries after 1
hour of no access
- .removalListener(removalListener) // Set the removal listener
- .build();
+ .removalListener(removalListener); // Set the removal listener
+
+ if
(PolarisConfiguration.loadConfig(BehaviorChangeConfiguration.ENTITY_CACHE_SOFT_VALUES))
{
+ byIdBuilder.softValues();
Review Comment:
In my testing, it improved performance and prevented situations where a
large cache lead to OOMs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]