This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 80e1f401f0 [enhancement](memory) Fix `USE_MEM_TRACKER=OFF` compile
(#13085)
80e1f401f0 is described below
commit 80e1f401f08bbf4603436eb0b942f4697c309939
Author: Xinyi Zou <[email protected]>
AuthorDate: Wed Oct 5 12:10:49 2022 +0800
[enhancement](memory) Fix `USE_MEM_TRACKER=OFF` compile (#13085)
---
be/src/runtime/thread_context.cpp | 14 --------------
be/src/runtime/thread_context.h | 20 +++++++++++++++++---
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/be/src/runtime/thread_context.cpp
b/be/src/runtime/thread_context.cpp
index cc11c1b29b..4a02c45560 100644
--- a/be/src/runtime/thread_context.cpp
+++ b/be/src/runtime/thread_context.cpp
@@ -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
diff --git a/be/src/runtime/thread_context.h b/be/src/runtime/thread_context.h
index fbfac1be59..26030ee2e6 100644
--- a/be/src/runtime/thread_context.h
+++ b/be/src/runtime/thread_context.h
@@ -29,6 +29,7 @@
#include "runtime/memory/thread_mem_tracker_mgr.h"
#include "runtime/threadlocal.h"
+#ifdef USE_MEM_TRACKER
// Add thread mem tracker consumer during query execution.
#define SCOPED_CONSUME_MEM_TRACKER(mem_tracker) \
auto VARNAME_LINENUM(add_mem_consumer) =
doris::AddThreadMemTrackerConsumer(mem_tracker)
@@ -38,6 +39,11 @@
auto VARNAME_LINENUM(attach_task) = AttachTask(arg1, ##__VA_ARGS__)
#define SCOPED_SWITCH_BTHREAD_TLS() auto VARNAME_LINENUM(switch_bthread) =
SwitchBthread()
+#else
+#define SCOPED_CONSUME_MEM_TRACKER(mem_tracker) (void)0
+#define SCOPED_ATTACH_TASK(arg1, ...) (void)0
+#define SCOPED_SWITCH_BTHREAD_TLS() (void)0
+#endif
namespace doris {
@@ -229,9 +235,7 @@ public:
~SwitchBthread();
private:
-#ifdef USE_MEM_TRACKER
ThreadContext* _bthread_context;
-#endif
};
class StopCheckThreadMemTrackerLimit {
@@ -246,6 +250,7 @@ public:
};
// The following macros are used to fix the tracking accuracy of caches etc.
+#ifdef USE_MEM_TRACKER
#define STOP_CHECK_THREAD_MEM_TRACKER_LIMIT() \
auto VARNAME_LINENUM(stop_check_limit) = StopCheckThreadMemTrackerLimit()
#define CONSUME_THREAD_MEM_TRACKER(size) \
@@ -293,5 +298,14 @@ public:
doris::ThreadMemTrackerMgr::consume_no_attach(-size);
\
}
\
} while (0)
-
+#else
+#define STOP_CHECK_THREAD_MEM_TRACKER_LIMIT() (void)0
+#define CONSUME_THREAD_MEM_TRACKER(size) (void)0
+#define RELEASE_THREAD_MEM_TRACKER(size) (void)0
+#define THREAD_MEM_TRACKER_TRANSFER_TO(size, tracker) (void)0
+#define THREAD_MEM_TRACKER_TRANSFER_FROM(size, tracker) (void)0
+#define RETURN_LIMIT_EXCEEDED(state, msg, ...) (void)0
+#define MEM_MALLOC_HOOK(size) (void)0
+#define MEM_FREE_HOOK(size) (void)0
+#endif
} // namespace doris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]