Skip to content

Conversation

123789456ye
Copy link
Collaborator

What changes are included in this PR?

  • Add tiered compactor, along with tests
  • Add metrics tests about approx. amplification and throughput.

Are these changes tested?

Pass all existed tests.

Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 73.25162% with 371 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/compaction/mod.rs 0.00% 270 Missing ⚠️
src/compaction/tiered.rs 93.99% 64 Missing ⚠️
src/compaction/leveled.rs 0.00% 27 Missing ⚠️
src/lib.rs 55.55% 8 Missing ⚠️
src/option.rs 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@123789456ye 123789456ye requested review from crwen and ethe and removed request for crwen August 14, 2025 10:52
};

#[tokio::test(flavor = "multi_thread")]
#[ignore]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the reasons for ignoring these tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are not testing functionality but more like bench, to compare between compactors.

Copy link
Collaborator

@jonathanc-n jonathanc-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overall looks good to me, just a few comments. Thanks @123789456ye

if !tier_files.is_empty() {
return Some(TieredTask {
input: vec![(tier, tier_files)],
target_tier: tier + 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check before incrementing here, and maybe if we are at the last tier we could try self compaction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think tiered need self compaction, since if compaction triggered, it's better to compact with next tier than remain. But you may try it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but if the last tier is full, it can be self compacted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input tier here only comes from should_major_compact, and the tier will not exceed MAX_LEVEL-2. However, maybe need to move MAX_LEVEL out of Version.

Copy link
Collaborator Author

@123789456ye 123789456ye Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but if the last tier is full, it can be self compacted.

I don't think this is necessary, since self compaction in L0 deals with the overlapping SSTs, but in the last tier there should be no overlapping. Though you may impl it and bench to see.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so. For tiered compaction you compact the level and push it to the next tier. if the level is flushed to the next tier multiple times, that level may contain overlap, which is when you would use self compaction for the last tier.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that is how you implemented it? I didn't look deep enough to verify that.

Copy link
Collaborator Author

@123789456ye 123789456ye Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. I haven't implement that in this tiered compactor and now the last tier will be overlap.
But I think it's better to use lazyleveled compactor(which is leveled in the bottom level and tiered above) in this case.

Copy link
Collaborator

@jonathanc-n jonathanc-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense then, lgtm so far. I'll take a deeper look again after merge when I'll plan some of the remote compaction logic

@jonathanc-n
Copy link
Collaborator

Is this good to go?

@ethe
Copy link
Member

ethe commented Aug 19, 2025

I'll take a look today.

@jonathanc-n
Copy link
Collaborator

I think we can merge after @ethe takes a quick look

@123789456ye 123789456ye requested a review from crwen August 22, 2025 07:13
@ethe ethe merged commit cd49ecb into tonbo-io:main Aug 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants