XiangpengHao opened a new issue, #6094:
URL: https://github.com/apache/arrow-rs/issues/6094

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   <!--
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   -->
   
   Related to https://github.com/apache/datafusion/issues/10918 and 
https://github.com/apache/arrow-rs/issues/5374
   
   Current default block size (i.e., buffer capacity) is 8KB, it is a 
reasonable initial value -- we only waste up to 8KB of data.
   
   However, it is not great for large `StringViewArray`s. With default 8KB 
block size , 4GB of strings will require half a million buffers, causing a 
significant slowdown even for APIs like 
[`get_array_memory_size`](https://github.com/apache/arrow-rs/blob/master/arrow-array/src/array/byte_view_array.rs#L397)
   
   We want to have a small number of buffers for the following reasons: (1) 
faster buffer lookup due to better `Vec<Buffer>` locality, and (2) faster 
concatenation. Query engines (e.g., DataFusion) often need to concatenate 
multiple batches, which needs to concatenate two `Vec<Buffer>` into a new one. 
Smaller `Vec<Buffer>`s has better concat performance.
   
   
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   (Simple) Change the default block size to 2MB. 2MB is the default size of 
huge page in many systems, and I believe 2MB is a reasonable choice. The 
drawback is that we may waste up to 2MB of memory for small arrays, which can 
be fixed using the method below. 
   
   (Advanced) Exponential increase until we hit 2MB. `4KB -> 8KB -> 16KB -> .. 
-> 512 KB -> 1MB -> 2MB -> ... -> 2MB -> 2MB`
   
   
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   We currently allow user to provide a block size when building the string 
view array. However, the implication of this block size is not straightforward 
and can take quite a lot of efforts to understand, and the user don't even know 
the default size without looking at the source code.
    I can expect the users of `StringViewArray` easily run into performance 
issues because of this non-trivial reason (like what I had run into)
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   


-- 
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]

Reply via email to