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

feat(storage): adjust base compaction limitation #17979

Merged
merged 22 commits into from
Aug 22, 2024

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Aug 8, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

In some scenarios, I found that CN generates small ssts, some ssts will be trivial-moved to base level, and the small files may destroy the efficiency of base level compaction, I want to adjust the strategy to reject some trivial-move and base level compaction tasks for some small ssts, so as to achieve better batching and reduce the small sst.

Notes: however, that this PR is not intended to significantly increase compaction capacity, but rather is a safeguard to minimise the number of small files compacting to the base level.

This PR changed:

  1. Reject to base trivial move tasks that are less than the threshold when validator is turned on
  2. Decrease the priority of base level compaction tasks that are less than the threshold (unexpected)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@Li0k
Copy link
Contributor Author

Li0k commented Aug 9, 2024

@Li0k
Copy link
Contributor Author

Li0k commented Aug 9, 2024

P50 Base Level Compaction Task Size Distribution

main
image

branch
image

With the nexmark test (NEXMARK_QUERY="q0,q4,q5,q5-rewrite,q7,q7-rewrite,q8,q9,q12,q13,q3-no-condition"), We can observe that branch no longer selects compaction tasks below 128m.

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the motivation to change && to || here is that we choose to rely on L0 intra compaction to reduce the level count when ret.sstable_infos.len() >= self.min_expected_level_count so that we can ensure that to base compaction must contain at least self.min_expected_level_count and at least self.min_compaction_bytes. Let's document this in the codes.

@Li0k
Copy link
Contributor Author

Li0k commented Aug 9, 2024

Consider a scenario

  1. the sst at the bottom of each partition is too small to trigger trivial-move
  2. there are too many sub levels to trigger a write-stop, and each partition is insufficient for Intra
  3. all partitions do not satisfy the to base min_bytes and cannot to base

@Li0k Li0k marked this pull request as ready for review August 14, 2024 08:41
@Li0k Li0k requested a review from zwang28 August 19, 2024 07:46
Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

LGTM

@Li0k
Copy link
Contributor Author

Li0k commented Aug 22, 2024

@Li0k Li0k added this pull request to the merge queue Aug 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 22, 2024
@Li0k Li0k added this pull request to the merge queue Aug 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 22, 2024
@Li0k Li0k enabled auto-merge August 22, 2024 06:50
@Li0k Li0k added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit c37ca31 Aug 22, 2024
32 of 33 checks passed
@Li0k Li0k deleted the li0k/storage_adjust_base_compaction branch August 22, 2024 07:18
@Li0k
Copy link
Contributor Author

Li0k commented Sep 3, 2024

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

Successfully merging this pull request may close these issues.

3 participants