Skip to content

Commit

Permalink
fix: universal compaction condition
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <[email protected]>
  • Loading branch information
skyzh committed Oct 1, 2024
1 parent b84dd38 commit dc15ba0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mini-lsm/src/compact/tiered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl TieredCompactionController {
for id in 0..(snapshot.levels.len() - 1) {
size += snapshot.levels[id].1.len();
let next_level_size = snapshot.levels[id + 1].1.len();
let current_size_ratio = size as f64 / next_level_size as f64;
if current_size_ratio >= size_ratio_trigger && id + 2 >= self.options.min_merge_width {
let current_size_ratio = next_level_size as f64 / size as f64;
if current_size_ratio > size_ratio_trigger && id + 1 >= self.options.min_merge_width {
println!(
"compaction triggered by size ratio: {}",
current_size_ratio * 100.0
Expand All @@ -71,10 +71,10 @@ impl TieredCompactionController {
tiers: snapshot
.levels
.iter()
.take(id + 2)
.take(id + 1)
.cloned()
.collect::<Vec<_>>(),
bottom_tier_included: id + 2 >= snapshot.levels.len(),
bottom_tier_included: id + 1 >= snapshot.levels.len(),
});
}
}
Expand Down

0 comments on commit dc15ba0

Please sign in to comment.