Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2416#discussion_r17923603
  
    --- Diff: 
core/src/main/scala/org/apache/spark/util/collection/ExternalSorter.scala ---
    @@ -232,35 +224,18 @@ private[spark] class ExternalSorter[K, V, C](
           return
         }
     
    -    val collection: SizeTrackingPairCollection[(Int, K), C] = if 
(usingMap) map else buffer
    -
    -    // TODO: factor this out of both here and ExternalAppendOnlyMap
    -    if (elementsRead > trackMemoryThreshold && elementsRead % 32 == 0 &&
    -        collection.estimateSize() >= myMemoryThreshold)
    -    {
    -      // Claim up to double our current memory from the shuffle memory pool
    -      val currentMemory = collection.estimateSize()
    -      val amountToRequest = 2 * currentMemory - myMemoryThreshold
    -      val granted = shuffleMemoryManager.tryToAcquire(amountToRequest)
    -      myMemoryThreshold += granted
    -      if (myMemoryThreshold <= currentMemory) {
    -        // We were granted too little memory to grow further (either 
tryToAcquire returned 0,
    -        // or we already had more memory than myMemoryThreshold); spill 
the current collection
    -        spill(currentMemory, usingMap)  // Will also release memory back 
to ShuffleMemoryManager
    -      }
    +    if (usingMap) {
    +      map = maybeSpill(map)
    --- End diff --
    
    It's a little confusing for a `maybeSpill` to call a different 
`maybeSpill`, from the base class to the parent class. We should rename one of 
them (not too sure which one) to `maybeSpillCollection` or something.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to