Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/10170#discussion_r47028774
--- 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 --
(I should add that I think the existing code is correct, but rewriting it
would make the semantics clearer and the tests easier to follow)
---
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]