dongjoon-hyun commented on a change in pull request #33109:
URL: https://github.com/apache/spark/pull/33109#discussion_r659483474



##########
File path: 
core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
##########
@@ -379,13 +378,13 @@ final class ShuffleBlockFetcherIterator(
         hostLocalBlocks ++= blocksForAddress.map(info => (info._1, info._3))
         hostLocalBlockBytes += mergedBlockInfos.map(_.size).sum
       } else {
-        remoteBlockBytes += blockInfos.map(_._2).sum
         val (_, timeCost) = Utils.timeTakenMs[Unit] {
           collectFetchRequests(address, blockInfos, collectedRemoteRequests)
         }
         logDebug(s"Collected remote fetch requests for $address in $timeCost 
ms")
       }
     }
+    val remoteBlockBytes = collectedRemoteRequests.map(_.size).sum
     val numRemoteBlocks = collectedRemoteRequests.map(_.blocks.size).sum

Review comment:
       Instead of two iterations, what about the single iteration? Something 
like the following?
   ```scala
   val (remoteBlockBytes, numRemoteBlocks) =
       collectedRemoteRequests.reduce((x, y) => (x.size + y.size, x.blocks.size 
+ y.blocks.size))
   ```




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to