Coverage Report

Created: 2024-11-20 19:28

/root/doris/be/src/runtime/thread_context.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <bthread/bthread.h>
21
#include <bthread/types.h>
22
#include <gen_cpp/Types_types.h>
23
#include <stdint.h>
24
25
#include <memory>
26
#include <ostream>
27
#include <string>
28
#include <thread>
29
30
#include "common/exception.h"
31
#include "common/logging.h"
32
#include "gutil/macros.h"
33
#include "runtime/exec_env.h"
34
#include "runtime/memory/mem_tracker_limiter.h"
35
#include "runtime/memory/thread_mem_tracker_mgr.h"
36
#include "util/defer_op.h" // IWYU pragma: keep
37
38
// Used to tracking query/load/compaction/e.g. execution thread memory usage.
39
// This series of methods saves some information to the thread local context of the current worker thread,
40
// including MemTracker, QueryID, etc. Use CONSUME_THREAD_MEM_TRACKER/RELEASE_THREAD_MEM_TRACKER in the code segment where
41
// the macro is located to record the memory into MemTracker.
42
// Not use it in rpc done.run(), because bthread_setspecific may have errors when UBSAN compiles.
43
#if defined(USE_MEM_TRACKER) && !defined(BE_TEST)
44
// Attach to query/load/compaction/e.g. when thread starts.
45
// This will save some info about a working thread in the thread context.
46
// Looking forward to tracking memory during thread execution into MemTrackerLimiter.
47
#define SCOPED_ATTACH_TASK(arg1) auto VARNAME_LINENUM(attach_task) = AttachTask(arg1)
48
49
// Switch MemTrackerLimiter for count memory during thread execution.
50
// Used after SCOPED_ATTACH_TASK, in order to count the memory into another
51
// MemTrackerLimiter instead of the MemTrackerLimiter added by the attach task.
52
#define SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(arg1) \
53
    auto VARNAME_LINENUM(switch_mem_tracker) = doris::SwitchThreadMemTrackerLimiter(arg1)
54
55
// Looking forward to tracking memory during thread execution into MemTracker.
56
// Usually used to record query more detailed memory, including ExecNode operators.
57
#define SCOPED_CONSUME_MEM_TRACKER(mem_tracker) \
58
    auto VARNAME_LINENUM(add_mem_consumer) = doris::AddThreadMemTrackerConsumer(mem_tracker)
59
60
// Count a code segment memory (memory malloc - memory free) to int64_t
61
// Usage example: int64_t scope_mem = 0; { SCOPED_MEM_COUNT(&scope_mem); xxx; xxx; }
62
#define SCOPED_MEM_COUNT_BY_HOOK(scope_mem) \
63
    auto VARNAME_LINENUM(scope_mem_count) = doris::ScopeMemCountByHook(scope_mem)
64
65
// Count a code segment memory (memory malloc - memory free) to MemTracker.
66
// Compared to count `scope_mem`, MemTracker is easier to observe from the outside and is thread-safe.
67
// Usage example: std::unique_ptr<MemTracker> tracker = std::make_unique<MemTracker>("first_tracker");
68
//                { SCOPED_CONSUME_MEM_TRACKER_BY_HOOK(_mem_tracker.get()); xxx; xxx; }
69
#define SCOPED_CONSUME_MEM_TRACKER_BY_HOOK(mem_tracker) \
70
    auto VARNAME_LINENUM(add_mem_consumer) = doris::AddThreadMemTrackerConsumerByHook(mem_tracker)
71
72
#define DEFER_RELEASE_RESERVED() \
73
    Defer VARNAME_LINENUM(defer) {[&]() { doris::thread_context()->release_reserved_memory(); }};
74
75
#define ORPHAN_TRACKER_CHECK()                                                  \
76
    DCHECK(doris::k_doris_exit || !doris::config::enable_memory_orphan_check || \
77
           doris::thread_context()->thread_mem_tracker()->label() != "Orphan")  \
78
            << doris::memory_orphan_check_msg
79
80
#define MEMORY_ORPHAN_CHECK()                                                 \
81
    DCHECK(doris::k_doris_exit || !doris::config::enable_memory_orphan_check) \
82
            << doris::memory_orphan_check_msg;
83
#else
84
// thread context need to be initialized, required by Allocator and elsewhere.
85
#define SCOPED_ATTACH_TASK(arg1, ...) \
86
161
    auto VARNAME_LINENUM(scoped_tls_at) = doris::ScopedInitThreadContext()
87
#define SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(arg1) \
88
71.0k
    auto VARNAME_LINENUM(scoped_tls_stmtl) = doris::ScopedInitThreadContext()
89
#define SCOPED_CONSUME_MEM_TRACKER(mem_tracker) \
90
132
    auto VARNAME_LINENUM(scoped_tls_cmt) = doris::ScopedInitThreadContext()
91
#define SCOPED_MEM_COUNT_BY_HOOK(scope_mem) \
92
0
    auto VARNAME_LINENUM(scoped_tls_mcbh) = doris::ScopedInitThreadContext()
93
#define SCOPED_CONSUME_MEM_TRACKER_BY_HOOK(mem_tracker) \
94
    auto VARNAME_LINENUM(scoped_tls_cmtbh) = doris::ScopedInitThreadContext()
95
#define DEFER_RELEASE_RESERVED() (void)0
96
#define ORPHAN_TRACKER_CHECK() (void)0
97
#define MEMORY_ORPHAN_CHECK() (void)0
98
#endif
99
100
#define SCOPED_SKIP_MEMORY_CHECK() \
101
46.5k
    auto VARNAME_LINENUM(scope_skip_memory_check) = doris::ScopeSkipMemoryCheck()
