Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Little-Wallace <[email protected]>
  • Loading branch information
Little-Wallace committed Sep 12, 2023
1 parent 3525d6b commit 2325058
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/meta/src/hummock/compaction/level_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,13 @@ impl DynamicLevelSelectorCore {
max_size * SCORE_BASE * (level.vnode_partition_count as u64)
/ ctx.level_max_bytes[level_idx],
);
// Reduce the level num of l0 non-overlapping sub_level
ctx.score_levels.push(PickerInfo {
score,
select_level: level_idx,
target_level: level_idx + 1,
picker_type: PickerType::BaseLevelCompaction(ctx.target_partitions.clone()),
});
} else {
// Reduce the level num of l0 non-overlapping sub_level
ctx.score_levels.push(PickerInfo {
score,
select_level: level_idx,
Expand Down
1 change: 1 addition & 0 deletions src/meta/src/hummock/compaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl CompactStatus {
&task.input_ssts[0].table_infos,
)
{
// If this level can not be partitioned, we must compact it at least once.
return false;
}
if task.input_ssts.len() == 1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,12 @@ impl PartitionIntraSubLevelPicker {
}
None
}
}

impl CompactionPicker for PartitionIntraSubLevelPicker {
fn pick_compaction(
&mut self,
fn pick_whole_level(
&self,
levels: &Levels,
level_handlers: &[LevelHandler],
stats: &mut LocalPickerStatistic,
) -> Option<CompactionInput> {
assert!(levels.can_partition_by_vnode());
let l0 = levels.l0.as_ref().unwrap();
let max_sub_level_id = self
.partitions
Expand All @@ -162,7 +158,7 @@ impl CompactionPicker for PartitionIntraSubLevelPicker {
}

if levels.vnode_partition_count == 0
&& level.total_file_size > self.config.sub_level_max_compaction_bytes / 2
&& level.total_file_size > self.config.sub_level_max_compaction_bytes
{
continue;
}
Expand Down Expand Up @@ -236,9 +232,17 @@ impl CompactionPicker for PartitionIntraSubLevelPicker {
vnode_partition_count,
});
}
None
}

fn pick_partition(
&mut self,
levels: &Levels,
level_handlers: &[LevelHandler],
stats: &mut LocalPickerStatistic,
) -> Option<CompactionInput> {
let mut skip_pending_compact = false;

let l0 = levels.l0.as_ref().unwrap();
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 / 2 {
Expand Down Expand Up @@ -309,6 +313,26 @@ impl CompactionPicker for PartitionIntraSubLevelPicker {
} else {
stats.skip_by_count_limit += 1;
}
None
}
}

impl CompactionPicker for PartitionIntraSubLevelPicker {
fn pick_compaction(
&mut self,
levels: &Levels,
level_handlers: &[LevelHandler],
stats: &mut LocalPickerStatistic,
) -> Option<CompactionInput> {
assert!(levels.can_partition_by_vnode());
if let Some(input) = self.pick_whole_level(levels, level_handlers) {
return Some(input);
}

if let Some(input) = self.pick_partition(levels, level_handlers, stats) {
return Some(input);
}

self.pick_l0_trivial_move_file(levels.l0.as_ref().unwrap(), level_handlers, stats)
}
}
Expand Down

0 comments on commit 2325058

Please sign in to comment.