[enhancement](memory) Fix USE_MEM_TRACKER=OFF compile (#13085)

This commit is contained in:
Xinyi Zou
2022-10-05 12:10:49 +08:00
committed by GitHub
parent 4a0b4f1836
commit 80e1f401f0
2 changed files with 17 additions and 17 deletions

View File

@ -33,9 +33,7 @@ AttachTask::AttachTask(const std::shared_ptr<MemTrackerLimiter>& mem_tracker,
const ThreadContext::TaskType& type, const std::string& task_id,
const TUniqueId& fragment_instance_id) {
DCHECK(mem_tracker);
#ifdef USE_MEM_TRACKER
thread_context()->attach_task(type, task_id, fragment_instance_id, mem_tracker);
#endif
}
AttachTask::AttachTask(RuntimeState* runtime_state) {
@ -44,43 +42,34 @@ AttachTask::AttachTask(RuntimeState* runtime_state) {
DCHECK(runtime_state->fragment_instance_id() != TUniqueId());
#endif // BE_TEST
DCHECK(runtime_state->instance_mem_tracker());
#ifdef USE_MEM_TRACKER
thread_context()->attach_task(
query_to_task_type(runtime_state->query_type()), print_id(runtime_state->query_id()),
runtime_state->fragment_instance_id(), runtime_state->instance_mem_tracker());
#endif // USE_MEM_TRACKER
}
AttachTask::~AttachTask() {
#ifdef USE_MEM_TRACKER
thread_context()->detach_task();
#ifndef NDEBUG
DorisMetrics::instance()->attach_task_thread_count->increment(1);
#endif // NDEBUG
#endif
}
AddThreadMemTrackerConsumer::AddThreadMemTrackerConsumer(MemTracker* mem_tracker) {
#ifdef USE_MEM_TRACKER
if (config::memory_verbose_track) {
thread_context()->_thread_mem_tracker_mgr->push_consumer_tracker(mem_tracker);
}
#endif // USE_MEM_TRACKER
}
AddThreadMemTrackerConsumer::~AddThreadMemTrackerConsumer() {
#ifdef USE_MEM_TRACKER
if (config::memory_verbose_track) {
#ifndef NDEBUG
DorisMetrics::instance()->add_thread_mem_tracker_consumer_count->increment(1);
#endif // NDEBUG
thread_context()->_thread_mem_tracker_mgr->pop_consumer_tracker();
}
#endif // USE_MEM_TRACKER
}
SwitchBthread::SwitchBthread() {
#ifdef USE_MEM_TRACKER
_bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
// First call to bthread_getspecific (and before any bthread_setspecific) returns NULL
if (_bthread_context == nullptr) {
@ -96,11 +85,9 @@ SwitchBthread::SwitchBthread() {
_bthread_context->set_type(ThreadContext::TaskType::BRPC);
bthread_context_key = btls_key;
bthread_context = _bthread_context;
#endif
}
SwitchBthread::~SwitchBthread() {
#ifdef USE_MEM_TRACKER
DCHECK(_bthread_context != nullptr);
_bthread_context->_thread_mem_tracker_mgr->flush_untracked_mem<false>();
_bthread_context->_thread_mem_tracker_mgr->init();
@ -110,7 +97,6 @@ SwitchBthread::~SwitchBthread() {
#ifndef NDEBUG
DorisMetrics::instance()->switch_bthread_count->increment(1);
#endif // NDEBUG
#endif // USE_MEM_TRACKER
}
} // namespace doris