You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by "waitinfuture (via GitHub)" <gi...@apache.org> on 2023/09/04 12:01:47 UTC
[GitHub] [incubator-celeborn] waitinfuture commented on a diff in pull request #1876: [CELEBORN-943][PERF] Pre-create CelebornInputStreams in CelebornShuffleReader
waitinfuture commented on code in PR #1876:
URL: https://github.com/apache/incubator-celeborn/pull/1876#discussion_r1314857630
##########
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:
> the method `shuffleClient.readPartition` explicitly declares the throwing of an IOException.
>
> https://github.com/apache/incubator-celeborn/blob/b66eaff880e91864a21c96dbac94fa5f8cd84f4c/client/src/main/java/org/apache/celeborn/client/ShuffleClient.java#L191-L193
Right. Do we have to consider RuntimeException here?
##########
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:
> the method `shuffleClient.readPartition` explicitly declares the throwing of an IOException.
>
> https://github.com/apache/incubator-celeborn/blob/b66eaff880e91864a21c96dbac94fa5f8cd84f4c/client/src/main/java/org/apache/celeborn/client/ShuffleClient.java#L191-L193
Right. Do we need to consider RuntimeException here?
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org