[feature-wip] (memory tracker) (step5) Fix track bthread, fix track vectorized query (#9145)
1. fix track bthread
- Bthread, a high performance M:N thread library used by brpc. In Doris, a brpc server response runs on one bthread, possibly on multiple pthreads. Currently, MemTracker consumption relies on pthread local variables (TLS).
- This caused pthread TLS MemTracker confusion when switching pthread TLS MemTracker in brpc server response. So replacing pthread TLS with bthread TLS in the brpc server response saves the MemTracker.
Ref: 731730da85/docs/en/server.md (bthread-local)
2. fix track vectorized query
- Added track mmap. Currently, mmap allocates memory in many places of the vectorized execution engine.
- Refactored ThreadContext to avoid dependency conflicts and make it easier to debug.
- Fix some bugs.
This commit is contained in:
@ -80,6 +80,7 @@ Status ExchangeNode::prepare(RuntimeState* state) {
|
||||
Status ExchangeNode::open(RuntimeState* state) {
|
||||
SCOPED_TIMER(_runtime_profile->total_time_counter());
|
||||
SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(mem_tracker());
|
||||
ADD_THREAD_LOCAL_MEM_TRACKER(_stream_recvr->mem_tracker());
|
||||
RETURN_IF_ERROR(ExecNode::open(state));
|
||||
if (_is_merging) {
|
||||
RETURN_IF_ERROR(_sort_exec_exprs.open(state));
|
||||
@ -215,7 +216,6 @@ Status ExchangeNode::get_next_merging(RuntimeState* state, RowBatch* output_batc
|
||||
RETURN_IF_CANCELLED(state);
|
||||
RETURN_IF_ERROR(state->check_query_state("Exchange, while merging next."));
|
||||
|
||||
ADD_THREAD_LOCAL_MEM_TRACKER(_stream_recvr->mem_tracker());
|
||||
RETURN_IF_ERROR(_stream_recvr->get_next(output_batch, eos));
|
||||
while ((_num_rows_skipped < _offset)) {
|
||||
_num_rows_skipped += output_batch->num_rows();
|
||||
|
||||
Reference in New Issue
Block a user