102
103
#define SKIP_LARGE_MEMORY_CHECK(...)                                       \
104
    do {                                                                   \
105
        doris::ThreadLocalHandle::create_thread_local_if_not_exits();      \
106
        doris::thread_context()->skip_large_memory_check++;                \
107
        DEFER({                                                            \
108
            doris::thread_context()->skip_large_memory_check--;            \
109
            doris::ThreadLocalHandle::del_thread_local_if_count_is_zero(); \
110
        });                                                                \
111
        __VA_ARGS__;                                                       \
112
    } while (0)
113
114
#define LIMIT_LOCAL_SCAN_IO(data_dir, bytes_read)                     \
115
25.8k
    std::shared_ptr<IOThrottle> iot = nullptr;                        \
116
25.8k
    auto* t_ctx = doris::thread_context(true);                        \
117
25.8k
    if (t_ctx) {                                                      \
118
25.8k
        iot = t_ctx->get_local_scan_io_throttle(data_dir);            \
119
25.8k
    }                                                                 \
120
25.8k
    if (iot) {                                                        \
121
0
        iot->acquire(-1);                                             \
122
0
    }                                                                 \
123
25.8k
    Defer defer {                                                     \
124
25.8k
        [&]() {                                                       \
125
25.8k
            if (iot) {                                                \
126
0
                iot->update_next_io_time(*bytes_read);                \
127
0
                t_ctx->update_total_local_scan_io_adder(*bytes_read); \
128
0
            }                                                         \
129
25.8k
        }                                                             \
130
25.8k
    }
131
132
#define LIMIT_REMOTE_SCAN_IO(bytes_read)               \
133
11
    std::shared_ptr<IOThrottle> iot = nullptr;         \
134
11
    if (auto* t_ctx = doris::thread_context(true)) {   \
135
11
        iot = t_ctx->get_remote_scan_io_throttle();    \
136
11
    }                                                  \
137
11
    if (iot) {                                         \
138
0
        iot->acquire(-1);                              \
139
0
    }                                                  \
140
11
    Defer defer {                                      \
141
11
        [&]() {                                        \
142
11
            if (iot) {                                 \
143
0
                iot->update_next_io_time(*bytes_read); \
144
0
            }                                          \
145
11
        }                                              \
buffered_reader.cpp:_ZZN5doris2io14PrefetchBuffer11read_bufferEmPKcmPmENK3$_1clEv
Line
Count
Source
141
11
        [&]() {                                        \
142
11
            if (iot) {                                 \
143
0
                iot->update_next_io_time(*bytes_read); \
144
0
            }                                          \
145
11
        }                                              \
Unexecuted instantiation: hdfs_file_reader.cpp:_ZZN5doris2io14HdfsFileReader12read_at_implEmNS_5SliceEPmPKNS0_9IOContextEENK3$_0clEv
Unexecuted instantiation: s3_file_reader.cpp:_ZZN5doris2io12S3FileReader12read_at_implEmNS_5SliceEPmPKNS0_9IOContextEENK3$_1clEv
146
11
    }
