spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From squito <...@git.apache.org>
Subject [GitHub] spark pull request: [Spark-8426] [scheduler] enhance blacklist mec...
Date Wed, 23 Sep 2015 16:02:06 GMT
Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8760#discussion_r40222054
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/BlacklistStrategy.scala ---
    @@ -0,0 +1,156 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.scheduler
    +
    +import scala.collection.mutable
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.SparkConf
    +import org.apache.spark.util.SystemClock
    +
    +/**
    + * The interface to determine executor blacklist and node blacklist.
    + */
    +trait BlacklistStrategy {
    +  val expireTimeInMillisecond: Long
    +
    +  // TaskId is optional here because the BlacklistStrategy could be unrelated to TaskId
    +  def getExecutorBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus],
    +      taskId: Option[Long]): Set[String]
    +
    +  def getNodeBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus],
    +      taskId: Option[Long]): Set[String]
    +
    +  // Default implementation to remove failure executors from HashMap based on given time
period.
    +  def expireExecutorsInBlackList(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus]): Unit = {
    +    val now = new SystemClock().getTimeMillis()
    +    failedExecutorMap.retain((executorid, failureStatus) => {
    +      (now - failureStatus.updatedTime) < expireTimeInMillisecond
    +    })
    +  }
    +}
    +
    +/**
    + * The interface for taskId unrelated strategy. In this case, provided taskId will be
ignored. The
    + * benefit for taskId unrelated strategy is different taskSets can learn experience from
other
    + * taskSet to avoid allocating tasks to problematic executors.
    + */
    +trait TaskUnrelatedBlacklistStrategy extends BlacklistStrategy with Logging{
    +  def getExecutorBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus],
    +      taskId: Option[Long]): Set[String] = {
    +    if (taskId.isDefined){
    +      logWarning("TaskId unrelated strategy is applied, given taskId will be ignored")
    +    }
    +    getExecutorBlacklist(failedExecutorMap)
    +  }
    +
    +  def getNodeBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus],
    +      taskId: Option[Long]): Set[String] = {
    +    if (taskId.isDefined){
    +      logWarning("TaskId unrelated strategy is applied, given taskId will be ignored")
    +    }
    +    getNodeBlacklist(failedExecutorMap)
    +  }
    +
    +  // define new interface which remove taskId from parameter.
    +  def getExecutorBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus]): Set[String]
    +  def getNodeBlacklist(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus]): Set[String]
    +}
    +
    +/**
    + * This strategy is simply based on given threshold and is taskId unrelated. An executor
will be
    + * in blacklist, if it failed more than "maxFailureTaskNumber" times. A node will be
in blacklist,
    + * if there are more than "maxBlackExecutorNumber" executors on it in executor blacklist.
    + */
    +class SimpleStrategy(
    +    maxFailureTaskNumber: Int,
    +    maxBlackExecutorNumber: Int,
    +    val expireTimeInMillisecond: Long
    +  )extends TaskUnrelatedBlacklistStrategy {
    +
    +  private def getSelectedExecutorMap(
    +      failedExecutorMap: mutable.HashMap[String, FailureStatus]) = {
    +    failedExecutorMap.filter{
    +      case (id, failureStatus) => failureStatus.failureTimes > maxFailureTaskNumber
    +    }
    +  }
    +
    +  def getExecutorBlacklist(
    +      failureExecutors: mutable.HashMap[String, FailureStatus]): Set[String] = {
    +    getSelectedExecutorMap(failureExecutors).keys.toSet
    +  }
    +
    +  def getNodeBlacklist(
    +      failureExecutors: mutable.HashMap[String, FailureStatus]): Set[String] = {
    --- End diff --
    
    ah, I was thinking before that the runtime would be proportional to the number of executors,
but its really just dependent on the executors w/ failed tasks.  Still I think it is probably
good to minimize the work done here if we can and its not too hard.  For instance, one easy
thing is just avoiding querying the sparkConf inside this function ( currently there is `sparkConf.getBoolean("spark.scheduler.blacklist.speculate",
false)`).
    
    I see now that it is a little hard to do the caching, given the separation between `BlacklistTracker`
and `BlacklistStrategy`, since `BlacklistStrategy` is responsible for updating `failureExecutors`,
and there is also a time-expiration as well.  I dont' see how a `isChanged` boolean is enough
to manage this, but maybe I'm wrong -- happy to look at the code.  I was thinking you would
need a `failedExecutorVersion: Long`, which gets incremented by the tracker if its ever updated,
but maybe there is something simpler.
    
    I will think about this some more ...


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message