Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/11874#discussion_r57253712
--- Diff:
core/src/main/scala/org/apache/spark/memory/StorageMemoryPool.scala ---
@@ -56,12 +58,30 @@ private[memory] class StorageMemoryPool(lock: Object)
extends MemoryPool(lock) w
/**
* Acquire N bytes of memory to cache the given block, evicting existing
ones if necessary.
- *
+ *
* @return whether all N bytes were successfully granted.
*/
- def acquireMemory(blockId: BlockId, numBytes: Long): Boolean =
lock.synchronized {
- val numBytesToFree = math.max(0, numBytes - memoryFree)
- acquireMemory(blockId, numBytes, numBytesToFree)
+ def acquireMemory(blockId: BlockId, numBytes: Long): Boolean = {
+ // First, attempt to acquire as much memory as we can without
performing any eviction
--- End diff --
I would expand on this: "Otherwise, another thread may jump in and use up
some free memory as soon as we release the lock, in which case we may evict too
few blocks to store this block later."
Right now it's not clear why we need to do this in 2 steps.
---
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]