xinyiZzz commented on code in PR #40542:
URL: https://github.com/apache/doris/pull/40542#discussion_r1756905128


##########
be/src/runtime/memory/mem_tracker.cpp:
##########
@@ -20,95 +20,41 @@
 
 #include "runtime/memory/mem_tracker.h"
 
+#include <bvar/reducer.h>
 #include <fmt/format.h>
 
 #include <mutex>
 
-#include "bvar/bvar.h"
-#include "runtime/memory/mem_tracker_limiter.h"
-#include "runtime/thread_context.h"
-
 namespace doris {
 
+constexpr size_t MEM_TRACKERS_GROUP_NUM = 1000;
 bvar::Adder<int64_t> g_memtracker_cnt("memtracker_cnt");
 
-// Save all MemTrackers in use to maintain the weak relationship between 
MemTracker and MemTrackerLimiter.
-// When MemTrackerLimiter prints statistics, all MemTracker statistics with 
weak relationship will be printed together.
-// Each group corresponds to several MemTrackerLimiters and has a lock.
-// Multiple groups are used to reduce the impact of locks.
-std::vector<MemTracker::TrackerGroup> MemTracker::mem_tracker_pool(1000);
+std::vector<MemTracker::TrackersGroup> 
MemTracker::mem_tracker_pool(MEM_TRACKERS_GROUP_NUM);
 
-MemTracker::MemTracker(const std::string& label, MemTrackerLimiter* parent) : 
_label(label) {
-    _consumption = std::make_shared<MemCounter>();
-    bind_parent(parent);
+MemTracker::MemTracker() {
+    g_memtracker_cnt << 1;
 }
 
-void MemTracker::bind_parent(MemTrackerLimiter* parent) {
-    if (parent) {
-        _type = parent->type();
-        _parent_label = parent->label();
-        _parent_group_num = parent->group_num();
-    } else {
-        _type = thread_context()->thread_mem_tracker()->type();
-        _parent_label = thread_context()->thread_mem_tracker()->label();
-        _parent_group_num = 
thread_context()->thread_mem_tracker()->group_num();
-    }
+MemTracker::MemTracker(const std::string& label) : MemTracker() {
+    _label = label;
+    _group_num = random() % MEM_TRACKERS_GROUP_NUM;

Review Comment:
   done



-- 
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