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

    https://github.com/apache/spark/pull/16867#discussion_r102292835
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala ---
    @@ -911,14 +916,14 @@ private[spark] class TaskSetManager(
         logDebug("Checking for speculative tasks: minFinished = " + 
minFinishedForSpeculation)
         if (tasksSuccessful >= minFinishedForSpeculation && tasksSuccessful > 
0) {
           val time = clock.getTimeMillis()
    -      val durations = 
taskInfos.values.filter(_.successful).map(_.duration).toArray
    -      Arrays.sort(durations)
    +      val durations = successfulTasksSet.toArray.map(taskInfos(_).duration)
    --- End diff --
    
    there are some other things you could do to make the original code more 
efficient:
    a) instead of `.values.filter.map`, use a `foreach` to directly add into an 
`ArrayBuffer`.  That will avoid all the intermediate collections that scala 
would create otherwise.
    b) store an approximate distribution of the runtimes, eg. using a tdigest.
    
    aside: what  pain that there is no quick way to get the middle element of a 
TreeSet -- I couldn't find anything efficient in either the java or scala libs 
:(


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