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 2022/11/25 08:41:50 UTC
[GitHub] [doris] freemandealer opened a new pull request, #14595: [WIP][enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
freemandealer opened a new pull request, #14595:
URL: https://github.com/apache/doris/pull/14595
# Proposed changes
Issue Number: close #14590
## Problem summary
Describe your changes.
## Checklist(Required)
1. Does it affect the original behavior:
- [ ] Yes
- [ ] No
- [ ] I don't know
2. Has unit tests been added:
- [ ] Yes
- [ ] No
- [ ] No Need
3. Has document been added or modified:
- [ ] Yes
- [ ] No
- [ ] No Need
4. Does it need to update dependencies:
- [ ] Yes
- [ ] No
5. Are there any changes that cannot be rolled back:
- [ ] Yes (If Yes, please explain WHY)
- [ ] No
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14595:
URL: https://github.com/apache/doris/pull/14595#issuecomment-1601843291
We're closing this PR because it hasn't been updated in a while.
This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and feel free a maintainer to remove the Stale tag!
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] yixiutt commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
yixiutt commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1033247509
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -412,7 +423,7 @@ Status BetaRowsetWriter::_load_noncompacted_segments(
* length is beyond (config::segcompaction_threshold_segment_num / 2)
*/
Status BetaRowsetWriter::_find_longest_consecutive_small_segment(
- SegCompactionCandidatesSharedPtr segments) {
+ SegCompactionCandidatesSharedPtr segments, size_t small_threshold, bool is_greedy) {
Review Comment:
I think it's better than _find_longest_consecutive_small_segment just do find rowset work and return 2 sets, such as rename_segments_set and compact_segment_set, instead of doing rename inside this funtion
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] freemandealer commented on a diff in pull request #14595: [WIP][enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
freemandealer commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1032868944
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +576,62 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_segcompaction ||
+ !config::enable_storage_vectorization) { //TODO: final pass indep
+ return Status::OK();
+ }
+ if (_segcompaction_status.load() != OLAP_SUCCESS) {
+ return Status::OLAPInternalError(OLAP_ERR_SEGCOMPACTION_FAILED);
+ }
+
+ int64_t num_seg = _is_segcompacted() ? _num_segcompacted : _num_segment;
+ if (num_seg <= config::max_segment_num_per_rowset) {
+ LOG(INFO) << "num_seg less than max_segment_num_per_rowset, skip final pass: " << num_seg
+ << " vs " << config::max_segment_num_per_rowset;
+ return Status::OK();
+ }
+
+ // reset num counters for the final segcompaction
+ _num_segment = _num_segcompacted.load();
+ _num_segcompacted = 0;
+ _segcompacted_point = 0;
+
+ _total_row_num_written = 0;
+ {
+ std::lock_guard<std::mutex> lock(_segid_statistics_map_mutex);
+ for (const auto& itr : _segid_statistics_map) {
+ _total_row_num_written += itr.second.row_num;
+ }
+ }
+
+ while (_segcompacted_point != _num_segment) {
+ _is_doing_segcompaction = true;
+ SegCompactionCandidatesSharedPtr segments = std::make_shared<SegCompactionCandidates>();
+ status = _get_segcompaction_candidates(segments, FINAL_SEGCOMPACTION_TYPE);
+ if (LIKELY(status.ok()) && (segments->size() > 0)) {
+ LOG(INFO) << "submit segcompaction final task, tablet_id:" << _context.tablet_id
+ << " rowset_id:" << _context.rowset_id << " segment num:" << _num_segment
+ << " segcompacted_point:" << _segcompacted_point;
+ status = StorageEngine::instance()->submit_seg_compaction_task(this, segments);
+ if (!status.ok()) {
+ _is_doing_segcompaction = false;
+ return status;
+ }
+ status = _wait_flying_segcompaction();
+ if (!status.ok()) {
+ LOG(WARNING) << "segcompaction failed when build new rowset final wait, res="
+ << status;
+ return status;
+ }
+ }
Review Comment:
is_doing_segcompaction = false;
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +576,62 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_segcompaction ||
+ !config::enable_storage_vectorization) { //TODO: final pass indep
+ return Status::OK();
+ }
+ if (_segcompaction_status.load() != OLAP_SUCCESS) {
+ return Status::OLAPInternalError(OLAP_ERR_SEGCOMPACTION_FAILED);
+ }
+
+ int64_t num_seg = _is_segcompacted() ? _num_segcompacted : _num_segment;
+ if (num_seg <= config::max_segment_num_per_rowset) {
+ LOG(INFO) << "num_seg less than max_segment_num_per_rowset, skip final pass: " << num_seg
+ << " vs " << config::max_segment_num_per_rowset;
+ return Status::OK();
+ }
+
+ // reset num counters for the final segcompaction
+ _num_segment = _num_segcompacted.load();
+ _num_segcompacted = 0;
+ _segcompacted_point = 0;
+
+ _total_row_num_written = 0;
+ {
+ std::lock_guard<std::mutex> lock(_segid_statistics_map_mutex);
+ for (const auto& itr : _segid_statistics_map) {
+ _total_row_num_written += itr.second.row_num;
+ }
+ }
+
+ while (_segcompacted_point != _num_segment) {
+ _is_doing_segcompaction = true;
+ SegCompactionCandidatesSharedPtr segments = std::make_shared<SegCompactionCandidates>();
+ status = _get_segcompaction_candidates(segments, FINAL_SEGCOMPACTION_TYPE);
+ if (LIKELY(status.ok()) && (segments->size() > 0)) {
+ LOG(INFO) << "submit segcompaction final task, tablet_id:" << _context.tablet_id
+ << " rowset_id:" << _context.rowset_id << " segment num:" << _num_segment
+ << " segcompacted_point:" << _segcompacted_point;
+ status = StorageEngine::instance()->submit_seg_compaction_task(this, segments);
+ if (!status.ok()) {
+ _is_doing_segcompaction = false;
+ return status;
Review Comment:
continue&retry instead of break&fail
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +576,62 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_segcompaction ||
+ !config::enable_storage_vectorization) { //TODO: final pass indep
+ return Status::OK();
+ }
+ if (_segcompaction_status.load() != OLAP_SUCCESS) {
+ return Status::OLAPInternalError(OLAP_ERR_SEGCOMPACTION_FAILED);
+ }
+
+ int64_t num_seg = _is_segcompacted() ? _num_segcompacted : _num_segment;
+ if (num_seg <= config::max_segment_num_per_rowset) {
+ LOG(INFO) << "num_seg less than max_segment_num_per_rowset, skip final pass: " << num_seg
+ << " vs " << config::max_segment_num_per_rowset;
+ return Status::OK();
+ }
+
+ // reset num counters for the final segcompaction
+ _num_segment = _num_segcompacted.load();
+ _num_segcompacted = 0;
+ _segcompacted_point = 0;
+
+ _total_row_num_written = 0;
+ {
+ std::lock_guard<std::mutex> lock(_segid_statistics_map_mutex);
+ for (const auto& itr : _segid_statistics_map) {
+ _total_row_num_written += itr.second.row_num;
+ }
+ }
+
+ while (_segcompacted_point != _num_segment) {
+ _is_doing_segcompaction = true;
+ SegCompactionCandidatesSharedPtr segments = std::make_shared<SegCompactionCandidates>();
+ status = _get_segcompaction_candidates(segments, FINAL_SEGCOMPACTION_TYPE);
+ if (LIKELY(status.ok()) && (segments->size() > 0)) {
+ LOG(INFO) << "submit segcompaction final task, tablet_id:" << _context.tablet_id
+ << " rowset_id:" << _context.rowset_id << " segment num:" << _num_segment
+ << " segcompacted_point:" << _segcompacted_point;
+ status = StorageEngine::instance()->submit_seg_compaction_task(this, segments);
+ if (!status.ok()) {
+ _is_doing_segcompaction = false;
+ return status;
+ }
+ status = _wait_flying_segcompaction();
Review Comment:
return if not ok, dup warning log
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +576,62 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_segcompaction ||
Review Comment:
indep
##########
be/src/olap/rowset/beta_rowset_writer.h:
##########
@@ -165,13 +174,19 @@ class BetaRowsetWriter : public RowsetWriter {
// ensure only one inflight segcompaction task for each rowset
std::atomic<bool> _is_doing_segcompaction;
+
// enforce compare-and-swap on _is_doing_segcompaction
+#if 0
Review Comment:
rm useless code
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] zhannngchen commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
zhannngchen commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1049280771
##########
be/src/common/config.h:
##########
@@ -838,6 +838,9 @@ CONF_Int32(segcompaction_threshold_segment_num, "10");
// The segment whose row number above the threshold will be compacted during segcompaction
CONF_Int32(segcompaction_small_threshold, "1048576");
+// Enable final-pass segcompaction before commit txn
+CONF_Bool(enable_final_pass_segcompaction, "false");
Review Comment:
We can make it as the default behavior os segment compaction?
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +575,58 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_storage_vectorization) {
+ return Status::OK();
+ }
+ if (_segcompaction_status.load() != OLAP_SUCCESS) {
+ return Status::OLAPInternalError(OLAP_ERR_SEGCOMPACTION_FAILED);
+ }
+
+ int64_t num_seg = _is_segcompacted() ? _num_segcompacted : _num_segment;
+ if (num_seg <= FINAL_SEGCOMPACTION_NUM_THRESHOLD) {
+ LOG(INFO) << "num_seg less than max_segment_num_per_rowset, skip final pass: " << num_seg
+ << " vs " << config::max_segment_num_per_rowset;
+ return Status::OK();
+ }
+
+ // reset num counters for the final segcompaction
+ _num_segment = _num_segcompacted.load();
+ _num_segcompacted = 0;
+ _segcompacted_point = 0;
+
+ _total_row_num_written = 0;
+ {
+ std::lock_guard<std::mutex> lock(_segid_statistics_map_mutex);
+ for (const auto& itr : _segid_statistics_map) {
+ _total_row_num_written += itr.second.row_num;
+ }
+ }
+
+ while (_segcompacted_point != _num_segment) {
+ _is_doing_segcompaction = true;
Review Comment:
no lock protection here?
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -552,6 +575,58 @@ Status BetaRowsetWriter::_segcompaction_ramaining_if_necessary() {
return status;
}
+Status BetaRowsetWriter::_segcompaction_finalpass_wait() {
+ Status status = Status::OK();
+ DCHECK_EQ(_is_doing_segcompaction, false);
+ if (!config::enable_storage_vectorization) {
+ return Status::OK();
+ }
+ if (_segcompaction_status.load() != OLAP_SUCCESS) {
+ return Status::OLAPInternalError(OLAP_ERR_SEGCOMPACTION_FAILED);
+ }
+
+ int64_t num_seg = _is_segcompacted() ? _num_segcompacted : _num_segment;
+ if (num_seg <= FINAL_SEGCOMPACTION_NUM_THRESHOLD) {
+ LOG(INFO) << "num_seg less than max_segment_num_per_rowset, skip final pass: " << num_seg
Review Comment:
How about the case that the data size is quite big, and `total_size/MAX_SEGMENT_SIZE > FINAL_SEGCOMPACTION_NUM_THRESHOLD`?
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -400,19 +407,22 @@ Status BetaRowsetWriter::_load_noncompacted_segments(
return Status::OLAPInternalError(OLAP_ERR_ROWSET_LOAD_FAILED);
}
segments->push_back(std::move(segment));
+ if (++segment_num >= FINAL_SEGCOMPACTION_MAX_SEGMENTS) {
+ break;
+ }
}
return Status::OK();
}
/* policy of segcompaction target selection:
- * 1. skip big segments
+ * 1. skip (and rename to keep segment id sequential when necessary) big segments
* 2. if the consecutive smalls end up with a big, compact the smalls, except
* single small
* 3. if the consecutive smalls end up with small, compact the smalls if the
* length is beyond (config::segcompaction_threshold_segment_num / 2)
*/
Status BetaRowsetWriter::_find_longest_consecutive_small_segment(
- SegCompactionCandidatesSharedPtr segments) {
+ SegCompactionCandidatesSharedPtr segments, size_t small_threshold, bool is_greedy) {
Review Comment:
Add a comment to explain new parameter `is _greedy`
##########
be/src/olap/rowset/beta_rowset_writer.h:
##########
@@ -127,6 +144,12 @@ class BetaRowsetWriter : public RowsetWriter {
bool _is_segment_overlapping(const std::vector<KeyBoundsPB>& segments_encoded_key_bounds);
protected:
+ // segment num below will not trigger final segcompaction
+ const uint32_t FINAL_SEGCOMPACTION_NUM_THRESHOLD = 50;
Review Comment:
I think we can merge this 2 const variables to 1
##########
be/src/olap/rowset/beta_rowset_writer.h:
##########
@@ -32,6 +32,18 @@ class FileWriter;
using SegCompactionCandidates = std::vector<segment_v2::SegmentSharedPtr>;
using SegCompactionCandidatesSharedPtr = std::shared_ptr<SegCompactionCandidates>;
+/* A load process can be divided into: 1) Loading 2) Publishing (Committing txn)
Review Comment:
Publishing is not equal to committing, they are different phase
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] hello-stephen commented on pull request #14595: [WIP][enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #14595:
URL: https://github.com/apache/doris/pull/14595#issuecomment-1327400797
TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 35.25 seconds
load time: 441 seconds
storage size: 17171345758 Bytes
https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221125121251_clickbench_pr_53053.html
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] yixiutt commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
yixiutt commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1033230552
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -743,9 +819,25 @@ RowsetSharedPtr BetaRowsetWriter::build() {
return nullptr;
}
+ if (config::enable_final_pass_segcompaction) {
+ uint64_t begin = GetCurrentTimeMicros();
Review Comment:
use OlapStopWatch instead of GetCurrentTimeMicros
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1052984292
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,12 @@ BetaRowsetWriter::BetaRowsetWriter()
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
+ _is_doing_segcompaction(false),
+ _final_segcompaction_num_threshold(50),
+ _total_row_num_written(0) {
_segcompaction_status.store(OK);
+ bthread_mutex_init(&_is_doing_segcompaction_lock, nullptr);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_mutex_init(&_is_doing_segcompaction_lock, nullptr);
```
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,12 @@
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
+ _is_doing_segcompaction(false),
+ _final_segcompaction_num_threshold(50),
+ _total_row_num_written(0) {
_segcompaction_status.store(OK);
+ bthread_mutex_init(&_is_doing_segcompaction_lock, nullptr);
+ bthread_cond_init(&_segcompacting_cond, nullptr);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_cond_init(&_segcompacting_cond, nullptr);
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] closed pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
URL: https://github.com/apache/doris/pull/14595
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14595:
URL: https://github.com/apache/doris/pull/14595#issuecomment-1363955125
clang-tidy review says "All clean, LGTM! :+1:"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1052058712
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,11 @@ BetaRowsetWriter::BetaRowsetWriter()
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
- _segcompaction_status.store(OK);
+ _is_doing_segcompaction(false),
+ _total_row_num_written(0) {
+ _segcompaction_status.store(OLAP_SUCCESS);
+ bthread_mutex_init(&_is_doing_segcompaction_lock, NULL);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_cond_init(&_segcompacting_cond, nullptr);
```
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,11 @@ BetaRowsetWriter::BetaRowsetWriter()
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
- _segcompaction_status.store(OK);
+ _is_doing_segcompaction(false),
+ _total_row_num_written(0) {
+ _segcompaction_status.store(OLAP_SUCCESS);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_mutex_init(&_is_doing_segcompaction_lock, nullptr);
```
##########
be/test/olap/segcompaction_test.cpp:
##########
@@ -576,6 +580,151 @@ TEST_F(SegCompactionTest, SegCompactionInterleaveWithBig_OoOoO) {
}
}
+TEST_F(SegCompactionTest, SegCompactionMultiPass) {
+ /* ooooOOoQooooooooO (Q is bigger than O) will be oOOoQooO after 1st-pass segcompaction
+ * finally we get OQO after final-pass segcompaction
+ * */
+ config::enable_segcompaction_during_load = true;
+ config::enable_storage_vectorization = true;
+ config::enable_segcompaction_after_load = true;
+ config::max_segment_num_per_rowset = 5;
+
+ Status s;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ create_tablet_schema(tablet_schema);
+
+ RowsetSharedPtr rowset;
+ config::segcompaction_small_threshold = 6000; // set threshold above
+ // rows_per_segment
+ std::vector<uint32_t> segment_num_rows;
+ { // write `num_segments * rows_per_segment` rows to rowset
+ RowsetWriterContext writer_context;
+ create_rowset_writer_context(10049, tablet_schema, &writer_context);
+
Review Comment:
warning: too few arguments to function call, expected 3, have 2 [clang-diagnostic-error]
```cpp
s = RowsetFactory::create_rowset_writer(writer_context, &rowset_writer);
^
```
**be/src/olap/rowset/rowset_factory.h:39:** 'create_rowset_writer' declared here
```cpp
static Status create_rowset_writer(const RowsetWriterContext& context, bool is_vertical,
^
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] freemandealer commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
freemandealer commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1034568659
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -743,9 +819,25 @@ RowsetSharedPtr BetaRowsetWriter::build() {
return nullptr;
}
+ if (config::enable_final_pass_segcompaction) {
+ uint64_t begin = GetCurrentTimeMicros();
Review Comment:
> use OlapStopWatch instead of GetCurrentTimeMicros
Thanks for your suggestion. I have checked OlapStopWatch, which is great tool but lack of flexibility coz it start timing when it is contructed. Thought I can put it into the scope here but the code are changing from time to time. I think it is more useful when do function level timing. So I would like to stick to GetCurrentTimeMicros if there is no performance issue.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] zhannngchen commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
zhannngchen commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1049280771
##########
be/src/common/config.h:
##########
@@ -838,6 +838,9 @@ CONF_Int32(segcompaction_threshold_segment_num, "10");
// The segment whose row number above the threshold will be compacted during segcompaction
CONF_Int32(segcompaction_small_threshold, "1048576");
+// Enable final-pass segcompaction before commit txn
+CONF_Bool(enable_final_pass_segcompaction, "false");
Review Comment:
We can make it as the default behavior of segment compaction?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14595:
URL: https://github.com/apache/doris/pull/14595#issuecomment-1358943319
clang-tidy review says "All clean, LGTM! :+1:"
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] github-actions[bot] commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1052178246
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,11 @@ BetaRowsetWriter::BetaRowsetWriter()
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
+ _is_doing_segcompaction(false),
+ _total_row_num_written(0) {
_segcompaction_status.store(OK);
+ bthread_mutex_init(&_is_doing_segcompaction_lock, NULL);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_mutex_init(&_is_doing_segcompaction_lock, nullptr);
```
##########
be/test/olap/segcompaction_test.cpp:
##########
@@ -576,6 +580,151 @@ TEST_F(SegCompactionTest, SegCompactionInterleaveWithBig_OoOoO) {
}
}
+TEST_F(SegCompactionTest, SegCompactionMultiPass) {
+ /* ooooOOoQooooooooO (Q is bigger than O) will be oOOoQooO after 1st-pass segcompaction
+ * finally we get OQO after final-pass segcompaction
+ * */
+ config::enable_segcompaction_during_load = true;
+ config::enable_storage_vectorization = true;
+ config::enable_segcompaction_after_load = true;
+ config::max_segment_num_per_rowset = 5;
+
+ Status s;
+ TabletSchemaSPtr tablet_schema = std::make_shared<TabletSchema>();
+ create_tablet_schema(tablet_schema);
+
+ RowsetSharedPtr rowset;
+ config::segcompaction_small_threshold = 6000; // set threshold above
+ // rows_per_segment
+ std::vector<uint32_t> segment_num_rows;
+ { // write `num_segments * rows_per_segment` rows to rowset
+ RowsetWriterContext writer_context;
+ create_rowset_writer_context(10049, tablet_schema, &writer_context);
+
+ std::unique_ptr<RowsetWriter> rowset_writer;
+ s = RowsetFactory::create_rowset_writer(writer_context, &rowset_writer);
Review Comment:
warning: too few arguments to function call, expected 3, have 2 [clang-diagnostic-error]
```cpp
s = RowsetFactory::create_rowset_writer(writer_context, &rowset_writer);
^
```
**be/src/olap/rowset/rowset_factory.h:39:** 'create_rowset_writer' declared here
```cpp
static Status create_rowset_writer(const RowsetWriterContext& context, bool is_vertical,
^
```
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -52,8 +52,11 @@
_total_data_size(0),
_total_index_size(0),
_raw_num_rows_written(0),
- _is_doing_segcompaction(false) {
+ _is_doing_segcompaction(false),
+ _total_row_num_written(0) {
_segcompaction_status.store(OK);
+ bthread_mutex_init(&_is_doing_segcompaction_lock, NULL);
+ bthread_cond_init(&_segcompacting_cond, NULL);
Review Comment:
warning: use nullptr [modernize-use-nullptr]
```suggestion
bthread_cond_init(&_segcompacting_cond, nullptr);
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] freemandealer commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
freemandealer commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1034662141
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -412,7 +423,7 @@ Status BetaRowsetWriter::_load_noncompacted_segments(
* length is beyond (config::segcompaction_threshold_segment_num / 2)
*/
Status BetaRowsetWriter::_find_longest_consecutive_small_segment(
- SegCompactionCandidatesSharedPtr segments) {
+ SegCompactionCandidatesSharedPtr segments, size_t small_threshold, bool is_greedy) {
Review Comment:
I agree it is a little mess in the find function... but moving rename out dose not seems to help with that (and may bring additional loops & iterator stuff than rename inplace). I should instead, refine the description comments for the function.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] yixiutt commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
yixiutt commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1033231982
##########
be/src/olap/rowset/beta_rowset_writer.h:
##########
@@ -32,6 +32,12 @@ class FileWriter;
using SegCompactionCandidates = std::vector<segment_v2::SegmentSharedPtr>;
using SegCompactionCandidatesSharedPtr = std::shared_ptr<SegCompactionCandidates>;
+enum SegCompactionType {
Review Comment:
add some comment for these types
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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] [doris] yixiutt commented on a diff in pull request #14595: [enhancement](load) multipass segcompaction to reduce segments before publish (#14590)
Posted by GitBox <gi...@apache.org>.
yixiutt commented on code in PR #14595:
URL: https://github.com/apache/doris/pull/14595#discussion_r1033247509
##########
be/src/olap/rowset/beta_rowset_writer.cpp:
##########
@@ -412,7 +423,7 @@ Status BetaRowsetWriter::_load_noncompacted_segments(
* length is beyond (config::segcompaction_threshold_segment_num / 2)
*/
Status BetaRowsetWriter::_find_longest_consecutive_small_segment(
- SegCompactionCandidatesSharedPtr segments) {
+ SegCompactionCandidatesSharedPtr segments, size_t small_threshold, bool is_greedy) {
Review Comment:
I think it's better than _find_longest_consecutive_small_segment just find rowset with 2 set, such as rename_segments_set and compact_segment_set, instead of doing rename inside this funtion
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
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