Skip to content

Commit

Permalink
fix(compaction): adjust base level compaciton
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Aug 8, 2024
1 parent 38927e8 commit 8882d0f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ impl LevelCompactionPicker {
}

let overlap_strategy = create_overlap_strategy(self.config.compaction_mode());
let trivial_move_picker =
TrivialMovePicker::new(0, self.target_level, overlap_strategy.clone());
let trivial_move_picker = TrivialMovePicker::new(
0,
self.target_level,
overlap_strategy.clone(),
self.config.target_file_size_base / 4,
);

trivial_move_picker.pick_trivial_move_task(
&l0.sub_levels[0].table_infos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ impl IntraCompactionPicker {
continue;
}

let trivial_move_picker = TrivialMovePicker::new(0, 0, overlap_strategy.clone());
let trivial_move_picker =
TrivialMovePicker::new(0, 0, overlap_strategy.clone(), u64::MAX);

let select_sst = trivial_move_picker.pick_trivial_move_sst(
&l0.sub_levels[idx + 1].table_infos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl NonOverlapSubLevelPicker {

let ret = self.pick_sub_level(l0, level_handler, sst);
if ret.sstable_infos.len() < self.min_expected_level_count
&& ret.total_file_size < self.min_compaction_bytes
|| ret.total_file_size < self.min_compaction_bytes
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ pub struct TrivialMovePicker {
level: usize,
target_level: usize,
overlap_strategy: Arc<dyn OverlapStrategy>,
min_size: u64,
}

impl TrivialMovePicker {
pub fn new(
level: usize,
target_level: usize,
overlap_strategy: Arc<dyn OverlapStrategy>,
min_size: u64,
) -> Self {
Self {
level,
target_level,
overlap_strategy,
min_size,
}
}

Expand All @@ -50,6 +53,10 @@ impl TrivialMovePicker {
) -> Option<SstableInfo> {
let mut skip_by_pending = false;
for sst in select_tables {
if sst.file_size < self.min_size {
continue;
}

if level_handlers[self.level].is_pending_compact(&sst.sst_id) {
skip_by_pending = true;
continue;
Expand Down

0 comments on commit 8882d0f

Please sign in to comment.