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

fix(meta): do not split by vnode for low write throughput #12534

Merged
merged 27 commits into from
Jan 10, 2024

Conversation

Little-Wallace
Copy link
Contributor

@Little-Wallace Little-Wallace commented Sep 26, 2023

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

What's changed and what's your intention?

If a group does not write much data after split, we may generate too many small files in level-0. This PR will fix this case by control whether to cut sstable by vnode partition

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • 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.

Signed-off-by: Little-Wallace <[email protected]>
@github-actions github-actions bot added the type/fix Bug fix label Sep 26, 2023
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Attention: 91 lines in your changes are missing coverage. Please review.

Comparison is base (5c588ef) 67.99% compared to head (b3433d5) 67.95%.
Report is 33 commits behind head on main.

Files Patch % Lines
...mmock/compaction/picker/intra_compaction_picker.rs 33.66% 67 Missing ⚠️
src/meta/src/hummock/manager/mod.rs 82.75% 10 Missing ⚠️
.../compaction/picker/base_level_compaction_picker.rs 69.23% 8 Missing ⚠️
...ck_sdk/src/compaction_group/hummock_version_ext.rs 86.20% 4 Missing ⚠️
src/meta/src/hummock/compaction/picker/mod.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12534      +/-   ##
==========================================
- Coverage   67.99%   67.95%   -0.05%     
==========================================
  Files        1535     1535              
  Lines      264830   264992     +162     
==========================================
  Hits       180080   180080              
- Misses      84750    84912     +162     
Flag Coverage Δ
rust 67.95% <72.67%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Little-Wallace
Copy link
Contributor Author

image image

@Little-Wallace
Copy link
Contributor Author

image image

Although this PR reduce many small file but I find that it may cause more large task and the write-amplification also increase a little.

Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
@Little-Wallace
Copy link
Contributor Author

image The problem which choose too many files in compact task 0-->base has been fixed.

To solve this problem, I refactor the score calculate to prevent no split level compact to base level.

@Li0k Li0k self-requested a review October 30, 2023 08:17
@@ -747,6 +773,10 @@ impl HummockLevelsExt for Levels {
}
delete_sst_ids_set.is_empty()
}

fn can_partition_by_vnode(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing to do with the current PR, in another PR I'm going to turn on partitioning in the default cg and the self.member_table_ids.len() == 1 will fail, any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@Li0k
Copy link
Contributor

Li0k commented Oct 30, 2023

@zwang28 @hzxa21 PTAL

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@zwang28 zwang28 left a comment

Choose a reason for hiding this comment

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

I haven't finished the review yet.

src/meta/src/hummock/compaction/mod.rs Outdated Show resolved Hide resolved
@@ -116,6 +118,7 @@ message HummockVersion {
uint64 group_id = 3;
uint64 parent_group_id = 4;
repeated uint32 member_table_ids = 5;
uint32 vnode_partition_count = 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you explain when this field is initialized / set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set in function build_initial_compaction_group_levels.

Copy link
Contributor

Choose a reason for hiding this comment

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

So for existing compaction groups, vnode_partition_count is 0 and cannot be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 Good catch.
I will refactor this code to avoid compatibility issues

Copy link
Contributor

@zwang28 zwang28 left a comment

Choose a reason for hiding this comment

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

Rest LGTM.
Will partition_vnode_count be mutable someday?


// Reduce the level num of l0 non-overlapping sub_level
ctx.score_levels.push({
PickerInfo {
if non_overlapping_size_score > SCORE_BASE {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the idea behind non_overlapping_size_score > SCORE_BASE and non_overlapping_level_score > SCORE_BASE? Why ToBase is stricter about size_score, while Intra is stricter about level_score?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because if there are not enough split-vnode file in level0, the selector will pick a large task to base level and it will case more write-amplification and also slowdown compaction

@Li0k
Copy link
Contributor

Li0k commented Dec 12, 2023

PTAL @hzxa21

@Li0k
Copy link
Contributor

Li0k commented Dec 12, 2023

@hzxa21
Copy link
Collaborator

hzxa21 commented Dec 12, 2023

There are several changes in main recently. I think we can rebase main and re-run the experiments to verify the results of this PR.

Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
@Little-Wallace
Copy link
Contributor Author

There are several changes in main recently. I think we can rebase main and re-run the experiments to verify the results of this PR.

I run a benchmark test for nexmark q5,q7,q9,q10,q15,q16,q19,q20. It does not matter for performance

@Little-Wallace Little-Wallace added this pull request to the merge queue Jan 10, 2024
Merged via the queue into main with commit 6c5b56d Jan 10, 2024
29 of 30 checks passed
@Little-Wallace Little-Wallace deleted the wallace/partition-vnode branch January 10, 2024 09:05
Li0k pushed a commit that referenced this pull request Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants