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(compaction): Limit the size of the new overlapping level #19277

Merged
merged 12 commits into from
Nov 22, 2024

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Nov 6, 2024

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

What's changed and what's your intention?

This PR introduces an optimization that allows hummock to slice the overlapping sub level by config size when committing epochs to improve the parallelism of the tier compaciton.

  1. new config max_overlapping_level_size
  2. slice the overlapping sub level by config size
  3. ut

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.


group_deltas.push(group_delta);
for sst in inserted_table_infos {
Copy link
Contributor

@zwang28 zwang28 Nov 12, 2024

Choose a reason for hiding this comment

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

Could you explain (and add comments) how the SSTables maintain a specific chronological order in inserted_table_infos? I believe this is a crucial prerequisite for dividing them into multiple sub-levels.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also wonder whether the current implementation is correct because I remember that newer sst comes first in inserted_table_infos .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fix the bug and cover with UT

new_compaction_groups.insert(new_compaction_group_id, compaction_group_config.clone());
compaction_groups.insert(
new_compaction_group_id,
(true, compaction_group_config.clone()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better add a documentation about what the bool means.

.get(cg_id)
.unwrap_or_else(|| panic!("compaction group {} should be created", cg_id))
.compaction_config();
compaction_groups.insert(*cg_id, (false, compaction_group));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this overwrite what we do in L146? For example, will we mistakenly treat a new cg as a old cg by overwriting the bool to false?

Copy link
Contributor 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 overwrite occurs, it is determined by compaction_groups.contains_key before insert.


group_deltas.push(group_delta);
for sst in inserted_table_infos {
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

@Li0k Li0k marked this pull request as ready for review November 19, 2024 09:49
@Li0k
Copy link
Contributor Author

Li0k commented Nov 20, 2024

PTAL @hzxa21 @zwang28

With the above Test, we can see that pr is optimised for large ckpt size commits. However, I also found a few problems with this test.

  1. after the tier compact is finished, a lot of trivial-move tasks will exhaust the cpu of the meta, and the efficiency of single-file trivial-move is extremely low. 2. when l0 is stacked up, we didn't make a timely decision.

  2. when l0 is piled up, we didn't change the compaction parameter in time, such as output sst size, max_compaction_size, which will reduce the efficiency of compaciton (refer to 1). Is it possible to introduce some deterministic rules to optimize the compaction task?

  3. I don't think it's correct to use 128M as the limit for overlapping level, since CN submitted max_sst_size = 256M, maybe we should adjust max_overlapping_level_size upwards.

Do we need to create a separate issue for optimization 1 / 2 ?

@hzxa21
Copy link
Collaborator

hzxa21 commented Nov 20, 2024

Do we need to create a separate issue for optimization 1 / 2 ?

+1. You can also give ideas on how to optimize 1 & 2 in the issue.

I don't think it's correct to use 128M as the limit for overlapping level, since CN submitted max_sst_size = 256M, maybe we should adjust max_overlapping_level_size upwards.

That is true. I think we should adjust max_overlapping_level_size because its effective lower bound seems to be max_sst_size = 256M


/// Rewrite the commit sstables to sub-levels based on the compaction group config.
/// The type of `compaction_group_manager_txn` is too complex to be used in the function signature. So we use `HashMap` instead.
fn rewrite_commit_sstables_to_sub_level(
Copy link
Contributor

Choose a reason for hiding this comment

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

correct_commit_ssts which generatescommit_sstables, should ensure the relateive SST order is correct.
Rest LGTM.

@Li0k
Copy link
Contributor Author

Li0k commented Nov 20, 2024

Do we need to create a separate issue for optimization 1 / 2 ?

+1. You can also give ideas on how to optimize 1 & 2 in the issue.

I don't think it's correct to use 128M as the limit for overlapping level, since CN submitted max_sst_size = 256M, maybe we should adjust max_overlapping_level_size upwards.

That is true. I think we should adjust max_overlapping_level_size because its effective lower bound seems to be max_sst_size = 256M

256M sounds good to me, I think it also roughly limits the size of l0, e.g. 256M * 300 (level-0-write-limit)

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.

Rest LGTM

}
}

if accumulated_size != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is better to check !ssts.is_empty() instead. Not sure whether there are corner cases that sst_size can be zero.

@Li0k Li0k enabled auto-merge November 22, 2024 10:03
@Li0k Li0k added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit bc06ffd Nov 22, 2024
33 of 34 checks passed
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