Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/11874#discussion_r57258931
--- Diff:
core/src/main/scala/org/apache/spark/memory/UnifiedMemoryManager.scala ---
@@ -131,26 +131,28 @@ private[spark] class UnifiedMemoryManager
private[memory] (
}
}
- override def acquireStorageMemory(blockId: BlockId, numBytes: Long):
Boolean = synchronized {
- assert(onHeapExecutionMemoryPool.poolSize + storageMemoryPool.poolSize
== maxMemory)
- assert(numBytes >= 0)
- if (numBytes > maxStorageMemory) {
- // Fail fast if the block simply won't fit
- logInfo(s"Will not store $blockId as the required space ($numBytes
bytes) exceeds our " +
- s"memory limit ($maxStorageMemory bytes)")
- return false
- }
- if (numBytes > storageMemoryPool.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(onHeapExecutionMemoryPool.memoryFree, numBytes)
-
onHeapExecutionMemoryPool.decrementPoolSize(memoryBorrowedFromExecution)
- storageMemoryPool.incrementPoolSize(memoryBorrowedFromExecution)
+ override def acquireStorageMemory(blockId: BlockId, numBytes: Long):
Boolean = {
+ synchronized {
+ assert(onHeapExecutionMemoryPool.poolSize +
storageMemoryPool.poolSize == maxMemory)
+ assert(numBytes >= 0)
+ if (numBytes > maxStorageMemory) {
+ // Fail fast if the block simply won't fit
+ logInfo(s"Will not store $blockId as the required space ($numBytes
bytes) exceeds our " +
+ s"memory limit ($maxStorageMemory bytes)")
+ return false
+ }
+ if (numBytes > storageMemoryPool.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(onHeapExecutionMemoryPool.memoryFree, numBytes)
+
onHeapExecutionMemoryPool.decrementPoolSize(memoryBorrowedFromExecution)
+ storageMemoryPool.incrementPoolSize(memoryBorrowedFromExecution)
--- End diff --
everything in this block is cheap anyway. The only expensive thing we want
to keep out of the synchronized block here is evicting blocks from memory
store, which is what `storageMemoryPool.acquireMemory` does.
---
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]