[feature] (memory) Switch TLS mem tracker to separate more detailed memory usage (#8605)
In pr #8476, all memory usage of a process is recorded in the process mem tracker, and all memory usage of a query is recorded in the query mem tracker, and it is still necessary to manually call `transfer to` to track the cached memory size. We hope to separate out more detailed memory usage based on Hook TCMalloc new/delete + TLS mem tracker. In this pr, the more detailed mem tracker is switched to TLS, which automatically and accurately counts more detailed memory usage than before.
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
#include "vec/exec/vset_operation_node.h"
|
||||
|
||||
#include "runtime/thread_context.h"
|
||||
#include "util/defer_op.h"
|
||||
#include "vec/exprs/vexpr.h"
|
||||
namespace doris {
|
||||
@ -228,6 +229,8 @@ 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");
|
||||
Block block;
|
||||
MutableBlock mutable_block(child(0)->row_desc().tuple_descriptors());
|
||||
|
||||
@ -244,7 +247,6 @@ Status VSetOperationNode::hash_table_build(RuntimeState* state) {
|
||||
_hash_table_mem_tracker->consume(allocated_bytes);
|
||||
_mem_used += allocated_bytes;
|
||||
|
||||
RETURN_IF_INSTANCE_LIMIT_EXCEEDED(state, "Set Operation Node, while getting next from the child 0.");
|
||||
if (block.rows() != 0) { mutable_block.merge(block); }
|
||||
|
||||
// make one block for each 4 gigabytes
|
||||
@ -254,7 +256,6 @@ Status VSetOperationNode::hash_table_build(RuntimeState* state) {
|
||||
// TODO:: Rethink may we should do the proess after we recevie all build blocks ?
|
||||
// which is better.
|
||||
RETURN_IF_ERROR(process_build_block(_build_blocks[index], index));
|
||||
RETURN_IF_INSTANCE_LIMIT_EXCEEDED(state, "Set Operation Node, while constructing the hash table.");
|
||||
mutable_block = MutableBlock();
|
||||
++index;
|
||||
last_mem_used = _mem_used;
|
||||
@ -263,7 +264,6 @@ Status VSetOperationNode::hash_table_build(RuntimeState* state) {
|
||||
|
||||
_build_blocks.emplace_back(mutable_block.to_block());
|
||||
RETURN_IF_ERROR(process_build_block(_build_blocks[index], index));
|
||||
RETURN_IF_INSTANCE_LIMIT_EXCEEDED(state, "Set Operation Node, while constructing the hash table.");
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user