xinyiZzz commented on code in PR #9145:
URL: https://github.com/apache/incubator-doris/pull/9145#discussion_r857127705


##########
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()) {
+        _mem_trackers[mem_tracker->id()] = mem_tracker;
+        DCHECK(_mem_trackers[mem_tracker->id()]) << print_debug_string();
+        _untracked_mems[mem_tracker->id()] = 0;
+        _mem_tracker_labels[_temp_tracker_id] = mem_tracker->label();

Review Comment:
   A reusable variable, Avoid memory allocation in functions and fall into an 
infinite loop. Has annotations.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to