This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
new 3198e1634e fix transfer to tracker (#12932) (#12951)
3198e1634e is described below
commit 3198e1634e27682b627b025fd79b4dbe0e47a31e
Author: Xinyi Zou <[email protected]>
AuthorDate: Sun Sep 25 10:53:39 2022 +0800
fix transfer to tracker (#12932) (#12951)
~MemTrackerLimiter() repeated consumption of _untracked_mem, resulting in
inaccurate process mem tracker.
---
be/src/runtime/memory/mem_tracker_limiter.cpp | 24 ++++++++++++++----------
be/src/runtime/memory/thread_mem_tracker_mgr.h | 1 +
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/be/src/runtime/memory/mem_tracker_limiter.cpp
b/be/src/runtime/memory/mem_tracker_limiter.cpp
index aaba7c6b19..aa2f207b16 100644
--- a/be/src/runtime/memory/mem_tracker_limiter.cpp
+++ b/be/src/runtime/memory/mem_tracker_limiter.cpp
@@ -75,20 +75,24 @@ MemTrackerLimiter::~MemTrackerLimiter() {
// TCMalloc hook will be triggered during destructor memtracker, may cause
crash.
if (_label == "Process") doris::thread_context_ptr._init = false;
DCHECK(remain_child_count() == 0 || _label == "Process");
- consume(_untracked_mem.exchange(0));
-#ifndef BE_TEST
// In order to ensure `consumption of all limiter trackers` + `orphan
tracker consumption` = `process tracker consumption`
- // in real time. Merge its consumption into orphan when all third level
limiter trackers are destructed, to avoid repetition.
- // the first layer: process;
- // the second layer: a tracker that will not be destructed globally
(query/load pool, load channel mgr, etc.);
- // the third layer: a query/load/compaction task generates a tracker
(query tracker, load channel tracker, etc.).
- if ((_parent && _parent->label() == "Process") ||
- (_parent->parent() && _parent->parent()->label() == "Process")) {
+ // in real time. Merge its consumption into orphan when parent is process,
to avoid repetition.
+ if ((_parent && _parent->label() == "Process")) {
ExecEnv::GetInstance()->orphan_mem_tracker_raw()->cache_consume_local(
_consumption->current_value());
}
-#endif
- if (_reset_zero) cache_consume_local(-_consumption->current_value());
+ if (_reset_zero) {
+ ExecEnv::GetInstance()->orphan_mem_tracker_raw()->cache_consume_local(
+ _consumption->current_value());
+ cache_consume_local(-_consumption->current_value());
+ _all_ancestors.clear();
+
_all_ancestors.push_back(ExecEnv::GetInstance()->orphan_mem_tracker_raw());
+ }
+ for (auto& tracker : _all_ancestors) {
+ if (tracker->label() != "Process") {
+ tracker->_consumption->add(_untracked_mem);
+ }
+ }
if (_parent) {
std::lock_guard<std::mutex> l(_parent->_child_tracker_limiter_lock);
if (_child_tracker_it != _parent->_child_tracker_limiters.end()) {
diff --git a/be/src/runtime/memory/thread_mem_tracker_mgr.h
b/be/src/runtime/memory/thread_mem_tracker_mgr.h
index 2736ff9630..14e9beef40 100644
--- a/be/src/runtime/memory/thread_mem_tracker_mgr.h
+++ b/be/src/runtime/memory/thread_mem_tracker_mgr.h
@@ -46,6 +46,7 @@ public:
~ThreadMemTrackerMgr() {
flush_untracked_mem<false>();
DCHECK(_consumer_tracker_stack.empty());
+ DCHECK(_limiter_tracker_stack.size() == 1);
}
// only for tcmalloc hook
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]