Skip to content

Commit

Permalink
feat(config): add config for calculate max_overlapping_level_size
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Nov 19, 2024
1 parent c8a6fab commit 868bef9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions proto/hummock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ message RiseCtlUpdateCompactionConfigRequest {
uint64 sst_allowed_trivial_move_min_size = 19;
uint32 split_weight_by_vnode = 20;
bool disable_auto_group_scheduling = 21;
uint32 max_overlapping_level_size_ratio = 22;
}
}
repeated uint64 compaction_group_ids = 1;
Expand Down Expand Up @@ -858,6 +859,11 @@ message CompactionConfig {

// The limitation of auto group scheduling
optional bool disable_auto_group_scheduling = 23;

// The limitation of the max size of the overlapping-level for the compaction
// e.g. max_overlapping_level_size = sub_level_max_compaction_bytes * max_overlapping_level_size_ratio
// hummock will reorg the commit-sstables to the multi overlapping-level if the size of the commit-sstables is larger than max_overlapping_level_size
optional uint32 max_overlapping_level_size_ratio = 24;
}

message TableStats {
Expand Down
4 changes: 4 additions & 0 deletions src/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,10 @@ pub mod default {
pub fn disable_auto_group_scheduling() -> bool {
false
}

pub fn max_overlapping_level_size_ratio() -> u32 {
4
}
}

pub mod object_store_config {
Expand Down
4 changes: 4 additions & 0 deletions src/ctl/src/cmd_impl/hummock/compaction_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub fn build_compaction_config_vec(
max_l0_compact_level: Option<u32>,
sst_allowed_trivial_move_min_size: Option<u64>,
disable_auto_group_scheduling: Option<bool>,
max_overlapping_level_size_ratio: Option<u32>,
) -> Vec<MutableConfig> {
let mut configs = vec![];
if let Some(c) = max_bytes_for_level_base {
Expand Down Expand Up @@ -127,6 +128,9 @@ pub fn build_compaction_config_vec(
if let Some(c) = disable_auto_group_scheduling {
configs.push(MutableConfig::DisableAutoGroupScheduling(c))
}
if let Some(c) = max_overlapping_level_size_ratio {
configs.push(MutableConfig::MaxOverlappingLevelSizeRatio(c))
}

configs
}
Expand Down
4 changes: 4 additions & 0 deletions src/ctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ enum HummockCommands {
sst_allowed_trivial_move_min_size: Option<u64>,
#[clap(long)]
disable_auto_group_scheduling: Option<bool>,
#[clap(long)]
max_overlapping_level_size_ratio: Option<u32>,
},
/// Split given compaction group into two. Moves the given tables to the new group.
SplitCompactionGroup {
Expand Down Expand Up @@ -578,6 +580,7 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
max_l0_compact_level,
sst_allowed_trivial_move_min_size,
disable_auto_group_scheduling,
max_overlapping_level_size_ratio,
}) => {
cmd_impl::hummock::update_compaction_config(
context,
Expand Down Expand Up @@ -610,6 +613,7 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
max_l0_compact_level,
sst_allowed_trivial_move_min_size,
disable_auto_group_scheduling,
max_overlapping_level_size_ratio,
),
)
.await?
Expand Down
3 changes: 3 additions & 0 deletions src/meta/src/hummock/compaction/compaction_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ impl CompactionConfigBuilder {
disable_auto_group_scheduling: Some(
compaction_config::disable_auto_group_scheduling(),
),
max_overlapping_level_size_ratio: Some(
compaction_config::max_overlapping_level_size_ratio(),
),
},
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/meta/src/hummock/manager/commit_epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::Arc;

use itertools::Itertools;
use risingwave_common::catalog::TableId;
use risingwave_common::config::default::compaction_config;
use risingwave_common::system_param::reader::SystemParamsRead;
use risingwave_hummock_sdk::change_log::ChangeLogDelta;
use risingwave_hummock_sdk::compaction_group::group_split::split_sst_with_table_ids;
Expand Down Expand Up @@ -457,7 +458,11 @@ fn rewrite_commit_sstables_to_sub_level(

let mut accumulated_size = 0;
let mut ssts = vec![];
let sub_level_size_limit = config.sub_level_max_compaction_bytes * 2; // TODO: use config instead of magic number
let sub_level_size_limit = config.sub_level_max_compaction_bytes
* config
.max_overlapping_level_size_ratio
.unwrap_or(compaction_config::max_overlapping_level_size_ratio())
as u64;

let level = overlapping_sstables.entry(group_id).or_default();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ fn update_compaction_config(target: &mut CompactionConfig, items: &[MutableConfi
MutableConfig::DisableAutoGroupScheduling(c) => {
target.disable_auto_group_scheduling = Some(*c);
}
MutableConfig::MaxOverlappingLevelSizeRatio(c) => {
target.max_overlapping_level_size_ratio = Some(*c);
}
}
}
}
Expand Down

0 comments on commit 868bef9

Please sign in to comment.