You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/29 21:10:25 UTC

[GitHub] [spark] liuzqt opened a new pull request, #37713: fix task result size issue

liuzqt opened a new pull request, #37713:
URL: https://github.com/apache/spark/pull/37713

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   When calculating driver result size, only counting actual result value while excluding other metadata (e.g., accumUpdates) in the serialized result task object.
   
   
   ### Why are the changes needed?
   metadata should not be counted because they will be discarded by the driver immediately after being processed, and will lead to unexpected exception when running jobs with tons of task but actually return small results.
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   Unit test


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] JoshRosen commented on a diff in pull request #37713: [SPARK-40261][CORE]Exclude TaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
JoshRosen commented on code in PR #37713:
URL: https://github.com/apache/spark/pull/37713#discussion_r957829146


##########
core/src/main/scala/org/apache/spark/scheduler/TaskResultGetter.scala:
##########
@@ -73,7 +73,7 @@ private[spark] class TaskResultGetter(sparkEnv: SparkEnv, scheduler: TaskSchedul
               // We should call it here, so that when it's called again in
               // "TaskSetManager.handleSuccessfulTask", it does not need to deserialize the value.
               directResult.value(taskResultSerializer.get())
-              (directResult, serializedData.limit())
+              (directResult, directResult.valueBytes.limit())

Review Comment:
   We might want to keep this `size` calculation unchanged in order to be consistent with how `IndirectTaskResult.size` is calculated:
   
   https://github.com/apache/spark/blob/c95ed826e23fdec6e1a779cfebde7b3364594fb5/core/src/main/scala/org/apache/spark/executor/Executor.scala#L656-L666
   
   There, it's calculated by first serializing the result into a `DirectTaskResult` and then taking its size.
   
   If we roll back the change to this line then the old definition of `size` will still be used (ensuring that we're consistent w.r.t. the old meaning of the result size internal accumulator that's populated from `size`).



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] xuanyuanking commented on a diff in pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
xuanyuanking commented on code in PR #37713:
URL: https://github.com/apache/spark/pull/37713#discussion_r958798741


##########
core/src/test/scala/org/apache/spark/scheduler/TaskResultGetterSuite.scala:
##########
@@ -297,6 +298,18 @@ class TaskResultGetterSuite extends SparkFunSuite with BeforeAndAfter with Local
     assert(unknownFailure.findFirstMatchIn(message).isDefined)
   }
 
+  test("SPARK-40261 task result metadata should not be counted into result size") {
+    val conf = new SparkConf().set(MAX_RESULT_SIZE.key, "1M")
+    sc = new SparkContext("local", "test", conf)
+    val rdd = sc.parallelize(1 to 10000, 10000)
+    // This will trigger 10k task but return empty result. The total serialized return tasks
+    // size(including accumUpdates metadata) would be ~10M in total in this example, but the result
+    // value itself is pretty small(empty arrays)
+    // Even setting MAX_RESULT_SIZE to a small value(1M here), it should not throw exception
+    // because the actual result is small
+    rdd.filter(_ < 0).collect()

Review Comment:
   +1
   and could you explain more on what's the behavior for this test before your fix?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Ngone51 commented on a diff in pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
Ngone51 commented on code in PR #37713:
URL: https://github.com/apache/spark/pull/37713#discussion_r957952476


##########
core/src/test/scala/org/apache/spark/scheduler/TaskResultGetterSuite.scala:
##########
@@ -297,6 +298,18 @@ class TaskResultGetterSuite extends SparkFunSuite with BeforeAndAfter with Local
     assert(unknownFailure.findFirstMatchIn(message).isDefined)
   }
 
+  test("SPARK-40261 task result metadata should not be counted into result size") {

Review Comment:
   ```suggestion
     test("SPARK-40261: task result metadata should not be counted into result size") {
   ```



##########
core/src/test/scala/org/apache/spark/scheduler/TaskResultGetterSuite.scala:
##########
@@ -297,6 +298,18 @@ class TaskResultGetterSuite extends SparkFunSuite with BeforeAndAfter with Local
     assert(unknownFailure.findFirstMatchIn(message).isDefined)
   }
 
