[fix](memory) Independent count exec node memory profile (#22598)

Independent count exec node memory profile, after #22582
This commit is contained in:
Xinyi Zou
2023-08-06 10:56:31 +08:00
committed by GitHub
parent 1073a924c1
commit 96f42ca20a
12 changed files with 48 additions and 91 deletions

View File

@ -90,6 +90,7 @@ ExecNode::ExecNode(ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl
_rows_returned_counter(nullptr),
_rows_returned_rate(nullptr),
_memory_used_counter(nullptr),
_peak_memory_usage_counter(nullptr),
_is_closed(false),
_ref(0) {
if (tnode.__isset.output_tuple_id) {
@ -134,8 +135,10 @@ Status ExecNode::prepare(RuntimeState* state) {
std::bind<int64_t>(&RuntimeProfile::units_per_second, _rows_returned_counter,
runtime_profile()->total_time_counter()),
"");
_mem_tracker = std::make_unique<MemTracker>("ExecNode:" + _runtime_profile->name(),
_runtime_profile.get(), nullptr, "PeakMemoryUsage");
_memory_used_counter = ADD_LABEL_COUNTER(runtime_profile(), "MemoryUsage");
_peak_memory_usage_counter = _runtime_profile->AddHighWaterMarkCounter(
"PeakMemoryUsage", TUnit::BYTES, "MemoryUsage");
_mem_tracker = std::make_unique<MemTracker>("ExecNode:" + _runtime_profile->name());
for (auto& conjunct : _conjuncts) {
RETURN_IF_ERROR(conjunct->prepare(state, intermediate_row_desc()));
@ -204,6 +207,9 @@ Status ExecNode::close(RuntimeState* state) {
result = st;
}
}
if (_peak_memory_usage_counter) {
_peak_memory_usage_counter->set(_mem_tracker->peak_consumption());
}
release_resource(state);
return result;
}
@ -572,6 +578,7 @@ Status ExecNode::get_next_after_projects(
if (UNLIKELY(!status.ok())) return status;
return do_projections(&_origin_block, block);
}
_peak_memory_usage_counter->set(_mem_tracker->peak_consumption());
return func(state, block, eos);
}