dimas-b commented on code in PR #490:
URL: https://github.com/apache/polaris/pull/490#discussion_r1999077963


##########
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:
   Thanks for this feedback! I'm glad to see that it had positive impact in you 
env :+1: 
   
   However, my experience with soft references in cache is not so bright and 
I'd advise caution, especially when Parallel GC is used. It may be able to 
recover from close-to-OOM conditions, but API response times are likely to 
suffer due to GC pauses. 
   
   Given that the default is off (not using soft values). I'm fine with this PR 
in general.



-- 
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]

Reply via email to