diff --git a/src/mito2/src/memtable/partition_tree.rs b/src/mito2/src/memtable/partition_tree.rs index a6a5f9dd4475..fccbf8387c4a 100644 --- a/src/mito2/src/memtable/partition_tree.rs +++ b/src/mito2/src/memtable/partition_tree.rs @@ -45,7 +45,7 @@ use crate::memtable::{ }; /// Use `1/DICTIONARY_SIZE_FACTOR` of OS memory as dictionary size. -const DICTIONARY_SIZE_FACTOR: u64 = 8; +pub(crate) const DICTIONARY_SIZE_FACTOR: u64 = 8; pub(crate) const DEFAULT_MAX_KEYS_PER_SHARD: usize = 8192; pub(crate) const DEFAULT_FREEZE_THRESHOLD: usize = 131072; @@ -84,7 +84,7 @@ pub struct PartitionTreeConfig { impl Default for PartitionTreeConfig { fn default() -> Self { - let mut fork_dictionary_bytes = ReadableSize::gb(1); + let mut fork_dictionary_bytes = ReadableSize::mb(512); if let Some(sys_memory) = common_config::utils::get_sys_total_memory() { let adjust_dictionary_bytes = std::cmp::min(sys_memory / DICTIONARY_SIZE_FACTOR, fork_dictionary_bytes); diff --git a/src/mito2/src/region/options.rs b/src/mito2/src/region/options.rs index f595b1f15bc7..e890207e874b 100644 --- a/src/mito2/src/region/options.rs +++ b/src/mito2/src/region/options.rs @@ -248,10 +248,20 @@ pub struct PartitionTreeOptions { impl Default for PartitionTreeOptions { fn default() -> Self { + let mut fork_dictionary_bytes = ReadableSize::mb(512); + if let Some(sys_memory) = common_config::utils::get_sys_total_memory() { + let adjust_dictionary_bytes = std::cmp::min( + sys_memory / crate::memtable::partition_tree::DICTIONARY_SIZE_FACTOR, + fork_dictionary_bytes, + ); + if adjust_dictionary_bytes.0 > 0 { + fork_dictionary_bytes = adjust_dictionary_bytes; + } + } Self { index_max_keys_per_shard: DEFAULT_MAX_KEYS_PER_SHARD, data_freeze_threshold: DEFAULT_FREEZE_THRESHOLD, - fork_dictionary_bytes: ReadableSize::mb(64), + fork_dictionary_bytes, } } }