viirya commented on a change in pull request #28911: URL: https://github.com/apache/spark/pull/28911#discussion_r459673702
########## File path: core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala ########## @@ -466,42 +464,51 @@ final class ShuffleBlockFetcherIterator( val cachedDirsByExec = hostLocalDirManager.getCachedHostLocalDirs() val (hostLocalBlocksWithCachedDirs, hostLocalBlocksWithMissingDirs) = hostLocalBlocksByExecutor - .map { case (hostLocalBmId, bmInfos) => - (hostLocalBmId, bmInfos, cachedDirsByExec.get(hostLocalBmId.executorId)) + .map { case (hostLocalBmId, blockInfos) => + (hostLocalBmId, blockInfos, cachedDirsByExec.get(hostLocalBmId.executorId)) }.partition(_._3.isDefined) - val bmId = blockManager.blockManagerId val immutableHostLocalBlocksWithoutDirs = - hostLocalBlocksWithMissingDirs.map { case (hostLocalBmId, bmInfos, _) => - hostLocalBmId -> bmInfos + hostLocalBlocksWithMissingDirs.map { case (hostLocalBmId, blockInfos, _) => + hostLocalBmId -> blockInfos }.toMap if (immutableHostLocalBlocksWithoutDirs.nonEmpty) { logDebug(s"Asynchronous fetching host-local blocks without cached executors' dir: " + s"${immutableHostLocalBlocksWithoutDirs.mkString(", ")}") - val execIdsWithoutDirs = immutableHostLocalBlocksWithoutDirs.keys.map(_.executorId).toArray - hostLocalDirManager.getHostLocalDirs(execIdsWithoutDirs) { - case Success(dirs) => - immutableHostLocalBlocksWithoutDirs.foreach { case (hostLocalBmId, blockInfos) => - blockInfos.takeWhile { case (blockId, _, mapIndex) => - fetchHostLocalBlock( - blockId, - mapIndex, - dirs.get(hostLocalBmId.executorId), - hostLocalBmId) + val dirFetchRequests = if (blockManager.externalShuffleServiceEnabled) { + val host = blockManager.blockManagerId.host + val port = blockManager.externalShuffleServicePort + Seq((host, port, immutableHostLocalBlocksWithoutDirs.keys.toArray)) + } else { + immutableHostLocalBlocksWithoutDirs.keys + .map(bmId => (bmId.host, bmId.port, Array(bmId))).toSeq + } + + dirFetchRequests.foreach { case (host, port, bmIds) => + hostLocalDirManager.getHostLocalDirs(host, port, bmIds.map(_.executorId)) { + case Success(dirsByExecId) => + bmIds.foreach { bmId => + val dirs = dirsByExecId.get(bmId.executorId) + immutableHostLocalBlocksWithoutDirs(bmId) + .takeWhile { case (blockId, _, mapIndex) => + fetchHostLocalBlock(blockId, mapIndex, dirs, bmId) + } } - } - logDebug(s"Got host-local blocks (without cached executors' dir) in " + - s"${Utils.getUsedTimeNs(startTimeNs)}") - - case Failure(throwable) => - logError(s"Error occurred while fetching host local blocks", throwable) - val (hostLocalBmId, blockInfoSeq) = immutableHostLocalBlocksWithoutDirs.head - val (blockId, _, mapIndex) = blockInfoSeq.head - results.put(FailureFetchResult(blockId, mapIndex, hostLocalBmId, throwable)) + logDebug(s"Got host-local blocks (without cached executors' dir) in " + + s"${Utils.getUsedTimeNs(startTimeNs)}") + + case Failure(throwable) => + logError(s"Error occurred while fetching host local blocks", throwable) Review comment: s"" is not needed. ########## File path: core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala ########## @@ -466,42 +464,51 @@ final class ShuffleBlockFetcherIterator( val cachedDirsByExec = hostLocalDirManager.getCachedHostLocalDirs() val (hostLocalBlocksWithCachedDirs, hostLocalBlocksWithMissingDirs) = hostLocalBlocksByExecutor - .map { case (hostLocalBmId, bmInfos) => - (hostLocalBmId, bmInfos, cachedDirsByExec.get(hostLocalBmId.executorId)) + .map { case (hostLocalBmId, blockInfos) => + (hostLocalBmId, blockInfos, cachedDirsByExec.get(hostLocalBmId.executorId)) }.partition(_._3.isDefined) - val bmId = blockManager.blockManagerId val immutableHostLocalBlocksWithoutDirs = - hostLocalBlocksWithMissingDirs.map { case (hostLocalBmId, bmInfos, _) => - hostLocalBmId -> bmInfos + hostLocalBlocksWithMissingDirs.map { case (hostLocalBmId, blockInfos, _) => + hostLocalBmId -> blockInfos }.toMap if (immutableHostLocalBlocksWithoutDirs.nonEmpty) { logDebug(s"Asynchronous fetching host-local blocks without cached executors' dir: " + s"${immutableHostLocalBlocksWithoutDirs.mkString(", ")}") - val execIdsWithoutDirs = immutableHostLocalBlocksWithoutDirs.keys.map(_.executorId).toArray - hostLocalDirManager.getHostLocalDirs(execIdsWithoutDirs) { - case Success(dirs) => - immutableHostLocalBlocksWithoutDirs.foreach { case (hostLocalBmId, blockInfos) => - blockInfos.takeWhile { case (blockId, _, mapIndex) => - fetchHostLocalBlock( - blockId, - mapIndex, - dirs.get(hostLocalBmId.executorId), - hostLocalBmId) + val dirFetchRequests = if (blockManager.externalShuffleServiceEnabled) { + val host = blockManager.blockManagerId.host + val port = blockManager.externalShuffleServicePort + Seq((host, port, immutableHostLocalBlocksWithoutDirs.keys.toArray)) + } else { + immutableHostLocalBlocksWithoutDirs.keys + .map(bmId => (bmId.host, bmId.port, Array(bmId))).toSeq + } + + dirFetchRequests.foreach { case (host, port, bmIds) => + hostLocalDirManager.getHostLocalDirs(host, port, bmIds.map(_.executorId)) { + case Success(dirsByExecId) => + bmIds.foreach { bmId => + val dirs = dirsByExecId.get(bmId.executorId) + immutableHostLocalBlocksWithoutDirs(bmId) + .takeWhile { case (blockId, _, mapIndex) => + fetchHostLocalBlock(blockId, mapIndex, dirs, bmId) + } } - } - logDebug(s"Got host-local blocks (without cached executors' dir) in " + - s"${Utils.getUsedTimeNs(startTimeNs)}") - - case Failure(throwable) => - logError(s"Error occurred while fetching host local blocks", throwable) - val (hostLocalBmId, blockInfoSeq) = immutableHostLocalBlocksWithoutDirs.head - val (blockId, _, mapIndex) = blockInfoSeq.head - results.put(FailureFetchResult(blockId, mapIndex, hostLocalBmId, throwable)) + logDebug(s"Got host-local blocks (without cached executors' dir) in " + Review comment: first s"" is not needed. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org