Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/15541#discussion_r84591073
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala ---
@@ -250,24 +251,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 currentOffer = taskAssigner.next()
+ val execId = currentOffer.workOffer.executorId
+ val host = currentOffer.workOffer.host
+ if (currentOffer.coresAvailable >= CPUS_PER_TASK) {
try {
for (task <- taskSet.resourceOffer(execId, host, maxLocality)) {
- tasks(i) += task
+ currentOffer.tasks += task
val tid = task.taskId
taskIdToTaskSetManager(tid) = taskSet
taskIdToExecutorId(tid) = execId
executorIdToTaskCount(execId) += 1
- availableCpus(i) -= CPUS_PER_TASK
- assert(availableCpus(i) >= 0)
+ currentOffer.coresAvailable -= CPUS_PER_TASK
+ assert(currentOffer.coresAvailable >= 0)
--- End diff --
Could we add a function in `class OfferState` for including the following
three lines of codes?
```Scala
currentOffer.tasks += task
currentOffer.coresAvailable -= CPUS_PER_TASK
assert(currentOffer.coresAvailable >= 0)
```
---
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]