You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/11/12 13:46:43 UTC

[GitHub] [incubator-doris] weizuo93 opened a new pull request #4891: [Optimize] Execute 'pick rowsets' before applying for permits for a compaction task

weizuo93 opened a new pull request #4891:
URL: https://github.com/apache/incubator-doris/pull/4891


   ## 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)
   - [x] 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)
   - [x] 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._
   
   - [x] I have create an issue on (Fix #4882 ), and have described the bug/feature there in detail
   - [] Compiling and unit tests pass locally with my changes
   - [] I have added tests that prove my fix is effective or that my feature works
   - [x] If this change need a document change, I have updated the document
   - [x] Any dependent changes have been merged
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #4891: [Refactor] Execute 'pick rowsets' before applying for permits for a compaction task

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #4891:
URL: https://github.com/apache/incubator-doris/pull/4891#discussion_r529607540



##########
File path: be/src/olap/base_compaction.cpp
##########
@@ -43,9 +50,26 @@ OLAPStatus BaseCompaction::compact() {
     RETURN_NOT_OK(pick_rowsets_to_compact());
     TRACE("rowsets picked");
     TRACE_COUNTER_INCREMENT("input_rowsets_count", _input_rowsets.size());
+    _tablet->set_clone_occurred(false);
+
+    return OLAP_SUCCESS;
+}
+
+OLAPStatus BaseCompaction::execute_compact() {
+    MutexLock lock(_tablet->get_base_lock(), TRY_LOCK);
+    if (!lock.own_lock()) {
+        LOG(WARNING) << "another base compaction is running. tablet=" << _tablet->full_name();
+        return OLAP_ERR_BE_TRY_BE_LOCK_ERROR;
+    }
+    TRACE("got base compaction lock");
+
+    if (_tablet->get_clone_occurred()) {
+        _tablet->set_clone_occurred(false);

Review comment:
       Add comment to explain why setting clone occurred here.

##########
File path: be/src/olap/base_compaction.cpp
##########
@@ -28,6 +28,13 @@ BaseCompaction::BaseCompaction(TabletSharedPtr tablet, const std::string& label,
 BaseCompaction::~BaseCompaction() { }
 
 OLAPStatus BaseCompaction::compact() {
+    RETURN_NOT_OK(prepare_compact());

Review comment:
       Who will call `BaseCompaction::compact()` now?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] weizuo93 commented on a change in pull request #4891: [Refactor] Execute 'pick rowsets' before applying for permits for a compaction task

Posted by GitBox <gi...@apache.org>.
weizuo93 commented on a change in pull request #4891:
URL: https://github.com/apache/incubator-doris/pull/4891#discussion_r530063779



##########
File path: be/src/olap/base_compaction.cpp
##########
@@ -28,6 +28,13 @@ BaseCompaction::BaseCompaction(TabletSharedPtr tablet, const std::string& label,
 BaseCompaction::~BaseCompaction() { }
 
 OLAPStatus BaseCompaction::compact() {
+    RETURN_NOT_OK(prepare_compact());

Review comment:
       > Who will call `BaseCompaction::compact()` now?
   
   `BaseCompaction::compact()` will still be called in "be/src/http/action/compaction_action.cpp" for `/api/compaction/run`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] weizuo93 commented on a change in pull request #4891: [Refactor] Execute 'pick rowsets' before applying for permits for a compaction task

Posted by GitBox <gi...@apache.org>.
weizuo93 commented on a change in pull request #4891:
URL: https://github.com/apache/incubator-doris/pull/4891#discussion_r530068677



##########
File path: be/src/olap/base_compaction.cpp
##########
@@ -43,9 +50,26 @@ OLAPStatus BaseCompaction::compact() {
     RETURN_NOT_OK(pick_rowsets_to_compact());
     TRACE("rowsets picked");
     TRACE_COUNTER_INCREMENT("input_rowsets_count", _input_rowsets.size());
+    _tablet->set_clone_occurred(false);
+
+    return OLAP_SUCCESS;
+}
+
+OLAPStatus BaseCompaction::execute_compact() {
+    MutexLock lock(_tablet->get_base_lock(), TRY_LOCK);
+    if (!lock.own_lock()) {
+        LOG(WARNING) << "another base compaction is running. tablet=" << _tablet->full_name();
+        return OLAP_ERR_BE_TRY_BE_LOCK_ERROR;
+    }
+    TRACE("got base compaction lock");
+
+    if (_tablet->get_clone_occurred()) {
+        _tablet->set_clone_occurred(false);

Review comment:
       OK.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman merged pull request #4891: [Refactor] Execute 'pick rowsets' before applying for permits for a compaction task

Posted by GitBox <gi...@apache.org>.
morningman merged pull request #4891:
URL: https://github.com/apache/incubator-doris/pull/4891


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org