You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/12/13 20:42:59 UTC
[GitHub] [spark] holdenk commented on a change in pull request #34650: [WIP][SPARK-36664][CORE] Log time waiting for cluster resources
holdenk commented on a change in pull request #34650:
URL: https://github.com/apache/spark/pull/34650#discussion_r768106412
##########
File path: core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala
##########
@@ -776,16 +801,55 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp
val resourceProfileToNumExecutors = resourceProfileIdToNumExecutors.map { case (rpid, num) =>
(scheduler.sc.resourceProfileManager.resourceProfileFromId(rpid), num)
}
+ val oldResourceProfileToNumExecutors = requestedTotalExecutorsPerResourceProfile.map {
+ case (rp, num) =>
+ (rp.id, num)
+ }.toMap
val response = synchronized {
this.requestedTotalExecutorsPerResourceProfile.clear()
this.requestedTotalExecutorsPerResourceProfile ++= resourceProfileToNumExecutors
this.numLocalityAwareTasksPerResourceProfileId = numLocalityAwareTasksPerResourceProfileId
this.rpHostToLocalTaskCount = hostToLocalTaskCount
+ updateExecRequestTimes(oldResourceProfileToNumExecutors, resourceProfileIdToNumExecutors)
doRequestTotalExecutors(requestedTotalExecutorsPerResourceProfile.toMap)
}
defaultAskTimeout.awaitResult(response)
}
+ private def updateExecRequestTimes(oldProfile: Map[Int, Int], newProfile: Map[Int, Int]): Unit = {
+ newProfile.map {
+ case (k, v) =>
+ val delta = v - oldProfile.getOrElse(k, 0)
+ if (delta != 0) {
+ updateExecRequestTime(k, delta)
+ }
+ }
+ }
+
+ private def updateExecRequestTime(profileId: Int, delta: Int) = {
+ val times = execRequestTimes.getOrElseUpdate(profileId, Queue[(Int, Long)]())
+ if (delta > 0) {
+ // Add the request to the end, constant time op
+ times += ((delta, System.currentTimeMillis()))
+ } else if (delta < 0) {
+ // Consume as if |delta| had been allocated
+ var c = -delta
+ try {
+ while (c > 0) {
+ val h = times.dequeue
+ if (h._1 > c) {
+ // Prepend updated first req to times, constant time op
+ ((h._1 - c, h._2)) +=: times
+ } else {
+ c = c - h._1
+ }
+ }
+ } catch {
+ case e: Exception => // Ignore
Review comment:
If someone choses something other than Spark to manage the scale-up/scale-down of resources, or a straggler shows up that we assumed wasn't going to show up so we duplicated the request.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org