You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2023/01/19 03:56:09 UTC

[doris] branch branch-1.2-lts updated (901f2711a3 -> 21d5c86932)

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

dataroaring pushed a change to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


    from 901f2711a3 [feature](multi-catalog) support hive metastore more events (#15702)
     new a6382105b4 (tcmalloc) gc does not work in somecases (#14732)
     new 21d5c86932 [fix](tcmalloc_gc) optimize policy of tcmalloc gc (#14776)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 be/src/common/daemon.cpp | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)


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


[doris] 01/02: (tcmalloc) gc does not work in somecases (#14732)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit a6382105b494e1351c6ed51445c539a533bb5abc
Author: Yongqiang YANG <98...@users.noreply.github.com>
AuthorDate: Fri Dec 2 09:18:23 2022 +0800

    (tcmalloc) gc does not work in somecases (#14732)
    
    gc does not work in some cases
---
 be/src/common/daemon.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index c0d3fee21f..27e91d6d5e 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -135,16 +135,13 @@ void Daemon::tcmalloc_gc_thread() {
                 to_free_bytes = std::max(to_free_bytes, tc_cached_bytes * 30 / 100);
                 to_free_bytes = std::min(to_free_bytes, tc_cached_bytes);
                 expected_aggressive_decommit = 1;
-            } else {
-                // release rate is enough.
-                to_free_bytes = 0;
             }
             last_ms = kMaxLastMs;
         } else if (memory_pressure > (pressure_limit - 10)) {
+            // In most cases, adjusting release rate is enough, if memory are consumed quickly
+            // we should release manually.
             if (last_memory_pressure <= (pressure_limit - 10)) {
                 to_free_bytes = std::max(to_free_bytes, tc_cached_bytes * 10 / 100);
-            } else {
-                to_free_bytes = 0;
             }
         }
 
@@ -178,6 +175,7 @@ void Daemon::tcmalloc_gc_thread() {
                 last_ms = 0;
             }
         } else {
+            DCHECK(tc_cached_bytes <= tc_used_bytes * max_cache_percent / 100);
             last_ms = 0;
         }
     }


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


[doris] 02/02: [fix](tcmalloc_gc) optimize policy of tcmalloc gc (#14776)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 21d5c869322ef3cf3da9b9d2ec4b62bd422da0c1
Author: Yongqiang YANG <98...@users.noreply.github.com>
AuthorDate: Mon Dec 5 21:16:35 2022 +0800

    [fix](tcmalloc_gc) optimize policy of tcmalloc gc (#14776)
    
    Release memory when memory pressure is above pressure limit and keep at lease 2% memory as tcmalloc cache.
---
 be/src/common/daemon.cpp | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index 27e91d6d5e..054dbdc533 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -80,7 +80,7 @@ void Daemon::tcmalloc_gc_thread() {
     double release_rates[10] = {1.0, 1.0, 1.0, 5.0, 5.0, 20.0, 50.0, 100.0, 500.0, 2000.0};
     int64_t pressure_limit = 90;
     bool is_performance_mode = false;
-    size_t physical_limit_bytes =
+    int64_t physical_limit_bytes =
             std::min(MemInfo::physical_mem() - MemInfo::sys_mem_available_low_water_mark(),
                      MemInfo::mem_limit());
 
@@ -115,13 +115,16 @@ void Daemon::tcmalloc_gc_thread() {
                                                         &tc_alloc_bytes);
         MallocExtension::instance()->GetNumericProperty("generic.current_allocated_bytes",
                                                         &tc_used_bytes);
-        int64_t tc_cached_bytes = tc_alloc_bytes - tc_used_bytes;
+        int64_t tc_cached_bytes = (int64_t)tc_alloc_bytes - (int64_t)tc_used_bytes;
         int64_t to_free_bytes =
-                (int64_t)tc_cached_bytes - (tc_used_bytes * max_cache_percent / 100);
+                (int64_t)tc_cached_bytes - ((int64_t)tc_used_bytes * max_cache_percent / 100);
+        to_free_bytes = std::max(to_free_bytes, (int64_t)0);
 
         int64_t memory_pressure = 0;
+        int64_t rss_pressure = 0;
         int64_t alloc_bytes = std::max(rss, tc_alloc_bytes);
         memory_pressure = alloc_bytes * 100 / physical_limit_bytes;
+        rss_pressure = rss * 100 / physical_limit_bytes;
 
         expected_aggressive_decommit = init_aggressive_decommit;
         if (memory_pressure > pressure_limit) {
@@ -129,11 +132,13 @@ void Daemon::tcmalloc_gc_thread() {
             // Ideally, we should reuse cache and not allocate from system any more,
             // however, it is hard to set limit on cache of tcmalloc and doris
             // use mmap in vectorized mode.
-            if (last_memory_pressure <= pressure_limit) {
+            // Limit cache capactiy is enough.
+            if (rss_pressure > pressure_limit) {
                 int64_t min_free_bytes = alloc_bytes - physical_limit_bytes * 9 / 10;
                 to_free_bytes = std::max(to_free_bytes, min_free_bytes);
                 to_free_bytes = std::max(to_free_bytes, tc_cached_bytes * 30 / 100);
-                to_free_bytes = std::min(to_free_bytes, tc_cached_bytes);
+                // We assure that we have at least 500M bytes in cache.
+                to_free_bytes = std::min(to_free_bytes, tc_cached_bytes - 500 * 1024 * 1024);
                 expected_aggressive_decommit = 1;
             }
             last_ms = kMaxLastMs;
@@ -147,7 +152,7 @@ void Daemon::tcmalloc_gc_thread() {
 
         int release_rate_index = memory_pressure / 10;
         double release_rate = 1.0;
-        if (release_rate_index >= sizeof(release_rates)) {
+        if (release_rate_index >= sizeof(release_rates) / sizeof(release_rates[0])) {
             release_rate = 2000.0;
         } else {
             release_rate = release_rates[release_rate_index];
@@ -161,7 +166,8 @@ void Daemon::tcmalloc_gc_thread() {
         }
 
         last_memory_pressure = memory_pressure;
-        if (to_free_bytes > 0) {
+        // We release at least 2% bytes once, frequent releasing hurts performance.
+        if (to_free_bytes > (physical_limit_bytes * 2 / 100)) {
             last_ms += kIntervalMs;
             if (last_ms >= kMaxLastMs) {
                 LOG(INFO) << "generic.current_allocated_bytes " << tc_used_bytes
@@ -175,7 +181,6 @@ void Daemon::tcmalloc_gc_thread() {
                 last_ms = 0;
             }
         } else {
-            DCHECK(tc_cached_bytes <= tc_used_bytes * max_cache_percent / 100);
             last_ms = 0;
         }
     }


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