yiguolei commented on code in PR #50549:
URL: https://github.com/apache/doris/pull/50549#discussion_r2078892535


##########
be/src/vec/common/pod_array.h:
##########
@@ -143,6 +154,38 @@ class PODArrayBase : private boost::noncopyable,
         return byte_size(num_elements) + pad_right + pad_left;
     }
 
+    inline void check_memory(int64_t size) {
+        std::string err_msg;
+        if (TAllocator::sys_memory_exceed(size, &err_msg) ||
+            TAllocator::memory_tracker_exceed(size, &err_msg)) {
+            err_msg = fmt::format("PODArray reserve memory failed, {}.", 
err_msg);
+            if (doris::enable_thread_catch_bad_alloc) {
+                LOG(WARNING) << err_msg;
+                throw doris::Exception(doris::ErrorCode::MEM_ALLOC_FAILED, 
err_msg);
+            } else {
+                LOG_EVERY_N(WARNING, 1024) << err_msg;
+            }
+        }
+    }
+
+    inline void reset_resident_memory() {
+        if (UNLIKELY(c_end - c_res_mem > 0)) {
+            // - allocated_bytes = c_end_of_storage - c_start = 4 MB;
+            // - used_bytes = c_end - c_start = 2.1 MB;
+            // - last tracking_res_memory = c_res_mem - c_start = 1 MB;
+            // - res_mem_growth = min(allocated_bytes, 
round_up_to_power_of_one(used_bytes)) - last_tracking_res_memory = 3 - 1 = 2 MB;
+            // - update tracking_res_memory = 1 + 2 = 3 MB;
+            // so after each reset_resident_memory, tracking_res_memory > 
used_bytes;
+            int64_t res_mem_growth = 
std::min(static_cast<size_t>(c_end_of_storage - c_start),
+                                              ((c_end - c_start) + 
PRE_GROWTH_SIZE - 1) /

Review Comment:
   integerRoundUp(c_end - c_start, PRE_GROWTH_SIZE)  ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to