otterc commented on a change in pull request #32140: URL: https://github.com/apache/spark/pull/32140#discussion_r649449168
########## File path: core/src/main/scala/org/apache/spark/storage/PushBasedFetchHelper.scala ########## @@ -0,0 +1,289 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.storage + +import java.util.concurrent.TimeUnit + +import scala.collection.mutable +import scala.collection.mutable.ArrayBuffer +import scala.util.{Failure, Success} + +import org.roaringbitmap.RoaringBitmap + +import org.apache.spark.MapOutputTracker +import org.apache.spark.MapOutputTracker.SHUFFLE_PUSH_MAP_ID +import org.apache.spark.internal.Logging +import org.apache.spark.network.buffer.ManagedBuffer +import org.apache.spark.network.shuffle.{BlockStoreClient, MergedBlockMeta, MergedBlocksMetaListener} +import org.apache.spark.storage.BlockManagerId.SHUFFLE_MERGER_IDENTIFIER +import org.apache.spark.storage.ShuffleBlockFetcherIterator._ + +/** + * Helper class for [[ShuffleBlockFetcherIterator]] that encapsulates all the push-based + * functionality to fetch merged block meta and merged shuffle block chunks. + */ +private class PushBasedFetchHelper( + private val iterator: ShuffleBlockFetcherIterator, + private val shuffleClient: BlockStoreClient, + private val blockManager: BlockManager, + private val mapOutputTracker: MapOutputTracker) extends Logging { + + private[this] val startTimeNs = System.nanoTime() + + private[this] val localShuffleMergerBlockMgrId = BlockManagerId( + SHUFFLE_MERGER_IDENTIFIER, blockManager.blockManagerId.host, + blockManager.blockManagerId.port, blockManager.blockManagerId.topologyInfo) + + /** A map for storing merged block shuffle chunk bitmap */ + private[this] val chunksMetaMap = new mutable.HashMap[ShuffleBlockChunkId, RoaringBitmap]() + + /** + * Returns true if the address is for a push-merged block. + */ + def isMergedShuffleBlockAddress(address: BlockManagerId): Boolean = { + SHUFFLE_MERGER_IDENTIFIER.equals(address.executorId) + } + + /** + * Returns true if the address is not of executor local or merged local block. false otherwise. + */ + def isNotExecutorOrMergedLocal(address: BlockManagerId): Boolean = { + (isMergedShuffleBlockAddress(address) && address.host != blockManager.blockManagerId.host) || + (!isMergedShuffleBlockAddress(address) && address != blockManager.blockManagerId) Review comment: Thanks for pointing this out. This method is always called for a merged shuffle block or chunk where `isMergedShuffleBlockAddress(address)` is going to be `true`. It is called from 2 places in iterator where we we just want to know if the merged block/chunk is remote or not. I am going to change this method name and implementation so it does what it is intended for. We do follow the same method for fetching merged local blocks which was introduced in SPARK-27651. -- 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