File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
core/src/main/scala/org/apache/spark/memory Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -105,14 +105,18 @@ class StorageMemoryPool extends MemoryPool with Logging {
105105 }
106106
107107 // TODO(josh): comment
108- def shrinkPoolByEvictingBlocks (spaceToEnsure : Long ): Long = synchronized {
108+ def shrinkPoolToFreeSpace (spaceToEnsure : Long ): Long = synchronized {
109109 val spaceFreedByReleasingUnusedMemory = Math .min(spaceToEnsure, memoryFree)
110110 decrementPoolSize(spaceFreedByReleasingUnusedMemory)
111- val evictedBlocks = new ArrayBuffer [(BlockId , BlockStatus )]
112- memoryStore.ensureFreeSpace(spaceToEnsure - spaceFreedByReleasingUnusedMemory, evictedBlocks)
113- val spaceFreedByEviction = evictedBlocks.map(_._2.memSize).sum
114- _memoryUsed -= spaceFreedByEviction
115- decrementPoolSize(spaceFreedByEviction)
116- spaceFreedByReleasingUnusedMemory + spaceFreedByEviction
111+ if (spaceFreedByReleasingUnusedMemory == spaceToEnsure) {
112+ spaceFreedByReleasingUnusedMemory
113+ } else {
114+ val evictedBlocks = new ArrayBuffer [(BlockId , BlockStatus )]
115+ memoryStore.ensureFreeSpace(spaceToEnsure - spaceFreedByReleasingUnusedMemory, evictedBlocks)
116+ val spaceFreedByEviction = evictedBlocks.map(_._2.memSize).sum
117+ _memoryUsed -= spaceFreedByEviction
118+ decrementPoolSize(spaceFreedByEviction)
119+ spaceFreedByReleasingUnusedMemory + spaceFreedByEviction
120+ }
117121 }
118122}
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ private[spark] class UnifiedMemoryManager private[memory] (
8989 // If there is not enough free memory AND storage has borrowed some execution memory,
9090 // then evict as much memory borrowed by storage as needed to grant this request
9191 if (numBytes > onHeapExecutionMemoryPool.memoryFree && memoryBorrowedByStorage > 0 ) {
92- val spaceReclaimed = storageMemoryPool.shrinkPoolByEvictingBlocks (
92+ val spaceReclaimed = storageMemoryPool.shrinkPoolToFreeSpace (
9393 math.min(numBytes, memoryBorrowedByStorage))
9494 onHeapExecutionMemoryPool.incrementPoolSize(spaceReclaimed)
9595 }
You can’t perform that action at this time.
0 commit comments