Github user squito commented on a diff in the pull request:
https://github.com/apache/spark/pull/8760#discussion_r40089514
--- 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 --
these functions get called a *lot* (at least once per scheduled task).
They will almost always return the same answer in successive calls, but they
are doing non-trivial work in each call (several operations over large
collections, eg. filtering, summing values, etc.). We should probably cache
those values and just update when there are more failures (probably need to be
careful on thread-safety).
---
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]