This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new d319dafb5c2 [pick](branch-2.1) pick #41123  (#42541)
d319dafb5c2 is described below

commit d319dafb5c25d1fa54096ff28c28c62fd1c6f9d1
Author: Xinyi Zou <zouxiny...@gmail.com>
AuthorDate: Mon Oct 28 19:21:19 2024 +0800

    [pick](branch-2.1) pick #41123  (#42541)
    
    cgroup memory usage should be refreshed frequently.
---
 be/src/util/mem_info.cpp | 55 +++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/be/src/util/mem_info.cpp b/be/src/util/mem_info.cpp
index 8be1db5cb85..b820234e712 100644
--- a/be/src/util/mem_info.cpp
+++ b/be/src/util/mem_info.cpp
@@ -189,40 +189,37 @@ void MemInfo::refresh_proc_meminfo() {
     }
 
     // refresh cgroup memory
-    if (_s_cgroup_mem_refresh_wait_times >= 0 && 
config::enable_use_cgroup_memory_info) {
-        int64_t cgroup_mem_limit = -1;
-        int64_t cgroup_mem_usage = -1;
-        std::string cgroup_mem_info_file_path;
-        _s_cgroup_mem_refresh_state = true;
-        Status status = 
CGroupMemoryCtl::find_cgroup_mem_limit(&cgroup_mem_limit);
-        if (!status.ok()) {
-            _s_cgroup_mem_refresh_state = false;
-        }
-        status = CGroupMemoryCtl::find_cgroup_mem_usage(&cgroup_mem_usage);
-        if (!status.ok()) {
-            _s_cgroup_mem_refresh_state = false;
-        }
-
-        if (_s_cgroup_mem_refresh_state) {
-            _s_cgroup_mem_limit = cgroup_mem_limit;
-            _s_cgroup_mem_usage = cgroup_mem_usage;
-            // wait 10s, 100 * 100ms, avoid too frequently.
-            _s_cgroup_mem_refresh_wait_times = -100;
-            LOG(INFO) << "Refresh cgroup memory win, refresh again after 10s, 
cgroup mem limit: "
-                      << _s_cgroup_mem_limit << ", cgroup mem usage: " << 
_s_cgroup_mem_usage;
+    if (config::enable_use_cgroup_memory_info) {
+        if (_s_cgroup_mem_refresh_wait_times >= 0) {
+            auto status = 
CGroupMemoryCtl::find_cgroup_mem_limit(&_s_cgroup_mem_limit);
+            if (!status.ok()) {
+                _s_cgroup_mem_limit = std::numeric_limits<int64_t>::max();
+                // find cgroup limit failed, wait 300s, 1000 * 100ms.
+                _s_cgroup_mem_refresh_wait_times = -3000;
+                LOG(INFO) << "Refresh cgroup memory limit failed, refresh 
again after 300s, cgroup "
+                             "mem limit: "
+                          << _s_cgroup_mem_limit;
+            } else {
+                // wait 10s, 100 * 100ms, avoid too frequently.
+                _s_cgroup_mem_refresh_wait_times = -100;
+            }
         } else {
-            // find cgroup failed, wait 300s, 1000 * 100ms.
-            _s_cgroup_mem_refresh_wait_times = -3000;
-            LOG(INFO)
-                    << "Refresh cgroup memory failed, refresh again after 
300s, cgroup mem limit: "
-                    << _s_cgroup_mem_limit << ", cgroup mem usage: " << 
_s_cgroup_mem_usage;
-        }
-    } else {
-        if (config::enable_use_cgroup_memory_info) {
             _s_cgroup_mem_refresh_wait_times++;
+        }
+
+        if (_s_cgroup_mem_limit != std::numeric_limits<int64_t>::max()) {
+            auto status = 
CGroupMemoryCtl::find_cgroup_mem_usage(&_s_cgroup_mem_usage);
+            if (!status.ok()) {
+                _s_cgroup_mem_usage = std::numeric_limits<int64_t>::min();
+                _s_cgroup_mem_refresh_state = false;
+            } else {
+                _s_cgroup_mem_refresh_state = true;
+            }
         } else {
             _s_cgroup_mem_refresh_state = false;
         }
+    } else {
+        _s_cgroup_mem_refresh_state = false;
     }
 
     // 1. calculate physical_mem


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

Reply via email to