@@ -437,6 +437,8 @@ pub trait ConfigObj: DIService {
437437
438438 fn cachestore_cache_max_size ( & self ) -> u64 ;
439439
440+ fn cachestore_cache_compaction_trigger_size ( & self ) -> u64 ;
441+
440442 fn cachestore_cache_max_keys ( & self ) -> u32 ;
441443
442444 fn cachestore_cache_eviction_policy ( & self ) -> CacheEvictionPolicy ;
@@ -573,6 +575,7 @@ pub struct ConfigObjImpl {
573575 pub cachestore_cache_eviction_loop_interval : u64 ,
574576 pub cachestore_cache_ttl_persist_loop_interval : u64 ,
575577 pub cachestore_cache_max_size : u64 ,
578+ pub cachestore_cache_compaction_trigger_size : u64 ,
576579 pub cachestore_cache_threshold_to_force_eviction : u8 ,
577580 pub cachestore_queue_results_expire : u64 ,
578581 pub cachestore_metrics_interval : u64 ,
@@ -780,6 +783,10 @@ impl ConfigObj for ConfigObjImpl {
780783 self . cachestore_cache_max_size
781784 }
782785
786+ fn cachestore_cache_compaction_trigger_size ( & self ) -> u64 {
787+ self . cachestore_cache_compaction_trigger_size
788+ }
789+
783790 fn cachestore_cache_threshold_to_force_eviction ( & self ) -> u8 {
784791 self . cachestore_cache_threshold_to_force_eviction
785792 }
@@ -1098,6 +1105,20 @@ where
10981105}
10991106
11001107impl Config {
1108+ fn calculate_cache_compaction_trigger_size ( cache_max_size : usize ) -> usize {
1109+ match cache_max_size >> 20 {
1110+ // TODO: Enable this limits after moving to separate CF for cache
1111+ // d if d < 32 => 32 * 9,
1112+ // d if d < 64 => 64 * 8,
1113+ // d if d < 128 => 128 * 7,
1114+ // d if d < 256 => 256 * 6,
1115+ d if d < 512 => 512 * 5 ,
1116+ d if d < 1024 => cache_max_size * 4 ,
1117+ d if d < 4096 => cache_max_size * 3 ,
1118+ _ => cache_max_size * 2 ,
1119+ }
1120+ }
1121+
11011122 pub fn default ( ) -> Config {
11021123 let query_timeout = env_parse ( "CUBESTORE_QUERY_TIMEOUT" , 120 ) ;
11031124 let query_cache_time_to_idle_secs = env_parse (
@@ -1106,6 +1127,23 @@ impl Config {
11061127 60 * 60 ,
11071128 ) ;
11081129
1130+ let cachestore_cache_max_size = env_parse_size (
1131+ "CUBESTORE_CACHE_MAX_SIZE" ,
1132+ 4096 << 20 ,
1133+ // 16384 mb
1134+ Some ( 16_384 << 20 ) ,
1135+ // 32 mb
1136+ Some ( 32 << 20 ) ,
1137+ ) ;
1138+
1139+ let cachestore_cache_compaction_trigger_size = env_parse_size (
1140+ "CUBESTORE_CACHE_COMPACTION_TRIGGER_SIZE" ,
1141+ Self :: calculate_cache_compaction_trigger_size ( cachestore_cache_max_size) ,
1142+ None ,
1143+ // 256 mb
1144+ Some ( 256 << 20 ) ,
1145+ ) as u64 ;
1146+
11091147 Config {
11101148 injector : Injector :: new ( ) ,
11111149 config_obj : Arc :: new ( ConfigObjImpl {
@@ -1256,14 +1294,8 @@ impl Config {
12561294 // 0 to disable
12571295 Some ( 0 ) ,
12581296 ) ,
1259- cachestore_cache_max_size : env_parse_size (
1260- "CUBESTORE_CACHE_MAX_SIZE" ,
1261- 4096 << 20 ,
1262- // 16384 mb
1263- Some ( 16384 << 20 ) ,
1264- // 32 mb
1265- Some ( 32 << 20 ) ,
1266- ) as u64 ,
1297+ cachestore_cache_max_size : cachestore_cache_max_size as u64 ,
1298+ cachestore_cache_compaction_trigger_size,
12671299 cachestore_cache_threshold_to_force_eviction : 25 ,
12681300 cachestore_queue_results_expire : env_parse_duration (
12691301 "CUBESTORE_QUEUE_RESULTS_EXPIRE" ,
@@ -1474,7 +1506,8 @@ impl Config {
14741506 cachestore_gc_loop_interval : 30 ,
14751507 cachestore_cache_eviction_loop_interval : 60 ,
14761508 cachestore_cache_ttl_persist_loop_interval : 15 ,
1477- cachestore_cache_max_size : 4096 << 32 ,
1509+ cachestore_cache_max_size : 4096 << 20 ,
1510+ cachestore_cache_compaction_trigger_size : 4096 * 2 << 20 ,
14781511 cachestore_cache_threshold_to_force_eviction : 25 ,
14791512 cachestore_queue_results_expire : 90 ,
14801513 cachestore_metrics_interval : 15 ,
0 commit comments