147
148
namespace doris {
149
150
class ThreadContext;
151
class MemTracker;
152
class RuntimeState;
153
class QueryThreadContext;
154
class WorkloadGroup;
155
156
extern bthread_key_t btls_key;
157
158
// Is true after ThreadContext construction.
159
inline thread_local bool pthread_context_ptr_init = false;
160
inline thread_local constinit ThreadContext* thread_context_ptr = nullptr;
161
// use mem hook to consume thread mem tracker.
162
inline thread_local bool use_mem_hook = false;
163
164
static std::string memory_orphan_check_msg =
165
        "If you crash here, it means that SCOPED_ATTACH_TASK and "
166
        "SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER are not used correctly. starting position of "
167
        "each thread is expected to use SCOPED_ATTACH_TASK to bind a MemTrackerLimiter belonging "
168
        "to Query/Load/Compaction/Other Tasks, otherwise memory alloc using Doris Allocator in the "
169
        "thread will crash. If you want to switch MemTrackerLimiter during thread execution, "
170
        "please use SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER, do not repeat Attach.";
171
172
// The thread context saves some info about a working thread.
173
// 2 required info:
174
//   1. thread_id:   Current thread id, Auto generated.
175
//   2. type(abolished):        The type is a enum value indicating which type of task current thread is running.
176
//                   For example: QUERY, LOAD, COMPACTION, ...
177
//   3. task id:     A unique id to identify this task. maybe query id, load job id, etc.
178
//   4. ThreadMemTrackerMgr
179
//
180
// There may be other optional info to be added later.
181
class ThreadContext {
182
public:
183
3.98k
    ThreadContext() { thread_mem_tracker_mgr = std::make_unique<ThreadMemTrackerMgr>(); }
184
185
3.92k
    ~ThreadContext() = default;
186
187
    void attach_task(const TUniqueId& task_id,
188
                     const std::shared_ptr<MemTrackerLimiter>& mem_tracker,
189
7
                     const std::weak_ptr<WorkloadGroup>& wg_wptr) {
190
        // will only attach_task at the beginning of the thread function, there should be no duplicate attach_task.
191
7
        DCHECK(mem_tracker);
192
        // Orphan is thread default tracker.
193
7
        DCHECK(thread_mem_tracker()->label() == "Orphan")
194
0
                << ", thread mem tracker label: " << thread_mem_tracker()->label()
195
0
                << ", attach mem tracker label: " << mem_tracker->label();
196
7
        _task_id = task_id;
197
7
        _wg_wptr = wg_wptr;
198
7
        thread_mem_tracker_mgr->attach_limiter_tracker(mem_tracker);
199
7
        thread_mem_tracker_mgr->set_query_id(_task_id);
200
7
        thread_mem_tracker_mgr->set_wg_wptr(_wg_wptr);
201
7
        thread_mem_tracker_mgr->enable_wait_gc();
202
7
        thread_mem_tracker_mgr->reset_query_cancelled_flag(false);
203
7
    }
204
205
6
    void detach_task() {
206
6
        _task_id = TUniqueId();
207
6
        _wg_wptr.reset();
208
6
        thread_mem_tracker_mgr->detach_limiter_tracker();
209
6
        thread_mem_tracker_mgr->set_query_id(TUniqueId());
210
6
        thread_mem_tracker_mgr->reset_wg_wptr();
211
6
        thread_mem_tracker_mgr->disable_wait_gc();
212
6
    }
213
214
0
    [[nodiscard]] const TUniqueId& task_id() const { return _task_id; }
215
216
15
    static std::string get_thread_id() {
217
15
        std::stringstream ss;
218
15
        ss << std::this_thread::get_id();
219
15
        return ss.str();
220
15
    }
221
    // Note that if set global Memory Hook, After thread_mem_tracker_mgr is initialized,
222
    // the current thread Hook starts to consume/release mem_tracker.
223
    // the use of shared_ptr will cause a crash. The guess is that there is an
224
    // intermediate state during the copy construction of shared_ptr. Shared_ptr is not equal
225
    // to nullptr, but the object it points to is not initialized. At this time, when the memory
226
    // is released somewhere, the hook is triggered to cause the crash.
227
    std::unique_ptr<ThreadMemTrackerMgr> thread_mem_tracker_mgr;
228
14.5k
    [[nodiscard]] MemTrackerLimiter* thread_mem_tracker() const {
229
14.5k
        return thread_mem_tracker_mgr->limiter_mem_tracker_raw();
230
14.5k
    }
231
232
    QueryThreadContext query_thread_context();
233
234
86
    void consume_memory(const int64_t size) const {
235
86
#ifdef USE_MEM_TRACKER
236
86
        DCHECK(doris::k_doris_exit || !doris::config::enable_memory_orphan_check ||
237
0
               thread_mem_tracker()->label() != "Orphan")
238
0
                << doris::memory_orphan_check_msg;
239
86
#endif
240
86
        thread_mem_tracker_mgr->consume(size, skip_large_memory_check);
241
86
    }
242
243
9
    doris::Status try_reserve_memory(const int64_t size) const {
244
9
#ifdef USE_MEM_TRACKER
245
9
        DCHECK(doris::k_doris_exit || !doris::config::enable_memory_orphan_check ||
246
0
               thread_mem_tracker()->label() != "Orphan")
247
0
                << doris::memory_orphan_check_msg;
248
9
#endif
249
9
        return thread_mem_tracker_mgr->try_reserve(size);
250
9
    }
251
252
2
    void release_reserved_memory() const {
253
2
#ifdef USE_MEM_TRACKER
254
2
        DCHECK(doris::k_doris_exit || !doris::config::enable_memory_orphan_check ||
255
0
               thread_mem_tracker()->label() != "Orphan")
256
0
                << doris::memory_orphan_check_msg;
257
2
#endif
258
2
        thread_mem_tracker_mgr->release_reserved();
259
2
    }
260
261
0
    std::weak_ptr<WorkloadGroup> workload_group() { return _wg_wptr; }
262
263
25.8k
    std::shared_ptr<IOThrottle> get_local_scan_io_throttle(const std::string& data_dir) {
264
25.8k
        if (std::shared_ptr<WorkloadGroup> wg_ptr = _wg_wptr.lock()) {
265
0
            return wg_ptr->get_local_scan_io_throttle(data_dir);
266
0
        }
267
25.8k
        return nullptr;
268
25.8k
    }
269
270
11
    std::shared_ptr<IOThrottle> get_remote_scan_io_throttle() {
271
11
        if (std::shared_ptr<WorkloadGroup> wg_ptr = _wg_wptr.lock()) {
272
0
            return wg_ptr->get_remote_scan_io_throttle();
273
0
        }
274
11
        return nullptr;
275
11
    }
276
277
0
    void update_total_local_scan_io_adder(size_t bytes_read) {
278
0
        if (std::shared_ptr<WorkloadGroup> wg_ptr = _wg_wptr.lock()) {
279
0
            wg_ptr->update_total_local_scan_io_adder(bytes_read);
280
0
        }
281
0
    }
282
283
    int thread_local_handle_count = 0;
284
    int skip_memory_check = 0;
285
    int skip_large_memory_check = 0;
286
287
private:
288
    TUniqueId _task_id;
289
    std::weak_ptr<WorkloadGroup> _wg_wptr;
290
};
291
292
class ThreadLocalHandle {
293
public:
294
121k
    static void create_thread_local_if_not_exits() {
295
121k
        if (bthread_self() == 0) {
296
121k
            if (!pthread_context_ptr_init) {
297
3.91k
                thread_context_ptr = new ThreadContext();
298
3.91k
                pthread_context_ptr_init = true;
299
3.91k
            }
300
121k
            DCHECK(thread_context_ptr != nullptr);
301
121k
            thread_context_ptr->thread_local_handle_count++;
302
121k
        } else {
303
            // Avoid calling bthread_getspecific frequently to get bthread local.
304
            // Very frequent bthread_getspecific will slow, but create_thread_local_if_not_exits is not expected to be much.
305
            // Cache the pointer of bthread local in pthead local.
306
89
            auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
307
89
            if (bthread_context == nullptr) {
308
                // If bthread_context == nullptr:
309
                // 1. First call to bthread_getspecific (and before any bthread_setspecific) returns NULL
310
                // 2. There are not enough reusable btls in btls pool.
311
                // else if bthread_context != nullptr:
312
                // 1. A new bthread starts, but get a reuses btls.
313
59
                bthread_context = new ThreadContext;
314
                // The brpc server should respond as quickly as possible.
315
59
                bthread_context->thread_mem_tracker_mgr->disable_wait_gc();
316
                // set the data so that next time bthread_getspecific in the thread returns the data.
317
59
                CHECK(0 == bthread_setspecific(btls_key, bthread_context) || doris::k_doris_exit);
318
59
            }
319
89
            DCHECK(bthread_context != nullptr);
320
89
            bthread_context->thread_local_handle_count++;
321
89
        }
322
121k
    }
323
324
    // `create_thread_local_if_not_exits` and `del_thread_local_if_count_is_zero` should be used in pairs,
325
    // `del_thread_local_if_count_is_zero` should only be called if `create_thread_local_if_not_exits` returns true
326
121k
    static void del_thread_local_if_count_is_zero() {
327
121k
        if (pthread_context_ptr_init) {
328
            // in pthread
329
121k
            thread_context_ptr->thread_local_handle_count--;
330
121k
            if (thread_context_ptr->thread_local_handle_count == 0) {
331
3.91k
                pthread_context_ptr_init = false;
332
3.91k
                delete doris::thread_context_ptr;
333
3.91k
                thread_context_ptr = nullptr;
334
3.91k
            }
335
121k
        } else if (bthread_self() != 0) {
336
            // in bthread
337
88
            auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
338
88
            DCHECK(bthread_context != nullptr);
339
88
            bthread_context->thread_local_handle_count--;
340
18.4E
        } else {
341
18.4E
            LOG(FATAL) << "__builtin_unreachable";
342
18.4E
            __builtin_unreachable();
343
18.4E
        }
344
121k
    }
345
};
346
347
// must call create_thread_local_if_not_exits() before use thread_context().
348
159k
static ThreadContext* thread_context(bool allow_return_null = false) {
349
159k
    if (pthread_context_ptr_init) {
350
        // in pthread
351
159k
        DCHECK(bthread_self() == 0);
352
159k
        DCHECK(thread_context_ptr != nullptr);
353
159k
        return thread_context_ptr;
354
159k
    }
355
17
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
12
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
12
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
12
        return bthread_context;
361
12
    }
362
5
    if (allow_return_null) {
363
5
        return nullptr;
364
5
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
5
}
Unexecuted instantiation: task_worker_pool_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_util_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bitmapfilter_predicate_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_filter_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: message_body_sink_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: multi_table_pipe_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_sink_file_writer_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: base_compaction_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bitmap_filter_column_predicate_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block_column_predicate_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: compaction_delete_bitmap_calculator_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: compaction_task_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cumulative_compaction_policy_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cumulative_compaction_time_series_policy_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: date_bloom_filter_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delete_bitmap_calculator_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delete_handler_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delta_writer_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_storage_migration_task_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: lru_cache_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_flush_executor_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_memory_limiter_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_sort_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: ordered_data_compaction_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: page_cache_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: path_gc_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: primary_key_index_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: row_cursor_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowid_conversion_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: beta_rowset_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_meta_manager_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_meta_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bitmap_index_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bloom_filter_index_reader_writer_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: encoding_info_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: index_compaction_with_deleted_term.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_array_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_searcher_cache_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: zone_map_index_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segcompaction_mow_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segcompaction_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segment_cache_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: single_compaction_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: storage_engine_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: storage_types_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_cooldown_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_meta_manager_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_meta_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_mgr_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_schema_helper.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: timestamped_version_tracker_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: txn_manager_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_manager_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_reader_writer_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: external_scan_context_mgr_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: thread_mem_tracker_mgr_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: snapshot_loader_test.cpp:_ZN5dorisL14thread_contextEb
run_all_tests.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
2
static ThreadContext* thread_context(bool allow_return_null = false) {
349
2
    if (pthread_context_ptr_init) {
350
        // in pthread
351
2
        DCHECK(bthread_self() == 0);
352
2
        DCHECK(thread_context_ptr != nullptr);
353
2
        return thread_context_ptr;
354
2
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
byte_buffer2_test.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
9
static ThreadContext* thread_context(bool allow_return_null = false) {
349
9
    if (pthread_context_ptr_init) {
350
        // in pthread
351
9
        DCHECK(bthread_self() == 0);
352
9
        DCHECK(thread_context_ptr != nullptr);
353
9
        return thread_context_ptr;
354
9
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
Unexecuted instantiation: key_util_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: agg_replace_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: column_string_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: datetime_round_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: from_string_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_serde_arrow_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_serde_csv_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_serde_mysql_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_serde_text_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_to_string_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delta_writer_v2_pool_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_stub_map_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: parquet_reader_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: parquet_thrift_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vgeneric_iterators_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_sink_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vwal_scanner_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexpr_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_arithmetic_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_aggregation_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_element_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_index_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_size_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_arrays_overlap_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bitmap_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_eq_for_null_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_geo_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_hash_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_ifnull_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_ip_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_json_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_jsonb_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_like_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_math_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_money_format_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_nullif_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_round_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_string_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_test_util.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_time_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_url_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: table_function_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: serialize_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: char_type_padding_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vertical_compaction_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_writer_v2_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partition_transformers_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: arrow_column_to_doris_column_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: task_worker_pool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: odbc_connector.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_active_queries_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_backend_active_tasks.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_catalog_meta_cache_stats_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_file_cache_statistics.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_partitions_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_processlist_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_routine_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_rowsets_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_table_options_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_table_properties_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_user_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_workload_group_privileges.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_workload_group_resource_usage_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_workload_groups_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_workload_sched_policy_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: table_connector.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_info.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_filter.cpp:_ZN5dorisL14thread_contextEb
buffered_reader.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
11
static ThreadContext* thread_context(bool allow_return_null = false) {
349
11
    if (pthread_context_ptr_init) {
350
        // in pthread
351
11
        DCHECK(bthread_self() == 0);
352
11
        DCHECK(thread_context_ptr != nullptr);
353
11
        return thread_context_ptr;
354
11
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
Unexecuted instantiation: file_factory.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hdfs_file_system.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hdfs_file_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: local_file_system.cpp:_ZN5dorisL14thread_contextEb
local_file_reader.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
25.8k
static ThreadContext* thread_context(bool allow_return_null = false) {
349
25.8k
    if (pthread_context_ptr_init) {
350
        // in pthread
351
25.8k
        DCHECK(bthread_self() == 0);
352
25.8k
        DCHECK(thread_context_ptr != nullptr);
353
25.8k
        return thread_context_ptr;
354
25.8k
    }
355
5
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
5
    if (allow_return_null) {
363
5
        return nullptr;
364
5
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
5
}
Unexecuted instantiation: multi_table_pipe.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: s3_file_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: s3_file_bufferpool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load_pipe.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_sink_file_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: base_compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: base_tablet.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block_column_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cumulative_compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cumulative_compaction_policy.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cumulative_compaction_time_series_policy.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_dir.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delete_bitmap_calculator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delete_handler.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delta_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delta_writer_v2.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: match_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_memory_limiter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable_flush_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: memtable.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: merger.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: null_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: olap_server.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cold_data_compaction.cpp:_ZN5dorisL14thread_contextEb
page_cache.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
26.2k
static ThreadContext* thread_context(bool allow_return_null = false) {
349
26.2k
    if (pthread_context_ptr_init) {
350
        // in pthread
351
26.2k
        DCHECK(bthread_self() == 0);
352
26.2k
        DCHECK(thread_context_ptr != nullptr);
353
26.2k
        return thread_context_ptr;
354
26.2k
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
Unexecuted instantiation: partial_update_info.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: primary_key_index.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: row_cursor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: beta_rowset.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: beta_rowset_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: beta_rowset_writer_v2.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_factory.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: beta_rowset_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_meta.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_meta_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segcompaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segment_creator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bitmap_index_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bitmap_index_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bloom_filter_index_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: bloom_filter_index_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: encoding_info.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: indexed_column_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: indexed_column_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_cache.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_compound_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_file_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_file_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_fs_directory.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inverted_index_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: lazy_init_segment_iterator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: ordinal_page_index.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: page_io.cpp:_ZN5dorisL14thread_contextEb
segment.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
93.1k
static ThreadContext* thread_context(bool allow_return_null = false) {
349
93.1k
    if (pthread_context_ptr_init) {
350
        // in pthread
351
93.1k
        DCHECK(bthread_self() == 0);
352
93.1k
        DCHECK(thread_context_ptr != nullptr);
353
93.1k
        return thread_context_ptr;
354
93.1k
    }
355
12
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
12
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
12
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
12
        return bthread_context;
361
12
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
Unexecuted instantiation: column_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: empty_segment_iterator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hierarchical_data_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segment_iterator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segment_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: column_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vertical_segment_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: zone_map_index.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vertical_beta_rowset_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowset_builder.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: calc_delete_bitmap_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: segment_loader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: single_replica_compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: snapshot_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: storage_engine.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: full_compaction.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_meta.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_meta_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: like_column_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_schema.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_column_object_pool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_schema_cache.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_alter_tablet_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_change.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_batch_load_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: push_handler.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_checksum_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_clone_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_index_change_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_publish_version_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: engine_storage_migration_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: index_builder.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: txn_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: types.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: version_graph.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_table.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wrapper_field.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exec_env.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exec_env_init.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: external_scan_context_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: fragment_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: group_commit_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_channel_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_channel.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_writer.cpp:_ZN5dorisL14thread_contextEb
global_memory_arbitrator.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
29
static ThreadContext* thread_context(bool allow_return_null = false) {
349
29
    if (pthread_context_ptr_init) {
350
        // in pthread
351
29
        DCHECK(bthread_self() == 0);
352
29
        DCHECK(thread_context_ptr != nullptr);
353
29
        return thread_context_ptr;
354
29
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
mem_tracker.cpp:_ZN5dorisL14thread_contextEb
Line
Count
Source
348
14.4k
static ThreadContext* thread_context(bool allow_return_null = false) {
349
14.4k
    if (pthread_context_ptr_init) {
350
        // in pthread
351
14.4k
        DCHECK(bthread_self() == 0);
352
14.4k
        DCHECK(thread_context_ptr != nullptr);
353
14.4k
        return thread_context_ptr;
354
14.4k
    }
355
0
    if (bthread_self() != 0) {
356
        // in bthread
357
        // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
358
0
        auto* bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
359
0
        DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0);
360
0
        return bthread_context;
361
0
    }
362
0
    if (allow_return_null) {
363
0
        return nullptr;
364
0
    }
365
    // It means that use thread_context() but this thread not attached a query/load using SCOPED_ATTACH_TASK macro.
366
0
    LOG(FATAL) << "__builtin_unreachable, " << doris::memory_orphan_check_msg;
367
0
    __builtin_unreachable();
368
0
}
Unexecuted instantiation: mem_tracker_limiter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: thread_mem_tracker_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: message_body_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: plan_fragment_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exec_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: query_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: buffer_control_block.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: routine_load_task_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_consumer_pool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_consumer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_consumer_group.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_filter_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_scanner_helper.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_state.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: snapshot_loader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablets_channel.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: workload_group.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: workload_group_manager.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: workload_sched_policy_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: http_service.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: internal_service.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: fold_constant_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: point_query_executor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: row_batch.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block_compression.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: obj_lru_cache.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: s3_util.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: thread.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: thrift_util.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: calc_file_crc_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: check_tablet_segment_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: compaction_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: download_binlog_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: file_cache_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: http_stream.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: meta_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pad_rowset_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline_task_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: report_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: show_nested_index_file_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: stream_load_2pc.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablet_migration_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablets_distribution_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: tablets_info_action.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: utils.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_group_array_intersect.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_approx_count_distinct.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_map.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_window.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregate_function_window_funnel.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: column_nullable.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: column_object.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: allocator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_util.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block_spill_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_factory.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_object.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_nullable_serde.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_type_object_serde.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: distinct_vaggregation_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: avro_jni_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: column_type_convert.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: csv_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_plain_binary_line_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_json_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vorc_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: parquet_column_convert.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vparquet_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: file_meta_cache.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vparquet_group_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vparquet_column_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vhash_join_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: inner_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: left_semi_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: left_anti_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: left_outer_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: full_outer_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: right_outer_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: cross_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: right_semi_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: right_anti_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: null_aware_left_anti_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: null_aware_left_semi_join_impl.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vjoin_node_base.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vnested_loop_join_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: group_commit_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_filter_consumer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_es_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_es_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_file_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_jdbc_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_jdbc_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_odbc_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_odbc_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_olap_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: parallel_scanner_builder.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: new_olap_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_cache.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: scanner_scheduler.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: scanner_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: split_source_connector.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vfile_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: max_compute_jni_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: paimon_jni_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hudi_jni_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: iceberg_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: table_format_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: equality_delete.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: paimon_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: transactional_hive_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: wal_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: arrow_stream_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: arrow_pip_input_stream.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmeta_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmeta_scanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vscan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vscanner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vaggregation_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vanalytic_eval_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vassert_num_rows_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vdata_gen_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexchange_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vsort_exec_exprs.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vjdbc_connector.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vpartition_sort_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partition_sorter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: sorter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vrepeat_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vschema_scan_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vselect_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vset_operation_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vsort_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: runtime_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: heap_sorter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: topn_sorter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtable_function_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vunion_node.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: table_function_factory.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_bitmap.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_json_array.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_json_object.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_map.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_numbers.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexplode_split.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vbitmap_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vbloom_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vcast_expr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vectorized_agg_fn.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vectorized_fn_call.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexpr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: varray_literal.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: varray_map_function.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: varray_filter_function.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vcase_expr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vexpr_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vin_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vinfo_func.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vliteral.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmap_literal.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmatch_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vruntimefilter_wrapper.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vslot_ref.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vstruct_literal.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtuple_is_null_predicate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_register.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_exists.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_element.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_index.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_aggregation.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_distance.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_distinct.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_except.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_intersect.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_difference.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_enumerate.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_enumerate_uniq.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_range.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_compact.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_popback.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_popfront.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_constructor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_apply.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_concat.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_pushfront.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_pushback.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_first_or_last_index.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_cum_sum.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_count.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_filter.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_remove.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_shuffle.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_slice.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_sort.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_sortby.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_split.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_union.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_with_constant.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_array_zip.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_arrays_overlap.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: comparison.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: comparison_equal_for_null.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: comparison_equals.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: comparison_greater.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: comparison_less.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: divide.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bit.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bit_count.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bit_shift.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bit_test.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bitmap.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_bitmap_variadic.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_case.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_cast.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_coalesce.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_collection_in.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_conv.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_convert_tz.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_date_or_datetime_computation.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_date_or_datetime_computation_v2.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_date_or_datetime_to_string.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_datetime_floor_ceil.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_datetime_string_to_string.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_encryption.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_fake.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_grouping.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_hash.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_helpers.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_hex.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_hll.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_ifnull.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_ignore.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_ip.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_java_udf.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_json.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_jsonb.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_map.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_multi_match.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_nullables.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_quantile_state.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_regexp.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_rpc.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_size.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_string.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_struct.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_struct_element.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_time_value_to_field.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_timestamp.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_tokenize.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_utility.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_uuid.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_variant_element.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_width_bucket.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: functions_geo.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: functions_logical.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: functions_multi_string_position.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: functions_multi_string_search.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: if.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: in.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: int_div.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: is_not_null.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: is_null.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: least_greast.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: like.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: match.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: math.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: minus.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: modulo.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: multiply.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: nullif.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: plus.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: random.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: round.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: time_of_function.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: to_time_function.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: function_url.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: uuid.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: uuid_numeric.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: parse2column.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: serialize.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: block_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: olap_data_convertor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vcollect_iterator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vertical_block_reader.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vertical_merge_iterator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vgeneric_iterators.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: shared_hash_table_controller.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vdata_stream_mgr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vdata_stream_recvr.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vsorted_run_merger.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: delta_writer_v2_pool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: group_commit_block_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_map_pool.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: load_stream_stub.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vdata_stream_sender.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partitioner.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vhive_table_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: viceberg_table_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmemory_scratch_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: volap_table_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: volap_table_sink_v2.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vresult_file_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vresult_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: varrow_flight_result_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: rowid_fetcher.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vrow_distribution.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_block_convertor.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_finder.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: async_result_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partition_transformers.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: viceberg_table_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: viceberg_partition_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vparquet_transformer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vorc_transformer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vfile_result_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vcsv_transformer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vhive_table_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vhive_partition_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vjdbc_table_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vmysql_table_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vodbc_table_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vtablet_writer_v2.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: vwal_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: spill_stream.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: spill_writer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: es_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exchange_sink_buffer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exchange_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hashjoin_probe_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: join_probe_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: multi_cast_data_streamer.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: nested_loop_join_probe_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: olap_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partitioned_hash_join_probe_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hashjoin_build_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: join_build_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: nested_loop_join_build_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partitioned_hash_join_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: file_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: jdbc_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: meta_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline_fragment_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: mysql_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: schema_scan_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: exchange_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: empty_set_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: datagen_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: data_queue.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: union_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: union_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: distinct_streaming_aggregation_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: distinct_streaming_aggregation_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: streaming_aggregation_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: streaming_aggregation_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregation_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: aggregation_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: sort_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: sort_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partition_sort_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partition_sort_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: analytic_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: analytic_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: repeat_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: assert_num_rows_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: table_function_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: empty_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: set_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: set_probe_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: set_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: select_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: result_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: olap_table_sink_v2_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: olap_table_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: hive_table_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: iceberg_table_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: result_file_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: multi_cast_data_stream_sink.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: multi_cast_data_stream_source.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: dependency.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: spill_sort_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: local_exchange_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partitioned_aggregation_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: spill_sort_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: partitioned_aggregation_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: local_exchange_source_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: jdbc_table_sink_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: streaming_aggregation_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: distinct_streaming_aggregation_operator.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline_x_fragment_context.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: local_exchanger.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: pipeline_x_task.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: task_queue.cpp:_ZN5dorisL14thread_contextEb
Unexecuted instantiation: task_scheduler.cpp:_ZN5dorisL14thread_contextEb
369
370
class QueryThreadContext {
371
public:
372
78
    QueryThreadContext() = default;
373
    QueryThreadContext(const TUniqueId& query_id,
374
                       const std::shared_ptr<MemTrackerLimiter>& mem_tracker,
375
                       const std::weak_ptr<WorkloadGroup>& wg_wptr)
376
0
            : query_id(query_id), query_mem_tracker(mem_tracker), wg_wptr(wg_wptr) {}
377
    // If use WorkloadGroup and can get WorkloadGroup ptr, must as a parameter.
378
    QueryThreadContext(const TUniqueId& query_id,
379
                       const std::shared_ptr<MemTrackerLimiter>& mem_tracker)
380
14
            : query_id(query_id), query_mem_tracker(mem_tracker) {}
381
382
37
    void init() {
383
#ifndef BE_TEST
384
        ORPHAN_TRACKER_CHECK();
385
        query_id = doris::thread_context()->task_id();
386
        query_mem_tracker = doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker();
387
        wg_wptr = doris::thread_context()->workload_group();
388
#else
389
37
        query_id = TUniqueId();
390
37
        query_mem_tracker = doris::ExecEnv::GetInstance()->orphan_mem_tracker();
391
37
#endif
392
37
    }
393
394
    TUniqueId query_id;
395
    std::shared_ptr<MemTrackerLimiter> query_mem_tracker;
396
    std::weak_ptr<WorkloadGroup> wg_wptr;
397
};
398
399
class ScopeMemCountByHook {
400
public:
401
0
    explicit ScopeMemCountByHook(int64_t* scope_mem) {
402
0
        ThreadLocalHandle::create_thread_local_if_not_exits();
403
0
        _scope_mem = scope_mem;
404
0
        thread_context()->thread_mem_tracker_mgr->start_count_scope_mem();
405
0
        use_mem_hook = true;
406
0
    }
407
408
0
    ~ScopeMemCountByHook() {
409
0
        use_mem_hook = false;
410
0
        *_scope_mem += thread_context()->thread_mem_tracker_mgr->stop_count_scope_mem();
411
0
        ThreadLocalHandle::del_thread_local_if_count_is_zero();
412
0
    }
413
414
private:
415
    int64_t* _scope_mem = nullptr;
416
};
417
418
// only hold thread context in scope.
419
class ScopedInitThreadContext {
420
public:
421
71.3k
    explicit ScopedInitThreadContext() { ThreadLocalHandle::create_thread_local_if_not_exits(); }
422
423
71.3k
    ~ScopedInitThreadContext() { ThreadLocalHandle::del_thread_local_if_count_is_zero(); }
424
};
425
426
class AttachTask {
427
public:
428
    // not query or load, initialize with memory tracker, empty query id and default normal workload group.
429
    explicit AttachTask(const std::shared_ptr<MemTrackerLimiter>& mem_tracker);
430
431
    // is query or load, initialize with memory tracker, query id and workload group wptr.
432
    explicit AttachTask(RuntimeState* runtime_state);
433
434
    explicit AttachTask(QueryContext* query_ctx);
435
436
    explicit AttachTask(const QueryThreadContext& query_thread_context);
437
438
    void init(const QueryThreadContext& query_thread_context);
439
440
    ~AttachTask();
441
};
442
443
class SwitchThreadMemTrackerLimiter {
444
public:
445
    explicit SwitchThreadMemTrackerLimiter(
446
0
            const std::shared_ptr<doris::MemTrackerLimiter>& mem_tracker) {
447
0
        DCHECK(mem_tracker);
448
0
        doris::ThreadLocalHandle::create_thread_local_if_not_exits();
449
0
        if (mem_tracker != thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()) {
450
0
            _old_mem_tracker = thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker();
451
0
            thread_context()->thread_mem_tracker_mgr->attach_limiter_tracker(mem_tracker);
452
0
        }
453
0
    }
454
455
0
    explicit SwitchThreadMemTrackerLimiter(const doris::QueryThreadContext& query_thread_context) {
456
0
        doris::ThreadLocalHandle::create_thread_local_if_not_exits();
457
0
        DCHECK(thread_context()->task_id() ==
458
0
               query_thread_context.query_id); // workload group alse not change
459
0
        DCHECK(query_thread_context.query_mem_tracker);
460
0
        if (query_thread_context.query_mem_tracker !=
461
0
            thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()) {
462
0
            _old_mem_tracker = thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker();
463
0
            thread_context()->thread_mem_tracker_mgr->attach_limiter_tracker(
464
0
                    query_thread_context.query_mem_tracker);
465
0
        }
466
0
    }
467
468
0
    ~SwitchThreadMemTrackerLimiter() {
469
0
        if (_old_mem_tracker != nullptr) {
470
0
            thread_context()->thread_mem_tracker_mgr->detach_limiter_tracker(_old_mem_tracker);
471
0
        }
472
0
        doris::ThreadLocalHandle::del_thread_local_if_count_is_zero();
473
0
    }
474
475
private:
476
    std::shared_ptr<doris::MemTrackerLimiter> _old_mem_tracker {nullptr};
477
};
478
479
class AddThreadMemTrackerConsumer {
480
public:
481
    // The owner and user of MemTracker are in the same thread, and the raw pointer is faster.
482
    // If mem_tracker is nullptr, do nothing.
483
    explicit AddThreadMemTrackerConsumer(MemTracker* mem_tracker);
484
485
    // The owner and user of MemTracker are in different threads. If mem_tracker is nullptr, do nothing.
486
    explicit AddThreadMemTrackerConsumer(const std::shared_ptr<MemTracker>& mem_tracker);
487
488
    ~AddThreadMemTrackerConsumer();
489
490
private:
491
    std::shared_ptr<MemTracker> _mem_tracker; // Avoid mem_tracker being released midway.
492
    bool _need_pop = false;
493
};
494
495
class AddThreadMemTrackerConsumerByHook {
496
public:
497
    explicit AddThreadMemTrackerConsumerByHook(const std::shared_ptr<MemTracker>& mem_tracker);
498
    ~AddThreadMemTrackerConsumerByHook();
499
500
private:
501
    std::shared_ptr<MemTracker> _mem_tracker;
502
};
503
504
class ScopeSkipMemoryCheck {
505
public:
506
46.5k
    explicit ScopeSkipMemoryCheck() {
507
46.5k
        ThreadLocalHandle::create_thread_local_if_not_exits();
508
46.5k
        doris::thread_context()->skip_memory_check++;
509
46.5k
    }
510
511
46.5k
    ~ScopeSkipMemoryCheck() {
512
46.5k
        doris::thread_context()->skip_memory_check--;
513
46.5k
        ThreadLocalHandle::del_thread_local_if_count_is_zero();
514
46.5k
    }
515
};
516
517
// Basic macros for mem tracker, usually do not need to be modified and used.
518
#if defined(USE_MEM_TRACKER) && !defined(BE_TEST)
519
// used to fix the tracking accuracy of caches.
520
#define THREAD_MEM_TRACKER_TRANSFER_TO(size, tracker)                                            \
521
    do {                                                                                         \
522
        ORPHAN_TRACKER_CHECK();                                                                  \
523
        doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker_raw()->transfer_to( \
524
                size, tracker);                                                                  \
525
    } while (0)
526
527
#define THREAD_MEM_TRACKER_TRANSFER_FROM(size, tracker)                                            \
528
    do {                                                                                           \
529
        ORPHAN_TRACKER_CHECK();                                                                    \
530
        tracker->transfer_to(                                                                      \
531
                size, doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker_raw()); \
532
    } while (0)
533
534
// Mem Hook to consume thread mem tracker
535
#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size)           \
536
    do {                                                   \
537
        if (doris::use_mem_hook) {                         \
538
            doris::thread_context()->consume_memory(size); \
539
        }                                                  \
540
    } while (0)
541
#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size) CONSUME_THREAD_MEM_TRACKER_BY_HOOK(-size)
542
#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...)           \
543
    do {                                                                   \
544
        if (doris::use_mem_hook) {                                         \
545
            doris::thread_context()->consume_memory(size_fn(__VA_ARGS__)); \
546
        }                                                                  \
547
    } while (0)
548
#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...)            \
549
    do {                                                                    \
550
        if (doris::use_mem_hook) {                                          \
551
            doris::thread_context()->consume_memory(-size_fn(__VA_ARGS__)); \
552
        }                                                                   \
553
    } while (0)
554
555
// if use mem hook, avoid repeated consume.
556
// must call create_thread_local_if_not_exits() before use thread_context().
557
#define CONSUME_THREAD_MEM_TRACKER(size)                                                           \
558
    do {                                                                                           \
559
        if (size == 0 || doris::use_mem_hook) {                                                    \
560
            break;                                                                                 \
561
        }                                                                                          \
562
        if (doris::pthread_context_ptr_init) {                                                     \
563
            DCHECK(bthread_self() == 0);                                                           \
564
            doris::thread_context_ptr->consume_memory(size);                                       \
565
        } else if (bthread_self() != 0) {                                                          \
566
            static_cast<doris::ThreadContext*>(bthread_getspecific(doris::btls_key))               \
567
                    ->consume_memory(size);                                                        \
568
        } else if (doris::ExecEnv::ready()) {                                                      \
569
            MEMORY_ORPHAN_CHECK();                                                                 \
570
            doris::ExecEnv::GetInstance()->orphan_mem_tracker_raw()->consume_no_update_peak(size); \
571
        }                                                                                          \
572
    } while (0)
573
#define RELEASE_THREAD_MEM_TRACKER(size) CONSUME_THREAD_MEM_TRACKER(-size)
574
575
#else
576
#define THREAD_MEM_TRACKER_TRANSFER_TO(size, tracker) (void)0
577
#define THREAD_MEM_TRACKER_TRANSFER_FROM(size, tracker) (void)0
578
#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK(size) (void)0
579
#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK(size) (void)0
580
#define CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...) (void)0
581
#define RELEASE_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(size_fn, ...) (void)0
582
214k
#define CONSUME_THREAD_MEM_TRACKER(size) (void)0
583
193k
#define RELEASE_THREAD_MEM_TRACKER(size) (void)0
584
#endif
585
} // namespace doris