[enhancement] Refactor to improve the usability of MemTracker (step2) (#10823)
This commit is contained in:
@ -40,7 +40,6 @@ struct HashTableBuild {
|
||||
|
||||
Defer defer {[&]() {
|
||||
int64_t bucket_bytes = hash_table_ctx.hash_table.get_buffer_size_in_bytes();
|
||||
_operation_node->_hash_table_mem_tracker->consume(bucket_bytes - old_bucket_bytes);
|
||||
_operation_node->_mem_used += bucket_bytes - old_bucket_bytes;
|
||||
}};
|
||||
|
||||
@ -86,7 +85,6 @@ Status VSetOperationNode::close(RuntimeState* state) {
|
||||
for (auto& exprs : _child_expr_lists) {
|
||||
VExpr::close(exprs, state);
|
||||
}
|
||||
_hash_table_mem_tracker->release(_mem_used);
|
||||
return ExecNode::close(state);
|
||||
}
|
||||
|
||||
@ -116,8 +114,8 @@ Status VSetOperationNode::init(const TPlanNode& tnode, RuntimeState* state) {
|
||||
Status VSetOperationNode::open(RuntimeState* state) {
|
||||
START_AND_SCOPE_SPAN(state->get_tracer(), span, "VSetOperationNode::open");
|
||||
SCOPED_TIMER(_runtime_profile->total_time_counter());
|
||||
SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(_mem_tracker);
|
||||
RETURN_IF_ERROR(ExecNode::open(state));
|
||||
SCOPED_CONSUME_MEM_TRACKER(_mem_tracker.get());
|
||||
// open result expr lists.
|
||||
for (const std::vector<VExprContext*>& exprs : _child_expr_lists) {
|
||||
RETURN_IF_ERROR(VExpr::open(exprs, state));
|
||||
@ -129,15 +127,13 @@ Status VSetOperationNode::open(RuntimeState* state) {
|
||||
Status VSetOperationNode::prepare(RuntimeState* state) {
|
||||
SCOPED_TIMER(_runtime_profile->total_time_counter());
|
||||
RETURN_IF_ERROR(ExecNode::prepare(state));
|
||||
SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(_mem_tracker);
|
||||
_hash_table_mem_tracker = MemTracker::create_virtual_tracker(-1, "VSetOperationNode:HashTable");
|
||||
SCOPED_CONSUME_MEM_TRACKER(_mem_tracker.get());
|
||||
_build_timer = ADD_TIMER(runtime_profile(), "BuildTime");
|
||||
_probe_timer = ADD_TIMER(runtime_profile(), "ProbeTime");
|
||||
|
||||
// Prepare result expr lists.
|
||||
for (int i = 0; i < _child_expr_lists.size(); ++i) {
|
||||
RETURN_IF_ERROR(VExpr::prepare(_child_expr_lists[i], state, child(i)->row_desc(),
|
||||
expr_mem_tracker()));
|
||||
RETURN_IF_ERROR(VExpr::prepare(_child_expr_lists[i], state, child(i)->row_desc()));
|
||||
}
|
||||
|
||||
for (auto ctx : _child_expr_lists[0]) {
|
||||
@ -236,8 +232,7 @@ void VSetOperationNode::hash_table_init() {
|
||||
//build a hash table from child(0)
|
||||
Status VSetOperationNode::hash_table_build(RuntimeState* state) {
|
||||
RETURN_IF_ERROR(child(0)->open(state));
|
||||
SCOPED_SWITCH_THREAD_LOCAL_MEM_TRACKER_ERR_CB(
|
||||
"Vec Set Operation Node, while constructing the hash table");
|
||||
SCOPED_UPDATE_MEM_EXCEED_CALL_BACK("Vec Set Operation Node, while constructing the hash table");
|
||||
Block block;
|
||||
MutableBlock mutable_block(child(0)->row_desc().tuple_descriptors());
|
||||
|
||||
@ -252,7 +247,6 @@ Status VSetOperationNode::hash_table_build(RuntimeState* state) {
|
||||
child(0)->get_next_span(), eos);
|
||||
|
||||
size_t allocated_bytes = block.allocated_bytes();
|
||||
_hash_table_mem_tracker->consume(allocated_bytes);
|
||||
_mem_used += allocated_bytes;
|
||||
|
||||
if (block.rows() != 0) {
|
||||
|
||||
Reference in New Issue
Block a user