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

    https://github.com/apache/spark/pull/18296#discussion_r122344684
  
    --- Diff: 
core/src/main/scala/org/apache/spark/memory/UnifiedMemoryManager.scala ---
    @@ -171,7 +171,8 @@ private[spark] class UnifiedMemoryManager 
private[memory] (
         if (numBytes > storagePool.memoryFree) {
           // There is not enough free memory in the storage pool, so try to 
borrow free memory from
           // the execution pool.
    -      val memoryBorrowedFromExecution = Math.min(executionPool.memoryFree, 
numBytes)
    +      val memoryBorrowedFromExecution = Math.min(executionPool.memoryFree,
    +        numBytes - storagePool.memoryFree)
    --- End diff --
    
    This change makes sense: if we hit this branch then we've failed to acquire 
enough memory to store a block. In particular, we might need `M` bytes of 
memory but only `A` are available in storage. In this case, we should only 
request the `(M - A)` bytes of extra memory that we need, but the old code was 
incorrectly requesting all `M` which would cause us to over-evict. Therefore, I 
think this change is correct.


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