You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "crepererum (via GitHub)" <gi...@apache.org> on 2023/04/27 14:18:44 UTC
[GitHub] [arrow-datafusion] crepererum opened a new pull request, #6138: feat: concurrent physical planning
crepererum opened a new pull request, #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138
# Which issue does this PR close?
\-
# Rationale for this change
Plan nodes w/ multiple children concurrently. This is helpful if planning requires IO (e.g. file or network access), you have different tables, and you do not want to wait for DataFusion to plan one after the other.
The main goal is to reduce planning time for `UNION` and `JOIN` queries.
# What changes are included in this PR?
New config variable `physical_planning_fanout` (we can bikeshed the naming) and a some stream magic to make planning concurrent.
# Are these changes tested?
Existing tests pass.
# Are there any user-facing changes?
Faster planning.
--
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] crepererum commented on pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1527465482
Has to wait til next week since I'm fighting DFs listing table IO.
--
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 #6138: feat: concurrent physical planning
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1179239519
##########
datafusion/common/src/config.rs:
##########
@@ -223,6 +223,11 @@ config_namespace! {
/// Parquet options
pub parquet: ParquetOptions, default = Default::default()
+
+ /// Fan-out during physical planning.
Review Comment:
```suggestion
/// Fan-out during initial physical planning.
```
##########
datafusion/common/src/config.rs:
##########
@@ -223,6 +223,11 @@ config_namespace! {
/// Parquet options
pub parquet: ParquetOptions, default = Default::default()
+
+ /// Fan-out during physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub physical_planning_fanout: usize, default = 10
Review Comment:
I recommend calling this "planning_concurrency"
--
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 #6138: feat: concurrent physical planning
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1534748439
Thank you @crepererum and @avantgardnerio
--
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] crepererum commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183449510
##########
datafusion/common/src/config.rs:
##########
@@ -226,6 +226,11 @@ config_namespace! {
/// Aggregate options
pub aggregate: AggregateOptions, default = Default::default()
+
+ /// Fan-out during initial physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub planning_concurrency: usize, default = 10
Review Comment:
I think the config system currently doesn't allow dependent defaults (this would require a full DAG-style resolution).
--
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] crepererum commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183448251
##########
datafusion/core/src/physical_plan/planner.rs:
##########
@@ -929,10 +972,11 @@ impl DefaultPhysicalPlanner {
}
// All equi-join keys are columns now, create physical join plan
+ let mut left_right = self.create_initial_plan_multi([left.as_ref(), right.as_ref()], session_state).await?;
Review Comment:
and if it doesn't match, what do you do then? `create_initial_plan_multi` has the rule "N in, N out" and hence unwrapping is totally legit here.
--
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] avantgardnerio commented on pull request #6138: feat: concurrent physical planning
Posted by "avantgardnerio (via GitHub)" <gi...@apache.org>.
avantgardnerio commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1533286983
It looks like the dynamic number of cores caused a sqllogictest failure. I see someone has already figured out a solution for that:
https://github.com/apache/arrow-datafusion/blob/3801d45fe5ea3d9b207488527b758a0264665263/datafusion/core/tests/sqllogictests/test_files/information_schema.slt#L126
I merely saw this as a nice to have, so I'd be fine setting it back to a constant, or overriding it in the test as above :point_up:
--
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] crepererum commented on pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1525939362
Will work on a benchmark tomorrow.
--
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] avantgardnerio commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "avantgardnerio (via GitHub)" <gi...@apache.org>.
avantgardnerio commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1182832054
##########
datafusion/common/src/config.rs:
##########
@@ -226,6 +226,11 @@ config_namespace! {
/// Aggregate options
pub aggregate: AggregateOptions, default = Default::default()
+
+ /// Fan-out during initial physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub planning_concurrency: usize, default = 10
Review Comment:
It might be nice to default this to `num_cpus` like above?
##########
datafusion/core/src/physical_plan/planner.rs:
##########
@@ -929,10 +972,11 @@ impl DefaultPhysicalPlanner {
}
// All equi-join keys are columns now, create physical join plan
+ let mut left_right = self.create_initial_plan_multi([left.as_ref(), right.as_ref()], session_state).await?;
Review Comment:
I'd love to see this not `unwrap` - perhaps match on a slice?
##########
datafusion/core/src/physical_plan/planner.rs:
##########
@@ -1064,8 +1108,9 @@ impl DefaultPhysicalPlanner {
}
}
LogicalPlan::CrossJoin(CrossJoin { left, right, .. }) => {
- let left = self.create_initial_plan(left, session_state).await?;
- let right = self.create_initial_plan(right, session_state).await?;
+ let mut left_right = self.create_initial_plan_multi([left.as_ref(), right.as_ref()], session_state).await?;
+ let right = left_right.pop().unwrap();
+ let left = left_right.pop().unwrap();
Review Comment:
Same...
--
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] avantgardnerio commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "avantgardnerio (via GitHub)" <gi...@apache.org>.
avantgardnerio commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183779449
##########
datafusion/core/src/physical_plan/planner.rs:
##########
@@ -929,10 +972,11 @@ impl DefaultPhysicalPlanner {
}
// All equi-join keys are columns now, create physical join plan
+ let mut left_right = self.create_initial_plan_multi([left.as_ref(), right.as_ref()], session_state).await?;
Review Comment:
> what do you do then?
I would recommend:
```
Err(DataFusionError::PlanError("xyz")?
```
--
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] crepererum commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183856045
##########
datafusion/core/src/physical_plan/planner.rs:
##########
@@ -929,10 +972,11 @@ impl DefaultPhysicalPlanner {
}
// All equi-join keys are columns now, create physical join plan
+ let mut left_right = self.create_initial_plan_multi([left.as_ref(), right.as_ref()], session_state).await?;
Review Comment:
I don't agree w/ on this one. Fundamentally broken stuff can panic, that's a common pattern in Rust. Errors should only be used where it makes sense. Esp. most errors don't even carry enough information for a user to be meaningful.
Anyways, I'm not gonna die on that hill. Fixed.
--
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] crepererum commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1179378566
##########
datafusion/common/src/config.rs:
##########
@@ -223,6 +223,11 @@ config_namespace! {
/// Parquet options
pub parquet: ParquetOptions, default = Default::default()
+
+ /// Fan-out during physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub physical_planning_fanout: usize, default = 10
Review Comment:
done
--
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] mingmwang commented on pull request #6138: feat: concurrent physical planning
Posted by "mingmwang (via GitHub)" <gi...@apache.org>.
mingmwang commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1526901464
@crepererum
Could you please help to explain a little that In which phase, the physical planner would require IOs?
--
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] avantgardnerio commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "avantgardnerio (via GitHub)" <gi...@apache.org>.
avantgardnerio commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183777356
##########
datafusion/common/src/config.rs:
##########
@@ -226,6 +226,11 @@ config_namespace! {
/// Aggregate options
pub aggregate: AggregateOptions, default = Default::default()
+
+ /// Fan-out during initial physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub planning_concurrency: usize, default = 10
Review Comment:
Github doesn't let me link, but online 216 is this:
```
/// Number of partitions for query execution. Increasing partitions can increase
/// concurrency. Defaults to the number of CPU cores on the system
pub target_partitions: usize, default = num_cpus::get()
```
--
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] crepererum commented on a diff in pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on code in PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#discussion_r1183853373
##########
datafusion/common/src/config.rs:
##########
@@ -226,6 +226,11 @@ config_namespace! {
/// Aggregate options
pub aggregate: AggregateOptions, default = Default::default()
+
+ /// Fan-out during initial physical planning.
+ ///
+ /// This is mostly use to plan `UNION` children in parallel.
+ pub planning_concurrency: usize, default = 10
Review Comment:
done
--
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] crepererum commented on pull request #6138: feat: concurrent physical planning
Posted by "crepererum (via GitHub)" <gi...@apache.org>.
crepererum commented on PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138#issuecomment-1531285715
benchmark done (see PR comment)
--
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 merged pull request #6138: feat: concurrent physical planning
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6138:
URL: https://github.com/apache/arrow-datafusion/pull/6138
--
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