Github user sameeragarwal commented on a diff in the pull request:
https://github.com/apache/spark/pull/11874#discussion_r57225044
--- Diff:
core/src/main/scala/org/apache/spark/memory/StorageMemoryPool.scala ---
@@ -75,21 +95,31 @@ private[memory] class StorageMemoryPool(lock: Object)
extends MemoryPool(lock) w
def acquireMemory(
blockId: BlockId,
numBytesToAcquire: Long,
- numBytesToFree: Long): Boolean = lock.synchronized {
+ numBytesToFree: Long): Boolean = {
assert(numBytesToAcquire >= 0)
assert(numBytesToFree >= 0)
- assert(memoryUsed <= poolSize)
- if (numBytesToFree > 0) {
+ assert(lock.synchronized(memoryUsed <= poolSize))
+ val memoryFreedByEviction = if (numBytesToFree > 0) {
memoryStore.evictBlocksToFreeSpace(Some(blockId), numBytesToFree)
+ } else {
+ 0
}
- // NOTE: If the memory store evicts blocks, then those evictions will
synchronously call
- // back into this StorageMemoryPool in order to free memory.
Therefore, these variables
- // should have been updated.
- val enoughMemory = numBytesToAcquire <= memoryFree
- if (enoughMemory) {
- _memoryUsed += numBytesToAcquire
+ if (memoryFreedByEviction > numBytesToAcquire) {
+ releaseMemory(memoryFreedByEviction - numBytesToAcquire)
+ }
--- End diff --
maybe put the remaining code below in an `else` block?
---
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]