From 75e02df520dee2fa2a97efe1253daa65e6a64c86 Mon Sep 17 00:00:00 2001 From: Little-Wallace Date: Wed, 30 Aug 2023 20:20:01 +0800 Subject: [PATCH] fix score and vnode config Signed-off-by: Little-Wallace --- src/common/src/config.rs | 4 ++-- src/meta/src/hummock/compaction/level_selector.rs | 5 ++++- src/meta/src/hummock/compaction/mod.rs | 7 +++++++ .../picker/base_level_compaction_picker.rs | 1 + .../compaction/picker/intral_sub_level_picker.rs | 12 +++++++++++- src/meta/src/hummock/compaction/picker/mod.rs | 1 + src/storage/hummock_test/src/compactor_tests.rs | 7 ++++++- 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/common/src/config.rs b/src/common/src/config.rs index 2c9b30bba84dd..fd896fd4258f1 100644 --- a/src/common/src/config.rs +++ b/src/common/src/config.rs @@ -846,7 +846,7 @@ pub mod default { } pub fn partition_vnode_count() -> u32 { - 64 + 8 } pub fn table_write_throughput_threshold() -> u64 { @@ -1199,7 +1199,7 @@ pub mod default { const DEFAULT_MAX_SPACE_RECLAIM_BYTES: u64 = 512 * 1024 * 1024; // 512MB; const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_SUB_LEVEL_NUMBER: u64 = 1000; const DEFAULT_MAX_COMPACTION_FILE_COUNT: u64 = 96; - const DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 4; + const DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 8; const DEFAULT_MIN_OVERLAPPING_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 6; use crate::catalog::hummock::CompactionFilterFlag; diff --git a/src/meta/src/hummock/compaction/level_selector.rs b/src/meta/src/hummock/compaction/level_selector.rs index d286c636c0485..df014e983340f 100644 --- a/src/meta/src/hummock/compaction/level_selector.rs +++ b/src/meta/src/hummock/compaction/level_selector.rs @@ -206,7 +206,7 @@ impl DynamicLevelSelectorCore { base_bytes_min + 1 } else { ctx.base_level = first_non_empty_level; - while ctx.base_level > 1 && cur_level_size > base_bytes_max * 2 { + while ctx.base_level > 1 && cur_level_size > base_bytes_max { ctx.base_level -= 1; cur_level_size /= self.config.max_bytes_for_level_multiplier; } @@ -471,6 +471,9 @@ impl LevelSelector for DynamicLevelSelector { if levels.member_table_ids.len() > 1 { ret.vnode_partition_count = 0; } + if stats.use_vnode_partition { + selector_stats.vnode_partition_task_count += 1; + } return Some(create_compaction_task( task_id, dynamic_level_core.get_config(), diff --git a/src/meta/src/hummock/compaction/mod.rs b/src/meta/src/hummock/compaction/mod.rs index 5e738c81a506f..dbbc14d6cca8c 100644 --- a/src/meta/src/hummock/compaction/mod.rs +++ b/src/meta/src/hummock/compaction/mod.rs @@ -259,6 +259,7 @@ impl Default for ManualCompactionOption { #[derive(Default)] pub struct LocalSelectorStatistic { skip_picker: Vec<(usize, usize, LocalPickerStatistic)>, + pub vnode_partition_task_count: usize, } impl LocalSelectorStatistic { @@ -294,6 +295,12 @@ impl LocalSelectorStatistic { .with_label_values(&[level_label.as_str(), "picker"]) .inc(); } + if self.vnode_partition_task_count > 0 { + metrics + .compact_skip_frequency + .with_label_values(&["partition", ""]) + .inc(); + } } } diff --git a/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs b/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs index a87c029504f7d..51cf48513f702 100644 --- a/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs +++ b/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs @@ -239,6 +239,7 @@ impl LevelCompactionPicker { [target_part.left_idx..target_part.right_idx] .to_vec(), }); + stats.use_vnode_partition = true; return Some(CompactionInput { input_levels, target_level: self.target_level, diff --git a/src/meta/src/hummock/compaction/picker/intral_sub_level_picker.rs b/src/meta/src/hummock/compaction/picker/intral_sub_level_picker.rs index fb67147d97861..4173156043d46 100644 --- a/src/meta/src/hummock/compaction/picker/intral_sub_level_picker.rs +++ b/src/meta/src/hummock/compaction/picker/intral_sub_level_picker.rs @@ -55,7 +55,7 @@ impl CompactionPicker for IntraSubLevelPicker { &mut self, levels: &Levels, level_handlers: &[LevelHandler], - _stats: &mut LocalPickerStatistic, + stats: &mut LocalPickerStatistic, ) -> Option { let l0 = levels.l0.as_ref().unwrap(); let max_sub_level_id = self @@ -154,6 +154,8 @@ impl CompactionPicker for IntraSubLevelPicker { }); } + let mut skip_pending_compact = false; + for part in &self.partitions { for (idx, info) in part.sub_levels.iter().enumerate() { if info.total_file_size > self.config.sub_level_max_compaction_bytes { @@ -199,6 +201,7 @@ impl CompactionPicker for IntraSubLevelPicker { input_levels.push(input_level); } if pending_compact { + skip_pending_compact = true; break; } } @@ -207,6 +210,8 @@ impl CompactionPicker for IntraSubLevelPicker { continue; } + stats.use_vnode_partition = true; + return Some(CompactionInput { input_levels, target_level: 0, @@ -215,6 +220,11 @@ impl CompactionPicker for IntraSubLevelPicker { }); } } + if skip_pending_compact { + stats.skip_by_pending_files += 1; + } else { + stats.skip_by_count_limit += 1; + } None } } diff --git a/src/meta/src/hummock/compaction/picker/mod.rs b/src/meta/src/hummock/compaction/picker/mod.rs index f5afe1da1cff5..5312f59c2c024 100644 --- a/src/meta/src/hummock/compaction/picker/mod.rs +++ b/src/meta/src/hummock/compaction/picker/mod.rs @@ -40,6 +40,7 @@ pub struct LocalPickerStatistic { pub skip_by_count_limit: u64, pub skip_by_pending_files: u64, pub skip_by_overlapping: u64, + pub use_vnode_partition: bool, } pub struct CompactionInput { pub input_levels: Vec, diff --git a/src/storage/hummock_test/src/compactor_tests.rs b/src/storage/hummock_test/src/compactor_tests.rs index 17186b6675c78..52effc2d5d52e 100644 --- a/src/storage/hummock_test/src/compactor_tests.rs +++ b/src/storage/hummock_test/src/compactor_tests.rs @@ -1463,6 +1463,11 @@ pub(crate) mod tests { } } + println!( + "partition compact task count: {}", + self.stats.vnode_partition_task_count + ); + for (idx, level) in self .group .l0 @@ -1777,7 +1782,7 @@ pub(crate) mod tests { #[tokio::test] async fn test_random_compact() { - let mut test = CompactTest::new(64 * 1024, 1000); + let mut test = CompactTest::new(64 * 1024, 2000); test.test_selector_compact_impl(RandomGenerator { max_pk: 1000000, rng: StdRng::seed_from_u64(0),