Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: no compaction of L0 and L1 is triggered when L0'size reaches level0_file_num_compaction_trigger in simple leveled #111

Open
zztaki opened this issue Dec 20, 2024 · 2 comments · May be fixed by #112

Comments

@zztaki
Copy link

zztaki commented Dec 20, 2024

Hello, I found a bug in simple_leveled.rs.

When the number of SSTs in L0 is larger than or equal to level0_file_num_compaction_trigger, we still recheck size_ratio_percent. This causes our L0 size to potentially exceed it.

for i in 0..self.options.max_levels {
if i == 0
&& snapshot.l0_sstables.len() < self.options.level0_file_num_compaction_trigger
{
continue;
}
let lower_level = i + 1;
let size_ratio = level_sizes[lower_level] as f64 / level_sizes[i] as f64;
if size_ratio < self.options.size_ratio_percent as f64 / 100.0 {
println!(
"compaction triggered at level {} and {} with size ratio {}",
i, lower_level, size_ratio
);
return Some(SimpleLeveledCompactionTask {
upper_level: if i == 0 { None } else { Some(i) },
upper_level_sst_ids: if i == 0 {
snapshot.l0_sstables.clone()
} else {
snapshot.levels[i - 1].1.clone()
},
lower_level,
lower_level_sst_ids: snapshot.levels[lower_level - 1].1.clone(),
is_lower_level_bottom_level: lower_level == self.options.max_levels,
});
}
}

image

I'm not sure if I misunderstood the tutorial. :)

@zztaki zztaki changed the title chore: DONOT trigger a compaction of L0 and L1 when L0'size reach level0_file_num_compaction_trigger in simple leveled chore: no compaction of L0 and L1 is triggered when L0'size reach level0_file_num_compaction_trigger in simple leveled Dec 20, 2024
@zztaki zztaki changed the title chore: no compaction of L0 and L1 is triggered when L0'size reach level0_file_num_compaction_trigger in simple leveled chore: no compaction of L0 and L1 is triggered when L0'size reaches level0_file_num_compaction_trigger in simple leveled Dec 20, 2024
@skyzh
Copy link
Owner

skyzh commented Dec 20, 2024

Ahh, I missed it. Do you want to submit patches to fix it? Or I can fix it.

@zztaki
Copy link
Author

zztaki commented Dec 21, 2024

Thank you for your reply. I would like to submit patches. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants