Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14079#discussion_r69893800
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala ---
    @@ -310,12 +342,38 @@ private[spark] class TaskSchedulerImpl(
           }
         }
     
    -    // Randomly shuffle offers to avoid always placing tasks on the same 
set of workers.
    -    val shuffledOffers = Random.shuffle(offers)
    +    // ensure that we periodically check if executors can be removed from 
the blacklist, without
    +    // requiring a separate thread and added synchronization overhead
    +    blacklistTracker.expireExecutorsInBlacklist()
    +
    +    val sortedTaskSets = rootPool.getSortedTaskSetQueue
    +    val filteredOffers: IndexedSeq[WorkerOffer] = offers.filter { offer =>
    +      !blacklistTracker.isNodeBlacklisted(offer.host)  &&
    +        !blacklistTracker.isExecutorBlacklisted(offer.executorId)
    +    } match {
    +        // toIndexedSeq always makes an *immutable* IndexedSeq, though we 
don't care if its mutable
    +        // or immutable.  So we do this to avoid making a pointless copy
    +      case is: IndexedSeq[WorkerOffer] => is
    +      case other: Seq[WorkerOffer] => other.toIndexedSeq
    +    }
    --- End diff --
    
    this business about `IndexedSeq[WorkerOffer]` vs `Seq[WorkerOffer]` is also 
unrelated to blacklisting, but I ran into it accidentally while doing some 
performance tests.  While `resourceOffer` accepts a `Seq`, it really ought to 
be an `IndexedSeq` given how its used internally (eg. given 500 offers, there 
is a 5x performance difference in the scheduler).  I made this change just 
because its more locally contained ... alternatively we could change the method 
signature and the callsites appropriately.
    
    It *happens* to be an IndexedSeq in the [important callsite in 
CoarseGrainedSchedulerBackend](https://github.com/apache/spark/blob/a04cab8f17fcac05f86d2c472558ab98923f91e3/core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala#L217),
 but that is more by chance than design (a call to `.toSeq` just happens to 
return an `IndexedSeq` for the particular types used)


---
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]

Reply via email to