Ngone51 commented on code in PR #38711:
URL: https://github.com/apache/spark/pull/38711#discussion_r1044062231


##########
core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala:
##########
@@ -1178,8 +1178,13 @@ private[spark] class DAGScheduler(
     listenerBus.post(SparkListenerTaskStart(task.stageId, stageAttemptId, 
taskInfo))
   }
 
-  private[scheduler] def handleSpeculativeTaskSubmitted(task: Task[_]): Unit = 
{
-    listenerBus.post(SparkListenerSpeculativeTaskSubmitted(task.stageId, 
task.stageAttemptId))
+  private[scheduler] def handleSpeculativeTaskSubmitted(task: Task[_], 
taskIndex: Int): Unit = {
+    val speculativeTaskSubmittedEvent =
+      SparkListenerSpeculativeTaskSubmitted(task.stageId, task.stageAttemptId)
+    // add taskIndex field for Executor Dynamic Allocation
+    speculativeTaskSubmittedEvent.updateTaskIndex(taskIndex)
+    speculativeTaskSubmittedEvent.updatePartitionId(task.partitionId)
+    listenerBus.post(speculativeTaskSubmittedEvent)

Review Comment:
   How about adding a new apply() to `SparkListenerSpeculativeTaskSubmitted` to 
simplify the construction? e.g.,
   ```scala
   object SparkListenerSpeculativeTaskSubmitted {
     def apply(stageId: Int, stageAttemptId: Int, taskIndex: Int, partitionId: 
Int)
       : SparkListenerSpeculativeTaskSubmitted = {
       val speculativeTaskSubmittedEvent =
         SparkListenerSpeculativeTaskSubmitted(stageId, stageAttemptId)
       // add taskIndex field for Executor Dynamic Allocation
       speculativeTaskSubmittedEvent.updateTaskIndex(taskIndex)
       speculativeTaskSubmittedEvent.updatePartitionId(task.partitionId)
       speculativeTaskSubmittedEvent
     }
   ```
   so here we can construct the `SparkListenerSpeculativeTaskSubmitted` like `  
    SparkListenerSpeculativeTaskSubmitted(task.stageId, task.stageAttemptId, 
taskIndex, task.partitionId)
   ` and I think it'd be less error-prone in case of users forget to call 
updates.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to