alamb opened a new issue, #6934:
URL: https://github.com/apache/arrow-datafusion/issues/6934

   ### Is your feature request related to a problem or challenge?
   
   @JayjeetAtGithub and I are investigating improving memory performance for 
certain queries
   
   When we hit the memory limit, we see different error messages. For example 
sometimes we see
   
   ```
   External error: External error: Execution error for 'deduplicate 
batches'\ncaused by\nResources exhausted: Memory Exhausted while Sorting 
(DiskManager is disabled)", source: None })
   ```
   
   And sometimes we see
   ```
   External error: Resources exhausted: Failed to allocate additional 212912 
bytes for GroupedHashAggregateStream[2] with 0 bytes already allocated - 
maximum available is 18446744073705376568"
   ```
   
   We would like to know what operators are consuming the memory
   
   I theorize the fact that we see different operators appear in the logs is 
due to the fact when we near the memory limit, any of the operators might be 
the "canary" that happened to be the operator that asked for memory next, 
rather than the one that was actually using it all)
   
   
   
   
   
   
   ### Describe the solution you'd like
   
   I would like some way to know how much each operator is consuming in a 
particular pool, and prior to returning an allocation error, entering a debug 
log with this information
   
   The memory pool code is here: 
https://github.com/apache/arrow-datafusion/blob/main/datafusion/execution/src/memory_pool/pool.rs
   
   I was imagining implementing `Display` for the pools like
   
   ```rust
   impl Display for GreedyPool  {
    ...
   }
   ```
   
   Which would produce a report like this with the reservations sorted in 
descending order:
   ```
   GreedyPool 25 allocations, 25630532 used, 332 free, 43942344 capacity
     321433: GroupedHashAggregateStream[0]
     1233: GroupedHashAggregateStream[2]
     24: Deduplicate
   ```
   
   Then prior to returning a resources exhausted error:
   
https://github.com/apache/arrow-datafusion/blob/50135e8c039b82d32b57db12ca06d789e9cbea4c/datafusion/execution/src/memory_pool/pool.rs#L87
   
   We would add a log message like
   
   ```rust
   debug!("Pool Exhausted while trying to allocate {additional} bytes for 
{reservation} :\n{self}", self)
   ```
   
   
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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