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

    https://github.com/apache/spark/pull/15218#discussion_r83963294
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala ---
    @@ -250,24 +263,26 @@ private[spark] class TaskSchedulerImpl(
       private def resourceOfferSingleTaskSet(
           taskSet: TaskSetManager,
           maxLocality: TaskLocality,
    -      shuffledOffers: Seq[WorkerOffer],
    -      availableCpus: Array[Int],
    -      tasks: IndexedSeq[ArrayBuffer[TaskDescription]]) : Boolean = {
    +      taskAssigner: TaskAssigner) : Boolean = {
         var launchedTask = false
    -    for (i <- 0 until shuffledOffers.size) {
    -      val execId = shuffledOffers(i).executorId
    -      val host = shuffledOffers(i).host
    -      if (availableCpus(i) >= CPUS_PER_TASK) {
    +    taskAssigner.init()
    +    while(taskAssigner.hasNext()) {
    +      var assigned = false
    +      val current = taskAssigner.getNext()
    +      val execId = current.workOffer.executorId
    +      val host = current.workOffer.host
    +      if (current.cores >= CPUS_PER_TASK) {
             try {
               for (task <- taskSet.resourceOffer(execId, host, maxLocality)) {
    -            tasks(i) += task
    +            current.tasks += task
                 val tid = task.taskId
                 taskIdToTaskSetManager(tid) = taskSet
                 taskIdToExecutorId(tid) = execId
                 executorIdToTaskCount(execId) += 1
    -            availableCpus(i) -= CPUS_PER_TASK
    -            assert(availableCpus(i) >= 0)
    +            current.cores = current.cores - CPUS_PER_TASK
    --- End diff --
    
    Do you want to follow the previous style `current.cores -= CPUS_PER_TASK`


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

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

Reply via email to