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


##########
be/src/vec/common/pod_array.h:
##########
@@ -120,8 +122,9 @@ class PODArrayBase : private boost::noncopyable,
         }
     }
 
+    /// Not round up, keep the size just as the application pass in like 
std::vector
     void alloc_for_num_elements(size_t num_elements) {
-        
alloc(round_up_to_power_of_two_or_zero(minimum_memory_for_elements(num_elements)));
+        alloc(minimum_memory_for_elements(num_elements));

Review Comment:
   I do not think this should be a config, because if it is a config, we do not 
know when to open the config since it is a macro. Actually, there are two types 
of memory allocation in PODArray:
   1. reserve, sometimes the developer know the expected size of the array, 
then he should call reserve method to allocate the EXPECTED memory.
   2. push_back, the developer does not know the expected size of the array, 
then he just call push back to allocate memory. In this scenario, we should 
allocate memory using power of 2.
   
   For most cases, we should reserve or resize memory size before push back, 
then we could reduce memory reallocation or memory copy. 
   This PR try to fix some problems. 
https://github.com/apache/doris/pull/13088. 



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to