Skip to content

Conversation

@weizuo93
Copy link
Contributor

Proposed changes

The current compaction mechanism is that there is a producer thread that has been producing compaction tasks, and the selected tablet must apply for permits. When a tablet could hold permits, compaction task for this tablet will be submitted to thread pool. We take compaction score as permits which is used for limiting memory consumption. However, pick_rowset_to_compaction() will be executed before the file merge in compaction thread, and the number of segment files that actually perform the merge operation is smaller than compaction score. In addition, it is also possible that compaction task exits directly because the tablet doesn't meet the requirements of compaction.

This patch optimizes and refactors the code of compaction, so that we can execute 'pick rowsets' before applying for permits for a compaction task, calculate the number of segment files that actually participate in the merge operation, and take this number as permits.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • [] Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

@weizuo93 weizuo93 changed the title [Optimize] Execute 'pick rowsets' before applying for permits for a compaction task [Refactor] Execute 'pick rowsets' before applying for permits for a compaction task Nov 12, 2020
@weizuo93 weizuo93 force-pushed the refactor-compaction-pick-rowset branch from 95a7742 to 8937a3b Compare November 23, 2020 05:27
TRACE("got base compaction lock");

if (_tablet->get_clone_occurred()) {
_tablet->set_clone_occurred(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment to explain why setting clone occurred here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

BaseCompaction::~BaseCompaction() { }

OLAPStatus BaseCompaction::compact() {
RETURN_NOT_OK(prepare_compact());
Copy link
Contributor

Choose a reason for hiding this comment

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

Who will call BaseCompaction::compact() now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Who will call BaseCompaction::compact() now?

BaseCompaction::compact() will still be called in "be/src/http/action/compaction_action.cpp" for /api/compaction/run.

@morningman morningman added area/compact Issues or PRs related to the compact kind/improvement labels Nov 24, 2020
@weizuo93 weizuo93 force-pushed the refactor-compaction-pick-rowset branch 2 times, most recently from 91b09c5 to 4f942cd Compare November 26, 2020 13:25
@weizuo93 weizuo93 force-pushed the refactor-compaction-pick-rowset branch from 4f942cd to c251ed0 Compare November 28, 2020 11:53
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman added the approved Indicates a PR has been approved by one committer. label Nov 29, 2020
@morningman morningman merged commit ec7e1c6 into apache:master Nov 30, 2020
morningman pushed a commit to morningman/doris that referenced this pull request Dec 17, 2020
… to be cleared

Regardless of whether the tablet is submitted for compaction or not,
we need to call 'reset_compaction' to clean up the base_compaction or cumulative_compaction objects
in the tablet, because these two objects store the tablet's own shared_ptr.
If it is not cleaned up, the reference count of the tablet will always be greater than 1,
thus cannot be collected by the garbage collector. (TabletManager::start_trash_sweep)

This bug is introduced from apache#4891
morningman added a commit that referenced this pull request Dec 18, 2020
… to be cleared (#5100)

Regardless of whether the tablet is submitted for compaction or not,
we need to call 'reset_compaction' to clean up the base_compaction or cumulative_compaction objects
in the tablet, because these two objects store the tablet's own shared_ptr.
If it is not cleaned up, the reference count of the tablet will always be greater than 1,
thus cannot be collected by the garbage collector. (TabletManager::start_trash_sweep)

This bug is introduced from #4891
morningman added a commit to baidu-doris/incubator-doris that referenced this pull request Jan 5, 2021
… to be cleared (apache#5100)

Regardless of whether the tablet is submitted for compaction or not,
we need to call 'reset_compaction' to clean up the base_compaction or cumulative_compaction objects
in the tablet, because these two objects store the tablet's own shared_ptr.
If it is not cleaned up, the reference count of the tablet will always be greater than 1,
thus cannot be collected by the garbage collector. (TabletManager::start_trash_sweep)

This bug is introduced from apache#4891
@weizuo93 weizuo93 deleted the refactor-compaction-pick-rowset branch March 9, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/compact Issues or PRs related to the compact kind/improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Execute 'pick rowsets' before applying for permits for a compaction task

2 participants