-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[fix](counters) fix MemoryUsage and PeakMemoryUsage counters of some operators #41602
base: master
Are you sure you want to change the base?
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
5021271
to
5fa6ca1
Compare
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
be/src/pipeline/exec/operator.cpp
Outdated
@@ -425,8 +424,7 @@ PipelineXSinkLocalStateBase::PipelineXSinkLocalStateBase(DataSinkOperatorXBase* | |||
} | |||
|
|||
PipelineXLocalStateBase::PipelineXLocalStateBase(RuntimeState* state, OperatorXBase* parent) | |||
: _num_rows_returned(0), | |||
_rows_returned_counter(nullptr), | |||
: _rows_returned_counter(nullptr), |
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: member initializer for '_rows_returned_counter' is redundant [modernize-use-default-member-init]
: _rows_returned_counter(nullptr), | |
: , |
69f6048
to
3fe3a78
Compare
run buildall |
TeamCity be ut coverage result: |
data.get_buffer_size_in_bytes() - | ||
Base::_shared_state->mem_usage_record.used_in_state); | ||
Base::_shared_state->mem_usage_record.used_in_state; | ||
Base::_mem_tracker->consume(arena_memory_usage); |
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.
base 里的这个memtracker 还有用么?
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.
有了MemoryUsage
和MemoryUsagePeak
这两个counter,这个_mem_tracker
感觉可以删掉了。
local_state._memory_used_counter->set(local_state._mem_tracker->consumption()); | ||
local_state._peak_memory_usage_counter->set( | ||
local_state._mem_tracker->peak_consumption()); | ||
COUNTER_SET(local_state._build_blocks_memory_usage, (int64_t)new_block_mem_usage); |
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.
至少跟580 行一致
@@ -386,6 +389,8 @@ Status ExchangeSinkBuffer::_send_rpc(InstanceLoId id) { | |||
} | |||
} | |||
if (request.block_holder->get_block()) { | |||
_parent->memory_used_counter()->update( | |||
-request.block_holder->get_block()->ByteSizeLong()); |
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.
broadcast 的时候,是shared ptr,一个block 在多个channel 共享的,你这么统计,结果很大。
先别统计broadcast的了。
@@ -166,6 +166,7 @@ Status ExchangeSinkBuffer::add_block(TransmitInfo&& request) { | |||
RETURN_IF_ERROR( | |||
BeExecVersionManager::check_be_exec_version(request.block->be_exec_version())); | |||
} | |||
_parent->memory_used_counter()->update(request.block->ByteSizeLong()); |
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.
我们 exchange sink operator:
- 先只统计非broad cast 方式的内存,统计方式跟现在这个PR的代码一样。
- channel 内保存的那一个block的内存。 broadcast方式的正好没有。
- 对于broadcast 方式的内存,可能是通过那个holder,构造和析构函数里计算,或者直接使用holder limiter的那个值。
0b594f4
to
1255d5a
Compare
run buildall |
TeamCity be ut coverage result: |
275528a
to
ac364bb
Compare
run buildall |
TeamCity be ut coverage result: |
run p0 |
Base::_mem_tracker->consume(arena_memory_usage); | ||
_serialize_key_arena_memory_usage->add(arena_memory_usage); | ||
Base::_shared_state->mem_usage_record.used_in_arena = _agg_arena_pool->size(); | ||
int64_t arena_memory_usage = _agg_arena_pool->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.
lost agg hash table?
@@ -109,7 +109,7 @@ class AggSinkLocalState : public PipelineXSinkLocalState<AggSharedState> { | |||
RuntimeProfile::Counter* _max_row_size_counter = nullptr; | |||
RuntimeProfile::Counter* _hash_table_memory_usage = nullptr; |
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 counter is not updated?
@@ -458,8 +455,11 @@ Status ExchangeSinkOperatorX::sink(RuntimeState* state, vectorized::Block* block | |||
auto rows = block->rows(); | |||
{ | |||
SCOPED_TIMER(local_state._split_block_hash_compute_timer); | |||
RETURN_IF_ERROR( | |||
local_state._partitioner->do_partitioning(state, block, _mem_tracker.get())); | |||
RETURN_IF_ERROR(local_state._partitioner->do_partitioning(state, block, nullptr)); |
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 add a nullptr not remove this parameter?
be/src/pipeline/exec/operator.cpp
Outdated
@@ -345,9 +345,8 @@ void PipelineXLocalStateBase::reached_limit(vectorized::Block* block, bool* eos) | |||
}); | |||
|
|||
if (auto rows = block->rows()) { | |||
_num_rows_returned += rows; | |||
COUNTER_UPDATE(_rows_returned_counter, rows); |
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.
这里统一给加了,然后每个operator 内部也在加,难道没有错吗?
@@ -460,18 +460,16 @@ void AggLocalState::do_agg_limit(vectorized::Block* block, bool* eos) { | |||
if (_shared_state->do_sort_limit && _shared_state->do_limit_filter(block, block->rows())) { | |||
vectorized::Block::filter_block_internal(block, _shared_state->need_computes); | |||
if (auto rows = block->rows()) { | |||
_num_rows_returned += rows; | |||
add_num_rows_returned(rows); |
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.
这里也加,然后base 里也加?
@@ -161,7 +161,7 @@ Status PartitionedHashJoinSinkLocalState::_revoke_unpartitioned_block(RuntimeSta | |||
|
|||
{ | |||
SCOPED_TIMER(_partition_timer); | |||
(void)_partitioner->do_partitioning(state, &sub_block, _mem_tracker.get()); | |||
(void)_partitioner->do_partitioning(state, &sub_block, nullptr); |
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.
这里的nullptr 有啥意义吗?
ac364bb
to
d9ef85e
Compare
d9ef85e
to
f4bd3d8
Compare
clang-tidy review says "All clean, LGTM! 👍" |
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
run buildall |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
clang-tidy review says "All clean, LGTM! 👍" |
TeamCity be ut coverage result: |
run buildall |
TeamCity be ut coverage result: |
Proposed changes
Issue Number: close #xxx