Skip to content

Commit

Permalink
feat(ctl): support mutable compression_algorithm (#17026)
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k authored and zwang28 committed Jun 18, 2024
1 parent 6d1cdf4 commit e4e2265
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proto/hummock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ message RiseCtlListCompactionGroupResponse {
}

message RiseCtlUpdateCompactionConfigRequest {
message CompressionAlgorithm {
uint32 level = 1;
string compression_algorithm = 2;
}

message MutableConfig {
oneof mutable_config {
uint64 max_bytes_for_level_base = 1;
Expand All @@ -666,6 +671,7 @@ message RiseCtlUpdateCompactionConfigRequest {
uint64 level0_max_compact_file_number = 14;
bool enable_emergency_picker = 15;
uint32 tombstone_reclaim_ratio = 16;
CompressionAlgorithm compression_algorithm = 17;
}
}
repeated uint64 compaction_group_ids = 1;
Expand Down
5 changes: 5 additions & 0 deletions src/ctl/src/cmd_impl/hummock/compaction_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use risingwave_hummock_sdk::compaction_group::StateTableId;
use risingwave_hummock_sdk::{CompactionGroupId, HummockContextId};
use risingwave_pb::hummock::compact_task::TaskStatus;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::mutable_config::MutableConfig;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::CompressionAlgorithm;

use crate::CtlContext;

Expand Down Expand Up @@ -63,6 +64,7 @@ pub fn build_compaction_config_vec(
level0_overlapping_sub_level_compact_level_count: Option<u32>,
enable_emergency_picker: Option<bool>,
tombstone_reclaim_ratio: Option<u32>,
compress_algorithm: Option<CompressionAlgorithm>,
) -> Vec<MutableConfig> {
let mut configs = vec![];
if let Some(c) = max_bytes_for_level_base {
Expand Down Expand Up @@ -110,6 +112,9 @@ pub fn build_compaction_config_vec(
if let Some(c) = tombstone_reclaim_ratio {
configs.push(MutableConfig::TombstoneReclaimRatio(c))
}
if let Some(c) = compress_algorithm {
configs.push(MutableConfig::CompressionAlgorithm(c))
}

configs
}
Expand Down
16 changes: 16 additions & 0 deletions src/ctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use cmd_impl::bench::BenchCommands;
use cmd_impl::hummock::SstDumpArgs;
use risingwave_hummock_sdk::HummockEpoch;
use risingwave_meta::backup_restore::RestoreOpts;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::CompressionAlgorithm;
use risingwave_pb::meta::update_worker_node_schedulability_request::Schedulability;
use thiserror_ext::AsReport;

Expand Down Expand Up @@ -240,6 +241,10 @@ enum HummockCommands {
enable_emergency_picker: Option<bool>,
#[clap(long)]
tombstone_reclaim_ratio: Option<u32>,
#[clap(long)]
compression_level: Option<u32>,
#[clap(long)]
compression_algorithm: Option<String>,
},
/// Split given compaction group into two. Moves the given tables to the new group.
SplitCompactionGroup {
Expand Down Expand Up @@ -662,6 +667,8 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
level0_overlapping_sub_level_compact_level_count,
enable_emergency_picker,
tombstone_reclaim_ratio,
compression_level,
compression_algorithm,
}) => {
cmd_impl::hummock::update_compaction_config(
context,
Expand All @@ -682,6 +689,15 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
level0_overlapping_sub_level_compact_level_count,
enable_emergency_picker,
tombstone_reclaim_ratio,
if let Some(level) = compression_level {
assert!(compression_algorithm.is_some());
Some(CompressionAlgorithm {
level,
compression_algorithm: compression_algorithm.unwrap(),
})
} else {
None
},
),
)
.await?
Expand Down
5 changes: 5 additions & 0 deletions src/meta/src/hummock/manager/compaction_group_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,11 @@ fn update_compaction_config(target: &mut CompactionConfig, items: &[MutableConfi
MutableConfig::TombstoneReclaimRatio(c) => {
target.tombstone_reclaim_ratio = *c;
}

MutableConfig::CompressionAlgorithm(c) => {
target.compression_algorithm[c.get_level() as usize]
.clone_from(&c.compression_algorithm);
}
}
}
}
Expand Down

0 comments on commit e4e2265

Please sign in to comment.