yiguolei commented on code in PR #52553:
URL: https://github.com/apache/doris/pull/52553#discussion_r2176187465
##########
be/src/vec/common/pod_array.h:
##########
@@ -174,15 +177,26 @@ class PODArrayBase : private boost::noncopyable,
static_assert(!TAllocator::need_check_and_tracking_memory(),
"TAllocator should specify
`NoTrackingDefaultMemoryAllocator`");
if (UNLIKELY(c_end_new - c_res_mem > 0)) {
+ // 1. if (capacity_size / PRE_GROWTH_RATIO) <= PRE_MIN_GROWTH_SIZE:
// - allocated_bytes = c_end_of_storage - c_start = 4 MB;
// - used_bytes = c_end_new - c_start = 2.1 MB;
// - last tracking_res_memory = c_res_mem - c_start = 1 MB;
- // - res_mem_growth = min(allocated_bytes,
integerRoundUp(used_bytes)) - last_tracking_res_memory = 3 - 1 = 2 MB;
+ // - res_mem_growth = min(allocated_bytes,
integerRoundUp(used_bytes, 1M)) - 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;
+ //
+ // 2. if (capacity_size / PRE_GROWTH_RATIO) > PRE_MIN_GROWTH_SIZE:
+ // - allocated_bytes = c_end_of_storage - c_start = 1024 MB;
+ // - used_bytes = c_end_new - c_start = 210 MB;
+ // - last tracking_res_memory = c_res_mem - c_start = 102 MB;
+ // - res_mem_growth = min(allocated_bytes,
integerRoundUp(used_bytes, 102M)) - last_tracking_res_memory = 306 - 102 = 204
MB;
+ // - update tracking_res_memory = 102 + 204 = 306 MB;
+
+ auto capacity_size = static_cast<size_t>(c_end_of_storage -
c_start);
+ auto min_growth_size = std::max(static_cast<size_t>(capacity_size
/ PRE_GROWTH_RATIO),
+ PRE_MIN_GROWTH_SIZE);
int64_t res_mem_growth =
- std::min(static_cast<size_t>(c_end_of_storage - c_start),
- integerRoundUp(c_end_new - c_start,
PRE_GROWTH_SIZE)) -
+ std::min(capacity_size, integerRoundUp(c_end_new -
c_start, min_growth_size)) -
Review Comment:
1. 这里为啥要integerRoundUp(c_end_new - c_start, min_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]