Skip to content

Commit

Permalink
fix: performance degradation caused by config change (#3556)
Browse files Browse the repository at this point in the history
  • Loading branch information
v0y4g3r authored Mar 21, 2024
1 parent 8b7a5aa commit 1f0fc40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/mito2/src/memtable/partition_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion src/mito2/src/region/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down

0 comments on commit 1f0fc40

Please sign in to comment.