dongjoon-hyun commented on code in PR #45228:
URL: https://github.com/apache/spark/pull/45228#discussion_r1533281979


##########
core/src/main/scala/org/apache/spark/storage/FallbackStorage.scala:
##########
@@ -92,6 +95,57 @@ private[storage] class FallbackStorage(conf: SparkConf) 
extends Logging {
     val hash = JavaUtils.nonNegativeHash(filename)
     fallbackFileSystem.exists(new Path(fallbackPath, 
s"$appId/$shuffleId/$hash/$filename"))
   }
+
+  private val fetchThreadPool: Option[ThreadPoolExecutor] = {
+    val numShuffleThreads = FallbackStorage.getNumReadThreads(conf)
+    if (numShuffleThreads > 0) {
+      logInfo(s"FallbackStorage created thread pool using  
${numShuffleThreads} thread(s)")
+      Some(ThreadUtils.newDaemonCachedThreadPool(
+        "FetchFromFallbackStorage-threadPool", numShuffleThreads))
+    } else {
+      logInfo("FallbackStorage thread pool not created")
+      None
+    }
+  }
+
+  def fetchBlocks(
+      blockManager: BlockManager,
+      blocks: collection.Seq[FetchBlockInfo],
+      address: BlockManagerId,
+      listener: BlockFetchingListener): Unit = {
+    fetchThreadPool match {
+      case Some(p) if !p.isShutdown =>
+        blocks.foreach(block =>
+          p.submit(new Runnable {
+            override def run(): Unit = {
+              fetchShuffleBlocks(block, blockManager, listener)
+            }
+          })
+        )
+      case _ =>
+        logInfo(s" fetchThreadPool does not exists for $address or shutdown")
+        blocks.foreach(block => fetchShuffleBlocks(block, blockManager, 
listener))
+    }
+  }
+
+  private def fetchShuffleBlocks(
+              block: FetchBlockInfo,

Review Comment:
   indentation.



##########
core/src/main/scala/org/apache/spark/storage/FallbackStorage.scala:
##########
@@ -92,6 +95,57 @@ private[storage] class FallbackStorage(conf: SparkConf) 
extends Logging {
     val hash = JavaUtils.nonNegativeHash(filename)
     fallbackFileSystem.exists(new Path(fallbackPath, 
s"$appId/$shuffleId/$hash/$filename"))
   }
+
+  private val fetchThreadPool: Option[ThreadPoolExecutor] = {
+    val numShuffleThreads = FallbackStorage.getNumReadThreads(conf)
+    if (numShuffleThreads > 0) {
+      logInfo(s"FallbackStorage created thread pool using  
${numShuffleThreads} thread(s)")
+      Some(ThreadUtils.newDaemonCachedThreadPool(
+        "FetchFromFallbackStorage-threadPool", numShuffleThreads))
+    } else {
+      logInfo("FallbackStorage thread pool not created")
+      None
+    }
+  }
+
+  def fetchBlocks(
+      blockManager: BlockManager,
+      blocks: collection.Seq[FetchBlockInfo],
+      address: BlockManagerId,
+      listener: BlockFetchingListener): Unit = {
+    fetchThreadPool match {
+      case Some(p) if !p.isShutdown =>
+        blocks.foreach(block =>
+          p.submit(new Runnable {
+            override def run(): Unit = {
+              fetchShuffleBlocks(block, blockManager, listener)
+            }
+          })
+        )
+      case _ =>
+        logInfo(s" fetchThreadPool does not exists for $address or shutdown")
+        blocks.foreach(block => fetchShuffleBlocks(block, blockManager, 
listener))
+    }
+  }
+
+  private def fetchShuffleBlocks(
+              block: FetchBlockInfo,

Review Comment:
   indentation?



-- 
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

Reply via email to