SteNicholas commented on code in PR #2549:
URL: https://github.com/apache/celeborn/pull/2549#discussion_r1636029741


##########
client-spark/spark-3/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornShuffleReader.scala:
##########
@@ -214,46 +219,71 @@ class CelebornShuffleReader[K, C](
             locations,
             streamHandlers,
             fileGroups.mapAttempts,
-            metricsCallback)
+            metricsCallback,
+            chunkPrefetchEnabled)
+          streams.put(partitionId, inputStream)
         } catch {
           case e: IOException =>
             logError(s"Exception caught when readPartition $partitionId!", e)
             exceptionRef.compareAndSet(null, e)
-            null
           case e: Throwable =>
             logError(s"Non IOException caught when readPartition 
$partitionId!", e)
             exceptionRef.compareAndSet(null, new CelebornIOException(e))
-            null
         }
-      } else null
+      }
     }
 
+    (startPartition until Math.min(
+      startPartition + inputStreamCreationWindow,
+      endPartition)).foreach(partitionId => {
+      streamCreatorPool.submit(new Runnable {
+        override def run(): Unit = {
+          createInputStream(partitionId)
+        }
+      })
+    })
+
     val recordIter = (startPartition until 
endPartition).iterator.map(partitionId => {
       if (handle.numMappers > 0) {
         val startFetchWait = System.nanoTime()
-        val inputStream: CelebornInputStream = createInputStream(partitionId)
-        if (exceptionRef.get() != null) {
-          exceptionRef.get() match {
-            case ce @ (_: CelebornIOException | _: 
PartitionUnRetryAbleException) =>
-              if (throwsFetchFailure &&
-                shuffleClient.reportShuffleFetchFailure(handle.shuffleId, 
shuffleId)) {
-                throw new FetchFailedException(
-                  null,
-                  handle.shuffleId,
-                  -1,
-                  -1,
-                  partitionId,
-                  SparkUtils.FETCH_FAILURE_ERROR_MSG + handle.shuffleId + "/" 
+ shuffleId,
-                  ce)
-              } else
-                throw ce
-            case e => throw e
+        var inputStream: CelebornInputStream = streams.get(partitionId)
+        while (inputStream == null) {
+          if (exceptionRef.get() != null) {
+            exceptionRef.get() match {
+              case ce @ (_: CelebornIOException | _: 
PartitionUnRetryAbleException) =>
+                if (throwsFetchFailure &&
+                  shuffleClient.reportShuffleFetchFailure(handle.shuffleId, 
shuffleId)) {
+                  throw new FetchFailedException(
+                    null,
+                    handle.shuffleId,
+                    -1,
+                    -1,
+                    partitionId,
+                    SparkUtils.FETCH_FAILURE_ERROR_MSG + handle.shuffleId + 
"/" + shuffleId,
+                    ce)
+                } else
+                  throw ce
+              case e => throw e
+            }
           }
+          logInfo("inputStream is null, sleeping...")
+          Thread.sleep(50)

Review Comment:
   Why does this sleep 50 millseconds?



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