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 2020/09/17 12:46:53 UTC

[GitHub] [spark] tomvanbussel commented on a change in pull request #29785: [SPARK-32901][CORE] Do not allocate memory while spilling UnsafeExternalSorter

tomvanbussel commented on a change in pull request #29785:
URL: https://github.com/apache/spark/pull/29785#discussion_r490214568



##########
File path: core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
##########
@@ -339,29 +342,43 @@ public void cleanupResources() {
   private void growPointerArrayIfNecessary() throws IOException {
     assert(inMemSorter != null);
     if (!inMemSorter.hasSpaceForAnotherRecord()) {
+      if (inMemSorter.numRecords() <= 0) {

Review comment:
       We won't hit this block with the preallocated memory. Initially `inMemSorter.hasSpaceForAnotherRecord()` will be true, which can only become false after records have been inserted, at which point `inMemSorter.numRecords() <= 0` won't be true anymore.
   
   We could just check whether `inMemSorter` has memory allocated, but I tried to somewhat abstract the internals of `inMemSorter`. Not sure if that was the right decision though, given how tightly coupled `UnsafeExternalSorter` and `UnsafeInMemorySorter` currently are.




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

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