You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/05/09 13:21:35 UTC

[GitHub] [arrow-datafusion] tustvold opened a new pull request, #6308: Parallel merge sort (#6162)

tustvold opened a new pull request, #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #6162
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Will run benchmarks prior to merge
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on pull request #6308: Parallel merge sort (#6162)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308#issuecomment-1541042461

   I plan to review this carefully tomorrow morning


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold commented on pull request #6308: Parallel merge sort (#6162)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308#issuecomment-1542392911

   It isn't a huge win, but I'll take it
   
   ```
   sort utf8 low cardinality
                           time:   [9.0271 ms 9.0396 ms 9.0527 ms]
                           change: [-11.727% -11.548% -11.370%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 4 outliers among 100 measurements (4.00%)
     3 (3.00%) high mild
     1 (1.00%) high severe
   merge sorted utf8 high cardinality
                           time:   [7.8055 ms 7.8186 ms 7.8341 ms]
                           change: [-3.5327% -3.0466% -2.5856%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 4 outliers among 100 measurements (4.00%)
     2 (2.00%) high mild
     2 (2.00%) high severe
   
   sort merge utf8 high cardinality
                           time:   [8.0414 ms 8.0505 ms 8.0599 ms]
                           change: [-2.5665% -2.3550% -2.1393%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 2 outliers among 100 measurements (2.00%)
     2 (2.00%) high mild
   
   sort utf8 high cardinality
                           time:   [12.386 ms 12.413 ms 12.442 ms]
                           change: [-15.231% -14.371% -13.530%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 8 outliers among 100 measurements (8.00%)
     7 (7.00%) high mild
     1 (1.00%) high severe
   sort utf8 tuple         time:   [19.995 ms 20.037 ms 20.082 ms]
                           change: [-23.549% -23.240% -22.940%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 4 outliers among 100 measurements (4.00%)
     1 (1.00%) high mild
     3 (3.00%) high severe
   sort mixed dictionary tuple
                           time:   [21.851 ms 21.939 ms 22.033 ms]
                           change: [-13.963% -13.555% -13.128%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 6 outliers among 100 measurements (6.00%)
     6 (6.00%) high mild
   sort mixed tuple        time:   [19.054 ms 19.176 ms 19.307 ms]
                           change: [-13.179% -12.578% -11.928%] (p = 0.00 < 0.05)
                           Performance has improved.
   Found 12 outliers among 100 measurements (12.00%)
     11 (11.00%) high mild
     1 (1.00%) high severe
   ```
   
   There is no change the merge benches and the benches for primitive arrays (as they don't use SortPreservingMerge)


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6308: Parallel merge sort (#6162)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308#discussion_r1189868392


##########
datafusion/core/src/physical_plan/common.rs:
##########
@@ -180,6 +181,31 @@ pub(crate) fn spawn_execution(
     })
 }
 
+/// If running in a tokio context spawns the execution of `stream` to a separate task
+/// allowing it to execute in parallel with an intermediate buffer of size `buffer`
+pub(crate) fn spawn_buffered(
+    mut input: SendableRecordBatchStream,
+    buffer: usize,
+) -> SendableRecordBatchStream {
+    // Use tokio only if running from a tokio context (#2201)

Review Comment:
   Nice



##########
datafusion/core/src/physical_plan/sorts/sort_preserving_merge.rs:
##########
@@ -181,29 +180,12 @@ impl ExecutionPlan for SortPreservingMergeExec {
                 result
             }
             _ => {
-                // Use tokio only if running from a tokio context (#2201)
-                let receivers = match tokio::runtime::Handle::try_current() {
-                    Ok(_) => (0..input_partitions)
-                        .map(|part_i| {
-                            let (sender, receiver) = mpsc::channel(1);
-                            let join_handle = spawn_execution(
-                                self.input.clone(),
-                                sender,
-                                part_i,
-                                context.clone(),
-                            );
-
-                            RecordBatchReceiverStream::create(
-                                &schema,
-                                receiver,
-                                join_handle,
-                            )
-                        })
-                        .collect(),
-                    Err(_) => (0..input_partitions)
-                        .map(|partition| self.input.execute(partition, context.clone()))
-                        .collect::<Result<_>>()?,
-                };
+                let receivers = (0..input_partitions)

Review Comment:
   This looks beautiful



-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on pull request #6308: Parallel merge sort (#6162)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308#issuecomment-1542416728

   I think we should merge it 


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] tustvold merged pull request #6308: Parallel merge sort (#6162)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #6308:
URL: https://github.com/apache/arrow-datafusion/pull/6308


-- 
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-unsubscribe@arrow.apache.org

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