mridulm commented on code in PR #36165: URL: https://github.com/apache/spark/pull/36165#discussion_r1034209167
########## core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala: ########## @@ -722,6 +718,63 @@ final class ShuffleBlockFetcherIterator( } } + // Number of map blocks in a ShuffleBlockChunk + private def getShuffleChunkCardinality(blockId: ShuffleBlockChunkId): Int = { + val chunkTracker = pushBasedFetchHelper.getRoaringBitMap(blockId) + chunkTracker match { + case Some(bitmap) => bitmap.getCardinality + case None => 0 + } + } + + // Check if the merged block is local to the host or not + private def isLocalMergedBlockAddress(address: BlockManagerId): Boolean = { + address.executorId.isEmpty && address.host == blockManager.blockManagerId.host + } + + private def shuffleMetricsUpdate( + blockId: BlockId, + buf: ManagedBuffer, + isLocal: Boolean): Unit = { + if (isLocal) { + shuffleLocalMetricsUpdate(blockId, buf) + } else { + shuffleRemoteMetricsUpdate(blockId, buf) + } + } + + private def shuffleLocalMetricsUpdate(blockId: BlockId, buf: ManagedBuffer): Unit = { + // Check if the block is within the host-local blocks set, or if it is a merged local + // block. In either case, it is local read and we need to increase the local + // shuffle read metrics. + blockId match { + case chunkId: ShuffleBlockChunkId => + shuffleMetrics.incLocalMergedChunksFetched(1) + shuffleMetrics.incLocalMergedBlocksFetched(getShuffleChunkCardinality(chunkId)) + shuffleMetrics.incLocalMergedBlocksBytesRead(buf.size) + shuffleMetrics.incLocalBlocksFetched(getShuffleChunkCardinality(chunkId)) Review Comment: Take a look at the snippet above - it is used twice :-) Same in `shuffleRemoteMetricsUpdate` -- 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: reviews-unsubscr...@spark.apache.org 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