cfmcgrady commented on code in PR #1876:
URL:
https://github.com/apache/incubator-celeborn/pull/1876#discussion_r1314791055
##########
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) {
+ throw exceptionRef.get()
+ }
+ Thread.sleep(50)
+ inputStream = streams.get(partitionId)
+ }
metricsCallback.incReadTime(System.currentTimeMillis() - start)
inputStream.setCallback(metricsCallback)
// ensure inputStream is closed when task completes
Review Comment:
~~we need to close all `streams`.~~
--
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]