geoffreyclaude commented on code in PR #26930:
URL: https://github.com/apache/datafusion/pull/26930#discussion_r4493696927


##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -998,21 +986,27 @@ impl ExternalSorter {
         shared_input: Option<Arc<MemoryReservation>>,
     ) -> Result<SendableRecordBatchStream> {
         let schema = batch.schema();
-        let stream =
-            futures::stream::once(self.sort_run(batch, reservation, 
shared_input)?)
-                .try_flatten();
+        let stream = futures::stream::once(self.sort_run(
+            batch,
+            reservation,
+            shared_input,
+            false,
+        )?)
+        .try_flatten();
         Ok(Box::pin(RecordBatchStreamAdapter::new(schema, stream)))
     }
 
     /// Sorts a batch and reserves its complete output before returning a 
stream.
-    /// The stream releases reservations as its consumer takes each output 
batch.
+    /// Reservations release as output is read; parallel preparation reads one
+    /// batch ahead to return spill workspace before the merge builds its 
cursor.
     /// If present, `shared_input` covers the runs' shared buffers and is held
     /// until sorting finishes; `reservation` covers this run's sorting and 
output.
     fn sort_run(
         &self,
         batch: RecordBatch,
         reservation: MemoryReservation,
         shared_input: Option<Arc<MemoryReservation>>,
+        read_ahead: bool,

Review Comment:
   Agreed, the measurements don’t justify the extra code. Adopted your smaller 
alternative: the PR now removes 200 lines with no additions.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to