Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/11242#discussion_r61979221
--- Diff: core/src/main/scala/org/apache/spark/rdd/UnionRDD.scala ---
@@ -56,14 +58,30 @@ private[spark] class UnionPartition[T: ClassTag](
}
}
+object UnionRDD {
+ private lazy val partitionEvalThreadPool = new ForkJoinPool(8)
+}
+
@DeveloperApi
class UnionRDD[T: ClassTag](
sc: SparkContext,
var rdds: Seq[RDD[T]])
extends RDD[T](sc, Nil) { // Nil since we implement getDependencies
+ // visible for testing
+ private[spark] val isPartitionEvalParallel: Boolean =
+ rdds.length > conf.getInt("spark.rdd.parallelListingThreshold", 10)
+
override def getPartitions: Array[Partition] = {
- val array = new Array[Partition](rdds.map(_.partitions.length).sum)
+ val parRDDs = if (isPartitionEvalParallel) {
+ val parArray = rdds.par
+ parArray.tasksupport = new
ForkJoinTaskSupport(UnionRDD.partitionEvalThreadPool)
+ parArray
+ } else {
+ rdds
+ }
+ // evaluating parRDDs.map(_.partitions) will execute in parallel and
cache partitions
--- End diff --
I don't think this comment adds any value. First of all it's not
necessarily true. Second if it's a parallel seq then that's just what Scala
does, no surprises there.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]