Skip to content

Commit 2f4b75b

Browse files
authored
fix(cubestore): Wrong calculation of default compaction trigger size (too often compaction) (#7960)
1 parent 418a01e commit 2f4b75b

File tree

1 file changed

+13
-9
lines changed
  • rust/cubestore/cubestore/src/config

1 file changed

+13
-9
lines changed

rust/cubestore/cubestore/src/config/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,12 @@ where
10831083
pub fn env_parse_size(name: &str, default: usize, max: Option<usize>, min: Option<usize>) -> usize {
10841084
let v = match env::var(name).ok() {
10851085
None => {
1086-
return default;
1086+
if cfg!(debug_assertions) {
1087+
// It's needed to check that default values are correct
1088+
default.to_string()
1089+
} else {
1090+
return default;
1091+
}
10871092
}
10881093
Some(v) => v,
10891094
};
@@ -1135,17 +1140,16 @@ where
11351140

11361141
impl Config {
11371142
fn calculate_cache_compaction_trigger_size(cache_max_size: usize) -> usize {
1138-
match cache_max_size >> 20 {
1139-
// TODO: Enable this limits after moving to separate CF for cache
1140-
// d if d < 32 => 32 * 9,
1141-
// d if d < 64 => 64 * 8,
1142-
// d if d < 128 => 128 * 7,
1143-
// d if d < 256 => 256 * 6,
1144-
d if d < 512 => 512 * 5,
1143+
let trigger_size = match cache_max_size >> 20 {
1144+
d if d < 32 => (640 << 20),
1145+
d if d < 64 => (1280 << 20),
1146+
d if d < 512 => cache_max_size * 5,
11451147
d if d < 1024 => cache_max_size * 4,
11461148
d if d < 4096 => cache_max_size * 3,
11471149
_ => cache_max_size * 2,
1148-
}
1150+
};
1151+
1152+
std::cmp::max(trigger_size, 512 << 20)
11491153
}
11501154

11511155
pub fn default() -> Config {

0 commit comments

Comments
 (0)