[enhancement] Refactor to improve the usability of MemTracker (step2) (#10823)
This commit is contained in:
@ -54,7 +54,7 @@
|
||||
#include "runtime/descriptors.h"
|
||||
#include "runtime/exec_env.h"
|
||||
#include "runtime/initial_reservations.h"
|
||||
#include "runtime/mem_tracker.h"
|
||||
#include "runtime/memory/mem_tracker.h"
|
||||
#include "runtime/row_batch.h"
|
||||
#include "runtime/runtime_state.h"
|
||||
#include "util/debug_util.h"
|
||||
@ -169,7 +169,7 @@ void ExecNode::push_down_predicate(RuntimeState* state, std::list<ExprContext*>*
|
||||
if ((*iter)->root()->is_bound(&_tuple_ids)) {
|
||||
// LOG(INFO) << "push down success expr is " << (*iter)->debug_string()
|
||||
// << " and node is " << debug_string();
|
||||
(*iter)->prepare(state, row_desc(), _expr_mem_tracker);
|
||||
(*iter)->prepare(state, row_desc());
|
||||
(*iter)->open(state);
|
||||
_conjunct_ctxs.push_back(*iter);
|
||||
iter = expr_ctxs->erase(iter);
|
||||
@ -206,17 +206,14 @@ Status ExecNode::prepare(RuntimeState* state) {
|
||||
std::bind<int64_t>(&RuntimeProfile::units_per_second, _rows_returned_counter,
|
||||
runtime_profile()->total_time_counter()),
|
||||
"");
|
||||
_mem_tracker = MemTracker::create_tracker(-1, "ExecNode:" + _runtime_profile->name(),
|
||||
state->instance_mem_tracker(),
|
||||
MemTrackerLevel::VERBOSE, _runtime_profile.get());
|
||||
SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(_mem_tracker);
|
||||
_expr_mem_tracker = MemTracker::create_tracker(-1, "ExecNode:Exprs:" + _runtime_profile->name(),
|
||||
_mem_tracker);
|
||||
_mem_tracker = std::make_unique<MemTracker>("ExecNode:" + _runtime_profile->name(), nullptr,
|
||||
_runtime_profile.get());
|
||||
SCOPED_CONSUME_MEM_TRACKER(_mem_tracker.get());
|
||||
|
||||
if (_vconjunct_ctx_ptr) {
|
||||
RETURN_IF_ERROR((*_vconjunct_ctx_ptr)->prepare(state, row_desc(), expr_mem_tracker()));
|
||||
RETURN_IF_ERROR((*_vconjunct_ctx_ptr)->prepare(state, row_desc()));
|
||||
}
|
||||
RETURN_IF_ERROR(Expr::prepare(_conjunct_ctxs, state, row_desc(), expr_mem_tracker()));
|
||||
RETURN_IF_ERROR(Expr::prepare(_conjunct_ctxs, state, row_desc()));
|
||||
|
||||
// TODO(zc):
|
||||
// AddExprCtxsToFree(_conjunct_ctxs);
|
||||
@ -228,7 +225,7 @@ Status ExecNode::prepare(RuntimeState* state) {
|
||||
}
|
||||
|
||||
Status ExecNode::open(RuntimeState* state) {
|
||||
SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(_mem_tracker);
|
||||
SCOPED_CONSUME_MEM_TRACKER(_mem_tracker.get());
|
||||
if (_vconjunct_ctx_ptr) {
|
||||
RETURN_IF_ERROR((*_vconjunct_ctx_ptr)->open(state));
|
||||
}
|
||||
@ -700,7 +697,7 @@ Status ExecNode::claim_buffer_reservation(RuntimeState* state) {
|
||||
|
||||
ss << print_plan_node_type(_type) << " id=" << _id << " ptr=" << this;
|
||||
RETURN_IF_ERROR(buffer_pool->RegisterClient(ss.str(), state->instance_buffer_reservation(),
|
||||
mem_tracker(), buffer_pool->GetSystemBytesLimit(),
|
||||
buffer_pool->GetSystemBytesLimit(),
|
||||
runtime_profile(), &_buffer_pool_client));
|
||||
|
||||
state->initial_reservations()->Claim(&_buffer_pool_client, _resource_profile.min_reservation);
|
||||
|
||||
Reference in New Issue
Block a user