-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[enhancement](compaction) optimizing memory usage for compaction #36492
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
[enhancement](compaction) optimizing memory usage for compaction #36492
Conversation
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
TPC-H: Total hot run time: 40420 ms |
TPC-DS: Total hot run time: 173148 ms |
ClickBench: Total hot run time: 30.31 s |
|
TeamCity be ut coverage result: |
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
TPC-H: Total hot run time: 41006 ms |
|
TeamCity be ut coverage result: |
be/src/olap/base_compaction.cpp
Outdated
| break; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a defer, because there are other places where rowsets are removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
be/src/common/config.cpp
Outdated
|
|
||
| DEFINE_Bool(enable_base_compaction_idle_sched, "true"); | ||
| DEFINE_mInt64(base_compaction_min_rowset_num, "5"); | ||
| DEFINE_mInt64(base_compaction_max_rowset_num, "20"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shoud limit comlumn num, it is waynum * column_num, because segment columns consumes memory too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to rowset num, we shoud limit score?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| way_num = num_segments(); | ||
| CHECK(way_num > 0); | ||
| } | ||
| return way_num; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as score?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The score contains an empty rowset, while the merge way does not include an empty rowset
be/src/olap/compaction.cpp
Outdated
| _merge_rowsets_latency_timer = ADD_TIMER(_profile, "merge_rowsets_latency"); | ||
| } | ||
|
|
||
| int64_t Compaction::merge_way() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge_way_num
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| << tablet->tablet_id() << " way cnt: " << way_cnt; | ||
| return 4096 - 32; | ||
| } | ||
| int64_t block_mem_limit = config::compaction_memory_bytes_limit / way_cnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are meta consuming memory too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR temporarily does not calculate the memory consumption of metadata
| src_rowset_readers, dst_rowset_writer, max_rows_per_segment, stats_output, | ||
| key_group_cluster_key_idxes)); | ||
| key_group_cluster_key_idxes, batch_size, &(tablet->sample_infos[i]))); | ||
| if (is_key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When memlimit happens, we should adjust batch_size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
dataroaring
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as comment.
ClickBench: Total hot run time: 30.47 s |
be/src/olap/base_compaction.cpp
Outdated
| void BaseCompaction::_filter_input_rowset() { | ||
| auto rs_iter = _input_rowsets.begin(); | ||
| int score = 0; | ||
| while (rs_iter != _input_rowsets.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just resize()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
run buildall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #include "olap/base_compaction.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'olap/base_compaction.h' file not found [clang-diagnostic-error]
#include "olap/base_compaction.h"
^
TPC-H: Total hot run time: 40077 ms |
TPC-DS: Total hot run time: 172010 ms |
ClickBench: Total hot run time: 30.53 s |
|
run buildall |
TPC-H: Total hot run time: 40180 ms |
TPC-DS: Total hot run time: 173175 ms |
ClickBench: Total hot run time: 30.65 s |
|
run p0 |
dataroaring
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
…ion (apache#36492)" This reverts commit 9990181.
|
revert and recommit in #37099 |
1 Limit the number of rowsets participating in base compaction.
2 Estimate the appropriate batch size by sampling and analyzing the memory consumption of blocks.