cloud-fan commented on a change in pull request #26040: [SPARK-9853][Core]
Optimize shuffle fetch of continuous partition IDs
URL: https://github.com/apache/spark/pull/26040#discussion_r335485913
##########
File path:
core/src/main/scala/org/apache/spark/network/netty/NettyBlockRpcServer.scala
##########
@@ -65,12 +65,30 @@ class NettyBlockRpcServer(
case fetchShuffleBlocks: FetchShuffleBlocks =>
val blocks = fetchShuffleBlocks.mapIds.zipWithIndex.flatMap { case
(mapId, index) =>
- fetchShuffleBlocks.reduceIds.apply(index).map { reduceId =>
- blockManager.getBlockData(
- ShuffleBlockId(fetchShuffleBlocks.shuffleId, mapId, reduceId))
+ if (!fetchShuffleBlocks.batchFetchEnabled) {
+ fetchShuffleBlocks.reduceIds(index).map { reduceId =>
+ blockManager.getBlockData(
+ ShuffleBlockId(fetchShuffleBlocks.shuffleId, mapId, reduceId))
+ }
+ } else {
+ val startAndEndId = fetchShuffleBlocks.reduceIds(index)
+ if (startAndEndId.length != 2) {
+ throw new IllegalStateException(s"Invalid shuffle fetch request
when batch mode " +
+ s"is enabled: $fetchShuffleBlocks")
+ }
+ Array(blockManager.getBlockData(
+ ShuffleBlockBatchId(
+ fetchShuffleBlocks.shuffleId, mapId, startAndEndId(0),
startAndEndId(1))))
}
}
- val numBlockIds = fetchShuffleBlocks.reduceIds.map(_.length).sum
+
+ val reduceIdsNum = fetchShuffleBlocks.reduceIds.map(_.length).sum
Review comment:
nit:
```
val numBlockIds = if (fetchShuffleBlocks.batchFetchEnabled) {
fetchShuffleBlocks.mapIds.length
} else {
fetchShuffleBlocks.reduceIds.map(_.length).sum
}
```
----------------------------------------------------------------
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]