pitrou opened a new issue, #40686:
URL: https://github.com/apache/arrow/issues/40686

   ### Describe the enhancement requested
   
   A common memory (re)allocation pattern is to persist a dynamically-sized 
scratch buffer (for example when decompressing or decoding data). Currently, 
the two options to achieve that are suboptimal:
   1. either resize the buffer when needed, but if the buffer's base pointer 
changes, the data will be copied when resizing even though the data is ephemeral
   2. or allocate a new buffer when needing to increase the scratch size, but 
it is wasteful if the buffer could otherwise have been resized in place
   
   Both jemalloc and mimalloc expose APIs that would allow us to implement a 
more optimal behavior of resizing without copying existing data: 
[mi_expand](https://microsoft.github.io/mimalloc/group__malloc.html#gaaee66a1d483c3e28f585525fb96707e4)
 for mimalloc, [xallocx](https://jemalloc.net/jemalloc.3.html) for jemalloc.
   
   One possible API would be:
   ```c++
     Status ReallocateNoCopy(int64_t old_size, int64_t new_size, int64_t 
alignment,
                             uint8_t** ptr) = 0;
     Status ReallocateNoCopy(int64_t old_size, int64_t new_size, uint8_t** ptr);
   ```
   
   
   ### Component(s)
   
   C++


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