RexXiong commented on code in PR #1876:
URL: 
https://github.com/apache/incubator-celeborn/pull/1876#discussion_r1314824712


##########
client-spark/spark-3/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornShuffleReader.scala:
##########
@@ -62,15 +70,51 @@ class CelebornShuffleReader[K, C](
         metrics.incFetchWaitTime(time)
     }
 
+    if (streamCreatorPool == null) {
+      CelebornShuffleReader.synchronized {
+        if (streamCreatorPool == null) {
+          streamCreatorPool = ThreadUtils.newDaemonCachedThreadPool(
+            "create-stream-thread",

Review Comment:
   Naming pool with `celeborn` prefix



##########
client-spark/spark-3/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornShuffleReader.scala:
##########
@@ -62,15 +70,51 @@ class CelebornShuffleReader[K, C](
         metrics.incFetchWaitTime(time)
     }
 
+    if (streamCreatorPool == null) {
+      CelebornShuffleReader.synchronized {
+        if (streamCreatorPool == null) {
+          streamCreatorPool = ThreadUtils.newDaemonCachedThreadPool(
+            "create-stream-thread",
+            conf.readStreamCreatorPoolThreads,
+            60);
+        }
+      }
+    }
+
+    val streams = new ConcurrentHashMap[Integer, CelebornInputStream]()
+    (startPartition until endPartition).map(partitionId => {
+      streamCreatorPool.submit(new Runnable {
+        override def run(): Unit = {
+          if (exceptionRef.get() == null) {
+            try {
+              val inputStream = shuffleClient.readPartition(
+                handle.shuffleId,
+                partitionId,
+                context.attemptNumber(),
+                startMapIndex,
+                endMapIndex)
+              streams.put(partitionId, inputStream)
+            } catch {
+              case e: IOException =>
+                logInfo("Exception caught when readPartition!")
+                exceptionRef.compareAndSet(null, e)
+            }
+          }
+        }
+      })
+    })
+
     val recordIter = (startPartition until 
endPartition).iterator.map(partitionId => {
       if (handle.numMappers > 0) {
         val start = System.currentTimeMillis()
-        val inputStream = shuffleClient.readPartition(
-          handle.shuffleId,
-          partitionId,
-          context.attemptNumber(),
-          startMapIndex,
-          endMapIndex)
+        var inputStream: CelebornInputStream = streams.get(partitionId)
+        while (inputStream == null) {
+          if (exceptionRef.get() != null) {

Review Comment:
   +1



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to