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

    https://github.com/apache/spark/pull/1507#discussion_r15903066
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala 
---
    @@ -98,19 +105,31 @@ class TaskMetrics extends Serializable {
        */
       var updatedBlocks: Option[Seq[(BlockId, BlockStatus)]] = None
     
    -  /** Adds the given ShuffleReadMetrics to any existing shuffle metrics 
for this task. */
    -  def updateShuffleReadMetrics(newMetrics: ShuffleReadMetrics) = 
synchronized {
    -    _shuffleReadMetrics match {
    -      case Some(existingMetrics) =>
    -        existingMetrics.shuffleFinishTime = math.max(
    -          existingMetrics.shuffleFinishTime, newMetrics.shuffleFinishTime)
    -        existingMetrics.fetchWaitTime += newMetrics.fetchWaitTime
    -        existingMetrics.localBlocksFetched += newMetrics.localBlocksFetched
    -        existingMetrics.remoteBlocksFetched += 
newMetrics.remoteBlocksFetched
    -        existingMetrics.remoteBytesRead += newMetrics.remoteBytesRead
    -      case None =>
    -        _shuffleReadMetrics = Some(newMetrics)
    +  /**
    +   * A task may have multiple shuffle readers for multiple dependencies. 
To avoid synchronization
    +   * issues from readers in different threads, in-progress tasks use a 
ShuffleReadMetrics for each
    +   * dependency, and merge these metrics before reporting them to the 
driver. This method returns
    +   * a ShuffleReadMetrics for a dependency and registers it for merging 
later.
    +   */
    +  def createShuffleReadMetricsForDependency(): ShuffleReadMetrics = 
synchronized {
    +    val readMetrics = new ShuffleReadMetrics()
    +    depsShuffleReadMetrics += readMetrics
    +    readMetrics
    +  }
    +
    +  /**
    +   * Aggregates shuffle read metrics for all registered dependencies into 
shuffleReadMetrics.
    +   */
    +  def mergeShuffleReadMetrics() = synchronized {
    --- End diff --
    
    can this be private[spark]?


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