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): support dynamic leveled-compaction #2242

Merged
merged 31 commits into from
May 9, 2022

Conversation

Little-Wallace
Copy link
Contributor

@Little-Wallace Little-Wallace commented Apr 29, 2022

What's changed and what's your intention?

close #2174

Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests

Refer to a related PR or issue link (optional)

close #2234

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 766 files.

Valid Invalid Ignored Fixed
762 2 2 0
Click to see the invalid file list
  • src/meta/src/hummock/compaction/compaction_picker.rs
  • src/meta/src/hummock/compaction/level_selector.rs

src/meta/src/hummock/compaction/level_selector.rs Outdated Show resolved Hide resolved
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]>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 764 files.

Valid Invalid Ignored Fixed
761 1 2 0
Click to see the invalid file list
  • src/meta/src/hummock/compaction/compaction_manager.rs

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

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 764 files.

Valid Invalid Ignored Fixed
761 1 2 0
Click to see the invalid file list
  • src/meta/src/hummock/compaction/compaction_manager.rs

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

codecov bot commented May 3, 2022

Codecov Report

Merging #2242 (89fa6e9) into main (8116931) will increase coverage by 0.22%.
The diff coverage is 93.45%.

@@            Coverage Diff             @@
##             main    #2242      +/-   ##
==========================================
+ Coverage   70.99%   71.21%   +0.22%     
==========================================
  Files         678      680       +2     
  Lines       85194    86010     +816     
==========================================
+ Hits        60486    61256     +770     
- Misses      24708    24754      +46     
Flag Coverage Δ
rust 71.21% <93.45%> (+0.22%) ⬆️

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

Impacted Files Coverage Δ
src/meta/src/hummock/level_handler.rs 70.73% <ø> (-1.37%) ⬇️
src/meta/src/hummock/mod.rs 20.18% <0.00%> (ø)
src/storage/src/hummock/cache.rs 96.14% <ø> (ø)
src/storage/src/hummock/compactor.rs 64.02% <15.00%> (-2.22%) ⬇️
src/meta/src/hummock/hummock_manager.rs 87.68% <62.50%> (-0.94%) ⬇️
src/meta/src/hummock/compaction/mod.rs 83.09% <87.09%> (-0.65%) ⬇️
...rc/meta/src/hummock/compaction/overlap_strategy.rs 92.00% <94.36%> (-8.00%) ⬇️
...c/meta/src/hummock/compaction/compaction_picker.rs 96.89% <96.89%> (ø)
src/meta/src/hummock/compaction/level_selector.rs 97.38% <97.38%> (ø)
...a/src/hummock/compaction/tier_compaction_picker.rs 97.53% <97.73%> (+0.31%) ⬆️
... and 6 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@zwang28 zwang28 mentioned this pull request May 4, 2022
2 tasks
Signed-off-by: Little-Wallace <[email protected]>
src/meta/src/hummock/compaction/level_selector.rs Outdated Show resolved Hide resolved
src/meta/src/hummock/compaction/level_selector.rs Outdated Show resolved Hide resolved
src/meta/src/hummock/compaction/level_selector.rs Outdated Show resolved Hide resolved
Comment on lines 192 to 201
// manager can trigger compaction jobs of other level but we add a base score
// `idle_file_count + 100` so that the manager can trigger L0
// compaction when the other levels are all balanced.
let score = idle_file_count * 100 / self.config.level0_trigger_number as u64
+ idle_file_count
+ 100;
let score = std::cmp::max(
total_size * 100 / self.config.max_bytes_for_level_base,
score,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get why we add idle_file_count + 100 to the score. Will this make the L0 score too large even if other levels are not balanced? If we want to prioritize L0 compaction when other levels are all balanced, can we just add a tie breaker in the score cmp function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm... I saw in pick_compaction we only trigger a compaction when score > 100. Are we trying to ensure that the compactor is never idle and can at least trigger intra-L0 compaction when idle_file_count > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's the original strategy in our project. Of course, it may not be best.

src/meta/src/hummock/compaction/level_selector.rs Outdated Show resolved Hide resolved
{
break;
}
tables.push(table.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid the clone and return &SstableInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The complex of cloning table would be far smaller than calculating score. Because the overlap size would not be large.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another problem is that if we pass the whole sstableinfo object in CompactTask, it would make CompactTask too large due the buckets of consistence hash. A better idea is only storing table id in input_ssts of CompactTask.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The complex of cloning table would be far smaller than calculating score. Because the overlap size would not be large.

I am not suggesting not returning a vec. I mean we can return Vec<&'a SstableInfo> instead of Vec<SstableInfo>

Another problem is that if we pass the whole sstableinfo object in CompactTask, it would make CompactTask too large due the buckets of consistence hash. A better idea is only storing table id in input_ssts of CompactTask.

Will compactor need the vnode bitmap for compaction? IMO, not passing the bitmap to the compactor will not affect correctness but may affect the compaction speed because compactor only needs to include SSTs with overlapping vnodes in one split. We can split input ssts according to the vnode info to address this issue in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return Vec<&'a SstableInfo> seems difficult because it's a return value from a dynamic object....
compactor will need vnode bitmap because it needs to know how to partition data. But compactor can get vnode bitmap from it's owned HummockVersion, so it's not necessary to send it in CompactTask.

Signed-off-by: Little-Wallace <[email protected]>
@Little-Wallace Little-Wallace changed the title [WIP] feat(compaction): support dynamic leveled-compaction feat(compaction): support dynamic leveled-compaction May 5, 2022
@zwang28 zwang28 self-requested a review May 9, 2022 02:27
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.

LGTM

@Little-Wallace
Copy link
Contributor Author

@hzxa21 Any suggestion?

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

Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
@zwang28 zwang28 self-requested a review May 9, 2022 09:34
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.

remove debug log

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.

Thanks

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.

frontend: empty result returned if compactor panics Tracking: leveled-compaction
3 participants