xinyiZzz commented on code in PR #9145:
URL: https://github.com/apache/incubator-doris/pull/9145#discussion_r857122781
##########
be/src/runtime/thread_mem_tracker_mgr.h:
##########
@@ -227,21 +253,36 @@ inline void ThreadMemTrackerMgr::cache_consume(int64_t
size) {
_untracked_mem += _untracked_mems[_tracker_id];
_untracked_mems[_tracker_id] = 0;
}
- noncache_consume();
+ noncache_consume(_untracked_mem);
+ _untracked_mem = 0;
start_thread_mem_tracker = true;
}
}
-inline void ThreadMemTrackerMgr::noncache_consume() {
- DCHECK(_mem_trackers[_tracker_id]) << ", label: " <<
_mem_tracker_labels[_tracker_id];
- Status st = mem_tracker()->try_consume(_untracked_mem);
+inline void ThreadMemTrackerMgr::noncache_consume(int64_t size) {
+ Status st = mem_tracker()->try_consume(size);
if (!st) {
// The memory has been allocated, so when TryConsume fails, need to
continue to complete
// the consume to ensure the accuracy of the statistics.
- mem_tracker()->consume(_untracked_mem);
- exceeded(_untracked_mem, st);
+ mem_tracker()->consume(size);
+ exceeded(size, st);
}
- _untracked_mem = 0;
+}
+
+inline void ThreadMemTrackerMgr::add_tracker(const
std::shared_ptr<MemTracker>& mem_tracker) {
+ DCHECK(_mem_trackers.find(mem_tracker->id()) == _mem_trackers.end()) <<
print_debug_string();
+ if (_mem_trackers.find(mem_tracker->id()) == _mem_trackers.end()) {
Review Comment:
OK, I'll remove `find` first.
But this is intentional. Because duplication of `add tracker` in some places
may be unavoidable.
(Not currently, future prs will include this, but I'll try to avoid it)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]