vanzin commented on a change in pull request #25299: [SPARK-27651][Core] Avoid
the network when shuffle blocks are fetched from the same host
URL: https://github.com/apache/spark/pull/25299#discussion_r318239195
##########
File path:
core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
##########
@@ -358,12 +382,65 @@ final class ShuffleBlockFetcherIterator(
}
}
+
+ /**
+ * Fetch the host-local blocks while we are fetching remote blocks. This is
ok because
+ * `ManagedBuffer`'s memory is allocated lazily when we create the input
stream, so all we
+ * track in-memory are the ManagedBuffer references themselves.
+ */
+ private[this] def fetchHostLocalBlocks() {
+ logDebug(s"Start fetching host-local blocks: ${hostLocalBlocks.mkString(",
")}")
+ val hostLocalExecutorIds =
hostLocalBlocksByExecutor.keySet.map(_.executorId)
+ val readsWithoutLocalDir = LinkedHashMap[BlockManagerId, Seq[(BlockId,
Long)]]()
+ val localDirsByExec =
blockManager.getHostLocalDirs(hostLocalExecutorIds.toArray)
+ hostLocalBlocksByExecutor.foreach { case (bmId, blockInfos) =>
+ val localDirs = localDirsByExec.get(bmId.executorId)
+ if (localDirs.isDefined) {
+ blockInfos.foreach { case (blockId, _) =>
+ try {
+ val buf = blockManager
+ .getHostLocalShuffleData(blockId.asInstanceOf[ShuffleBlockId],
localDirs.get)
Review comment:
Actually this is a good point. I think it might be a good idea for
`blockManager.getHostLocalDirs` to be more asynchronous: return whatever
current data it has about local dirs, and asynchronously ask the driver the
location of local dirs for the missing executors.
This would allow the shuffle to make progress without synchronizing all
tasks on the driver to retrieve this information. You'll still send potentially
a lot of messages to the driver in that initial burst of activity, but at least
it won't actually slow down the shuffle.
The RPC to the driver timing out is not a big issue for this code (since the
executor knows how to get the data through other means), but it would indicate
that the driver is backed up for other reasons. I don't think this particular
RPC by itself would cause those issues.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]