You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "yihua (via GitHub)" <gi...@apache.org> on 2023/09/15 01:45:50 UTC

[GitHub] [hudi] yihua commented on a diff in pull request #9395: [HUDI-6669] HoodieEngineContext should not use parallel stream with parallelism greater than CPU cores

yihua commented on code in PR #9395:
URL: https://github.com/apache/hudi/pull/9395#discussion_r1326688166


##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieEngineContext.java:
##########
@@ -105,4 +105,12 @@ public abstract <I, K, V> List<V> reduceByKey(
   public abstract void cancelJob(String jobId);
 
   public abstract void cancelAllJobs();
+
+  public <T> Stream<T> stream(List<T> data, Integer parallelism) {
+    return stream(stream(data.stream(), data.size()), parallelism);
+  }
+
+  public <T> Stream<T> stream(Stream<T> data, Integer parallelism) {
+    return parallelism == null || parallelism > Runtime.getRuntime().availableProcessors() ? data : data.parallel();

Review Comment:
   So if `parallelism > Runtime.getRuntime().availableProcessors()`, the `data` is not parallelized at all, as Java's `data.stream()` is sequential by default.  Also to @stream2000 's point, before this PR, the parallelism of `map` is already limited by `Runtime.getRuntime().availableProcessors()`.  Does that still cause OOM?  Is OOM from somewhere else?  



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org