Skip to content

Commit b6b4485

Browse files
witgopwendell
authored andcommitted
SPARK-2248: spark.default.parallelism does not apply in local mode
Author: witgo <witgo@qq.com> Closes #1194 from witgo/SPARK-2248 and squashes the following commits: 6ac950b [witgo] spark.default.parallelism does not apply in local mode
1 parent 2714968 commit b6b4485

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/src/main/scala/org/apache/spark/scheduler/local/LocalBackend.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ private[spark] class LocalBackend(scheduler: TaskSchedulerImpl, val totalCores:
9797
localActor ! ReviveOffers
9898
}
9999

100-
override def defaultParallelism() = totalCores
100+
override def defaultParallelism() =
101+
scheduler.conf.getInt("spark.default.parallelism", totalCores)
101102

102103
override def killTask(taskId: Long, executorId: String, interruptThread: Boolean) {
103104
localActor ! KillTask(taskId, interruptThread)

core/src/test/scala/org/apache/spark/SparkContextSchedulerCreationSuite.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ class SparkContextSchedulerCreationSuite
7777
}
7878
}
7979

80+
test("local-default-parallelism") {
81+
val defaultParallelism = System.getProperty("spark.default.parallelism")
82+
System.setProperty("spark.default.parallelism", "16")
83+
val sched = createTaskScheduler("local")
84+
85+
sched.backend match {
86+
case s: LocalBackend => assert(s.defaultParallelism() === 16)
87+
case _ => fail()
88+
}
89+
90+
Option(defaultParallelism) match {
91+
case Some(v) => System.setProperty("spark.default.parallelism", v)
92+
case _ => System.clearProperty("spark.default.parallelism")
93+
}
94+
}
95+
8096
test("simr") {
8197
createTaskScheduler("simr://uri").backend match {
8298
case s: SimrSchedulerBackend => // OK

0 commit comments

Comments
 (0)