+  test("SPARK-40261 task result metadata should not be counted into result size") {
+    val conf = new SparkConf().set(MAX_RESULT_SIZE.key, "1M")
+    sc = new SparkContext("local", "test", conf)
+    val rdd = sc.parallelize(1 to 10000, 10000)
+    // This will trigger 10k task but return empty result. The total serialized return tasks
+    // size(including accumUpdates metadata) would be ~10M in total in this example, but the result
+    // value itself is pretty small(empty arrays)
+    // Even setting MAX_RESULT_SIZE to a small value(1M here), it should not throw exception
+    // because the actual result is small
+    rdd.filter(_ < 0).collect()

Review Comment:
   ```suggestion
       assert(rdd.filter(_ < 0).collect() === 0)
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37713:
URL: https://github.com/apache/spark/pull/37713#issuecomment-1231445496

   Can one of the admins verify this patch?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] liuzqt commented on a diff in pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
liuzqt commented on code in PR #37713:
URL: https://github.com/apache/spark/pull/37713#discussion_r958809543


##########
core/src/test/scala/org/apache/spark/scheduler/TaskResultGetterSuite.scala:
##########
@@ -297,6 +298,18 @@ class TaskResultGetterSuite extends SparkFunSuite with BeforeAndAfter with Local
     assert(unknownFailure.findFirstMatchIn(message).isDefined)
   }
 
+  test("SPARK-40261 task result metadata should not be counted into result size") {
+    val conf = new SparkConf().set(MAX_RESULT_SIZE.key, "1M")
+    sc = new SparkContext("local", "test", conf)
+    val rdd = sc.parallelize(1 to 10000, 10000)
+    // This will trigger 10k task but return empty result. The total serialized return tasks
+    // size(including accumUpdates metadata) would be ~10M in total in this example, but the result
+    // value itself is pretty small(empty arrays)
+    // Even setting MAX_RESULT_SIZE to a small value(1M here), it should not throw exception
+    // because the actual result is small
+    rdd.filter(_ < 0).collect()

Review Comment:
   Before the fix, it will throw exception defined [here](https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala#L780) .  This rdd operation is just to contrive a example reproducing that exception (trigger large amounts of data but collecting empty result)



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] mridulm commented on pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
mridulm commented on PR #37713:
URL: https://github.com/apache/spark/pull/37713#issuecomment-1231176576

   I have seen overheads upto 10's KB or higher (N-way joins where N is very very large) - but inspite of that, I would agree with @JoshRosen's analysis that we dont need to bring `IndirectTaskResult` in scope for this change.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] JoshRosen closed pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
JoshRosen closed pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size
URL: https://github.com/apache/spark/pull/37713


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] liuzqt commented on a diff in pull request #37713: [SPARK-40261][CORE]Exclude DirectTaskResult metadata when calculating result size

Posted by GitBox <gi...@apache.org>.
liuzqt commented on code in PR #37713:
URL: https://github.com/apache/spark/pull/37713#discussion_r958809543


##########
core/src/test/scala/org/apache/spark/scheduler/TaskResultGetterSuite.scala:
##########
@@ -297,6 +298,18 @@ class TaskResultGetterSuite extends SparkFunSuite with BeforeAndAfter with Local
     assert(unknownFailure.findFirstMatchIn(message).isDefined)
   }
 
+  test("SPARK-40261 task result metadata should not be counted into result size") {
+    val conf = new SparkConf().set(MAX_RESULT_SIZE.key, "1M")
+    sc = new SparkContext("local", "test", conf)
+    val rdd = sc.parallelize(1 to 10000, 10000)
+    // This will trigger 10k task but return empty result. The total serialized return tasks
+    // size(including accumUpdates metadata) would be ~10M in total in this example, but the result
+    // value itself is pretty small(empty arrays)
+    // Even setting MAX_RESULT_SIZE to a small value(1M here), it should not throw exception
+    // because the actual result is small
+    rdd.filter(_ < 0).collect()

Review Comment:
   Before the fix, it will throw exception defined [here](https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala#L780) .  This rdd operation is just to contrive a example reproducing that exception (trigger large amounts of task but actually collecting empty result)



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org