martin-g commented on code in PR #1911:
URL:
https://github.com/apache/datafusion-ballista/pull/1911#discussion_r3491350991
##########
ballista/scheduler/src/state/task_manager.rs:
##########
@@ -163,12 +165,64 @@ impl JobInfoCache {
encoded_stage_plans: HashMap::new(),
}
}
+
+ #[cfg(feature = "disable-stage-plan-cache")]
+ fn partition_prune_helper(
+ partition_ids: &[usize],
+ plan: &Arc<dyn ExecutionPlan>,
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ let n = plan.output_partitioning().partition_count();
+ let wanted: HashSet<usize> = partition_ids.iter().copied().collect();
Review Comment:
nit: how many partition ids are expected here ?
If it is a small number then `partition_ids.contains(&i)` is OK too and it
will avoid the extra allocation.
##########
ballista/scheduler/src/state/task_manager.rs:
##########
@@ -163,12 +165,64 @@ impl JobInfoCache {
encoded_stage_plans: HashMap::new(),
}
}
+
+ #[cfg(feature = "disable-stage-plan-cache")]
+ fn partition_prune_helper(
+ partition_ids: &[usize],
+ plan: &Arc<dyn ExecutionPlan>,
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ let n = plan.output_partitioning().partition_count();
+ let wanted: HashSet<usize> = partition_ids.iter().copied().collect();
+ Ok(plan
+ .clone()
+ .transform_up(|node| {
+ let Some(r) =
node.as_any().downcast_ref::<ShuffleReaderExec>() else {
+ return Ok(Transformed::no(node));
+ };
+ if r.broadcast || r.partition.len() != n {
Review Comment:
```suggestion
if r.broadcast || r.partition.len() != partition_ids.len() {
```
isn't this more correct ?
##########
ballista/scheduler/src/state/task_manager.rs:
##########
@@ -163,12 +165,64 @@ impl JobInfoCache {
encoded_stage_plans: HashMap::new(),
}
}
+
+ #[cfg(feature = "disable-stage-plan-cache")]
+ fn partition_prune_helper(
+ partition_ids: &[usize],
+ plan: &Arc<dyn ExecutionPlan>,
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ let n = plan.output_partitioning().partition_count();
+ let wanted: HashSet<usize> = partition_ids.iter().copied().collect();
+ Ok(plan
+ .clone()
+ .transform_up(|node| {
+ let Some(r) =
node.as_any().downcast_ref::<ShuffleReaderExec>() else {
+ return Ok(Transformed::no(node));
+ };
+ if r.broadcast || r.partition.len() != n {
+ return Ok(Transformed::no(node));
+ }
+
+ let partition = r
+ .partition
+ .iter()
+ .enumerate()
+ .map(|(i, loc)| {
+ if wanted.contains(&i) {
+ loc.clone()
+ } else {
+ vec![]
+ }
+ })
+ .collect();
+
Review Comment:
consider returning early if there was no pruning:
```suggestion
if wanted.len() == r.partition.len() {
return Ok(Transformed::no(node));
}
```
--
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]