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

    https://github.com/apache/spark/pull/10170#discussion_r47038892
  
    --- Diff: 
core/src/main/scala/org/apache/spark/memory/StorageMemoryPool.scala ---
    @@ -73,27 +73,31 @@ class StorageMemoryPool(lock: Object) extends 
MemoryPool(lock) with Logging {
        *
        * @param blockId the ID of the block we are acquiring storage memory for
        * @param numBytesToAcquire the size of this block
    -   * @param numBytesToFree the size of space to be freed through evicting 
blocks
    +   * @param maxNumBytesToFree the maximum amount of space to be freed 
through evicting blocks
        * @return whether all N bytes were successfully granted.
        */
       def acquireMemory(
           blockId: BlockId,
           numBytesToAcquire: Long,
    -      numBytesToFree: Long,
    +      maxNumBytesToFree: Long,
           evictedBlocks: mutable.Buffer[(BlockId, BlockStatus)]): Boolean = 
lock.synchronized {
         assert(numBytesToAcquire >= 0)
    -    assert(numBytesToFree >= 0)
    +    assert(maxNumBytesToFree >= 0)
         assert(memoryUsed <= poolSize)
    -    memoryStore.ensureFreeSpace(blockId, numBytesToFree, evictedBlocks)
    -    // Register evicted blocks, if any, with the active task metrics
    -    Option(TaskContext.get()).foreach { tc =>
    -      val metrics = tc.taskMetrics()
    -      val lastUpdatedBlocks = 
metrics.updatedBlocks.getOrElse(Seq[(BlockId, BlockStatus)]())
    -      metrics.updatedBlocks = Some(lastUpdatedBlocks ++ 
evictedBlocks.toSeq)
    +    if (numBytesToAcquire > memoryFree && maxNumBytesToFree > 0) {
    +      val additionalMemoryRequired = numBytesToAcquire - memoryFree
    +      memoryStore.evictBlocksToFreeSpace(
    --- End diff --
    
    `evictBlocksToFreeSpace` already has a form of this check internally. Even 
if we add the logic here, we can't drop the checks inside of 
`evictBlocksToFreeSpace` because when storage is evicting storage we need to 
handle the fact that an RDD cannot evict blocks belonging to the same RDD.
    
    It wouldn't hurt to add the check here, I suppose, since it would save us 
the hassle of having to iterate over all of the blocks in the memory store.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to