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

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


The following commit(s) were added to refs/heads/spill_and_reserve by this push:
     new 476b9bbc771 [spill](fix) fix reserve memory if 
enable_memory_overcommit (#41282)
476b9bbc771 is described below

commit 476b9bbc77142f842c51593d7129f56968c51181
Author: TengJianPing <18241664+jackte...@users.noreply.github.com>
AuthorDate: Wed Sep 25 17:25:29 2024 +0800

    [spill](fix) fix reserve memory if enable_memory_overcommit (#41282)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    
    <!--Describe your changes.-->
---
 be/src/runtime/memory/mem_tracker_limiter.h    | 12 ++++++++++++
 be/src/runtime/memory/thread_mem_tracker_mgr.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/be/src/runtime/memory/mem_tracker_limiter.h 
b/be/src/runtime/memory/mem_tracker_limiter.h
index 80ddde30351..09558c7bddc 100644
--- a/be/src/runtime/memory/mem_tracker_limiter.h
+++ b/be/src/runtime/memory/mem_tracker_limiter.h
@@ -171,6 +171,18 @@ public:
     int64_t reserved_consumption() const { return 
_reserved_counter.current_value(); }
     int64_t reserved_peak_consumption() const { return 
_reserved_counter.peak_value(); }
 
+    void reserve(int64_t bytes) {
+        if (UNLIKELY(bytes == 0)) {
+            return;
+        }
+        _mem_counter.add(bytes);
+        if (_query_statistics) {
+            _query_statistics->set_max_peak_memory_bytes(peak_consumption());
+            _query_statistics->set_current_used_memory_bytes(consumption());
+        }
+        _reserved_counter.add(bytes);
+    }
+
     bool try_reserve(int64_t bytes) {
         if (UNLIKELY(bytes == 0)) {
             return true;
diff --git a/be/src/runtime/memory/thread_mem_tracker_mgr.h 
b/be/src/runtime/memory/thread_mem_tracker_mgr.h
index 80b00d32a0b..15a57528491 100644
--- a/be/src/runtime/memory/thread_mem_tracker_mgr.h
+++ b/be/src/runtime/memory/thread_mem_tracker_mgr.h
@@ -296,6 +296,8 @@ inline doris::Status 
ThreadMemTrackerMgr::try_reserve(int64_t size) {
                     size, _limiter_tracker->consumption(), 
_limiter_tracker->limit());
             return 
doris::Status::Error<ErrorCode::QUERY_MEMORY_EXCEEDED>(err_msg);
         }
+    } else {
+        _limiter_tracker->reserve(size);
     }
     if (wg_ptr) {
         if (!wg_ptr->add_wg_refresh_interval_memory_growth(size)) {


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

Reply via email to