-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-23516][CORE] It is unnecessary to transfer unroll memory to storage memory #20676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,18 +246,18 @@ private[spark] class MemoryStore( | |
| val amountToRequest = size - unrollMemoryUsedByThisBlock | ||
| keepUnrolling = reserveUnrollMemoryForThisTask(blockId, amountToRequest, memoryMode) | ||
| if (keepUnrolling) { | ||
| unrollMemoryUsedByThisBlock += amountToRequest | ||
| unrollMemoryUsedByThisBlock = size | ||
| } | ||
| } else if (size < unrollMemoryUsedByThisBlock) { | ||
| releaseUnrollMemoryForThisTask(memoryMode, unrollMemoryUsedByThisBlock - size) | ||
| unrollMemoryUsedByThisBlock = size | ||
| } | ||
|
|
||
| if (keepUnrolling) { | ||
| val entry = entryBuilder.build() | ||
| // Synchronize so that transfer is atomic | ||
| memoryManager.synchronized { | ||
| releaseUnrollMemoryForThisTask(memoryMode, unrollMemoryUsedByThisBlock) | ||
| val success = memoryManager.acquireStorageMemory(blockId, entry.size, memoryMode) | ||
| assert(success, "transferring unroll memory to storage memory failed") | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a concept difference between unroll memory and storage memory. And it seems reasonable to transfer unroll memory to storage memory from the view of their concept, though, it makes no big difference underlying storage memory. I'm not sure will this change cause some side effect, if none, I'll approve of it. |
||
| // In fact, unroll memory is also storage memory, it is unnecessary to | ||
| // release unroll memory really | ||
| releaseUnrollMemoryForThisTask(memoryMode, unrollMemoryUsedByThisBlock, false) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you check other calls on this function? Are you sure all other calls' third param default to be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am sure all other calls' third param default to be true
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| entries.synchronized { | ||
| entries.put(blockId, entry) | ||
|
|
@@ -565,7 +565,8 @@ private[spark] class MemoryStore( | |
| * Release memory used by this task for unrolling blocks. | ||
| * If the amount is not specified, remove the current task's allocation altogether. | ||
| */ | ||
| def releaseUnrollMemoryForThisTask(memoryMode: MemoryMode, memory: Long = Long.MaxValue): Unit = { | ||
| def releaseUnrollMemoryForThisTask(memoryMode: MemoryMode, memory: Long = Long.MaxValue, | ||
| releaseMemoryReally: Boolean = true): Unit = { | ||
| val taskAttemptId = currentTaskAttemptId() | ||
| memoryManager.synchronized { | ||
| val unrollMemoryMap = memoryMode match { | ||
|
|
@@ -576,7 +577,9 @@ private[spark] class MemoryStore( | |
| val memoryToRelease = math.min(memory, unrollMemoryMap(taskAttemptId)) | ||
| if (memoryToRelease > 0) { | ||
| unrollMemoryMap(taskAttemptId) -= memoryToRelease | ||
| memoryManager.releaseUnrollMemory(memoryToRelease, memoryMode) | ||
| if (releaseMemoryReally) { | ||
| memoryManager.releaseUnrollMemory(memoryToRelease, memoryMode) | ||
| } | ||
| } | ||
| if (unrollMemoryMap(taskAttemptId) == 0) { | ||
| unrollMemoryMap.remove(taskAttemptId) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#19285 miss this check before? Oops! This could waste storage memory. Thanks for adding this.
Also, cc @cloud-fan @ConeyLiu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #19285, we first release
unrollMemoryUsedByThisBlockunroll memory, and then we requestentry.sizestorage memory. So, there is no waste of resources here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no problem before,because it releases all unroll memory in 257 line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, glad to hear that.