2010YOUY01 commented on code in PR #17163:
URL: https://github.com/apache/datafusion/pull/17163#discussion_r2289827090


##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -299,13 +307,63 @@ impl ExternalSorter {
             batch_size,
             sort_spill_reservation_bytes,
             sort_in_place_threshold_bytes,
+            cursor_batch_ratio,
         })
     }
 
+    /// Calculates the ratio of memory used by the sort cursor to the original 
`RecordBatch`.
+    /// Returns the ratio `(cursor_size / batch_size) + 1.0`, representing the 
expected memory multiplier
+    /// when allocating space for both the original batch and its associated 
cursor.
+    ///
+    /// Mirrors the cursor selection logic in `StreamingMerge::build`
+    /// Performs the same conversion for ratio estimation, but discards the 
result.

Review Comment:
   The best solution should be when buffering, eagerly do the Arrow Rows 
conversions and account the actual memory, however this approach is very 
challenging to keep the performance.
   Here is a related issue: https://github.com/apache/datafusion/pull/15380



-- 
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: github-unsubscr...@datafusion.apache.org

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


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

Reply via email to