spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] jiangxb1987 commented on a change in pull request #27972: [SPARK-31207][CORE] Ensure the total number of blocks to fetch equals to the sum of local/hostLocal/remote blocks
Date Tue, 24 Mar 2020 01:06:23 GMT
jiangxb1987 commented on a change in pull request #27972: [SPARK-31207][CORE] Ensure the total
number of blocks to fetch equals to the sum of local/hostLocal/remote blocks
URL: https://github.com/apache/spark/pull/27972#discussion_r396848072
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
 ##########
 @@ -312,19 +310,57 @@ final class ShuffleBlockFetcherIterator(
         hostLocalBlocks ++= blocksForAddress.map(info => (info._1, info._3))
         hostLocalBlockBytes += mergedBlockInfos.map(_.size).sum
       } else {
-        numRemoteBlocks += blockInfos.size
         remoteBlockBytes += blockInfos.map(_._2).sum
         collectFetchRequests(address, blockInfos, collectedRemoteRequests)
       }
     }
+    val numRemoteBlocks = collectedRemoteRequests.map(_.blocks.size).sum
     val totalBytes = localBlockBytes + remoteBlockBytes + hostLocalBlockBytes
+    assert(numBlocksToFetch == localBlocks.size + hostLocalBlocks.size + numRemoteBlocks,
+      s"The number of non-empty blocks $numBlocksToFetch doesn't equal to the number of local
" +
+        s"blocks ${localBlocks.size} + the number of host-local blocks ${hostLocalBlocks.size}
" +
+        s"+ the number of remote blocks ${numRemoteBlocks}.")
     logInfo(s"Getting $numBlocksToFetch (${Utils.bytesToString(totalBytes)}) non-empty blocks
" +
       s"including ${localBlocks.size} (${Utils.bytesToString(localBlockBytes)}) local and
" +
       s"${hostLocalBlocks.size} (${Utils.bytesToString(hostLocalBlockBytes)}) " +
       s"host-local and $numRemoteBlocks (${Utils.bytesToString(remoteBlockBytes)}) remote
blocks")
     collectedRemoteRequests
   }
 
+  def createFetchRequest(
+      blocks: Seq[FetchBlockInfo],
+      address: BlockManagerId,
+      curRequestSize: Long): FetchRequest = {
+    logDebug(s"Creating fetch request of $curRequestSize at $address "
+      + s"with ${blocks.size} blocks")
+    FetchRequest(address, blocks)
+  }
+
+  def createFetchRequests(
+      curBlocks: ArrayBuffer[FetchBlockInfo],
+      address: BlockManagerId,
+      curRequestSize: Long,
+      isLast: Boolean,
+      collectedRemoteRequests: ArrayBuffer[FetchRequest]): ArrayBuffer[FetchBlockInfo] =
{
+    val mergedBlocks = mergeContinuousShuffleBlockIdsIfNeeded(curBlocks)
+    var retBlocks = new ArrayBuffer[FetchBlockInfo]
+    if (mergedBlocks.length <= maxBlocksInFlightPerAddress) {
+      collectedRemoteRequests += createFetchRequest(mergedBlocks, address, curRequestSize)
+    } else {
+      mergedBlocks.grouped(maxBlocksInFlightPerAddress).foreach { blocks =>
+        if (blocks.length == maxBlocksInFlightPerAddress || isLast) {
+          collectedRemoteRequests += createFetchRequest(blocks, address, curRequestSize)
 
 Review comment:
   I'm just moving the original logic around, what's the problem with the `curRequestSize`
?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


Mime
View raw message