[Enhancement] Add config to disable statistics cache lazy refresh by default (backport #62518) (#62573)
Co-authored-by: stephen <91597003+stephen-shelby@users.noreply.github.com>
This commit is contained in:
parent
95b4145579
commit
dacc9100f5
|
|
@ -2127,7 +2127,7 @@ public class Config extends ConfigBase {
|
|||
* The size of the thread-pool which will be used to refresh statistic caches
|
||||
*/
|
||||
@ConfField
|
||||
public static int statistic_cache_thread_pool_size = 10;
|
||||
public static int statistic_cache_thread_pool_size = 5;
|
||||
|
||||
@ConfField
|
||||
public static int slot_manager_response_thread_pool_size = 16;
|
||||
|
|
@ -2150,6 +2150,9 @@ public class Config extends ConfigBase {
|
|||
@ConfField(mutable = true)
|
||||
public static long statistic_update_interval_sec = 24L * 60L * 60L;
|
||||
|
||||
@ConfField(mutable = true)
|
||||
public static boolean enable_statistic_cache_refresh_after_write = false;
|
||||
|
||||
@ConfField(mutable = true)
|
||||
public static long statistic_collect_too_many_version_sleep = 600000; // 10min
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -720,12 +720,17 @@ public class CachedStatisticStorage implements StatisticStorage, MemoryTrackable
|
|||
}
|
||||
|
||||
private <K, V> AsyncLoadingCache<K, V> createAsyncLoadingCache(AsyncCacheLoader<K, V> cacheLoader) {
|
||||
return Caffeine.newBuilder()
|
||||
Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder()
|
||||
.expireAfterWrite(Config.statistic_update_interval_sec * 2, TimeUnit.SECONDS)
|
||||
.refreshAfterWrite(Config.statistic_update_interval_sec, TimeUnit.SECONDS)
|
||||
.maximumSize(Config.statistic_cache_columns)
|
||||
.executor(statsCacheRefresherExecutor)
|
||||
.buildAsync(cacheLoader);
|
||||
.executor(statsCacheRefresherExecutor);
|
||||
|
||||
// Only enable refreshAfterWrite if the config is enabled
|
||||
if (Config.enable_statistic_cache_refresh_after_write) {
|
||||
cacheBuilder.refreshAfterWrite(Config.statistic_update_interval_sec, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
return cacheBuilder.buildAsync(cacheLoader);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue