-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-21090][core]Optimize the unified memory manager code #18296
Conversation
Test build #78030 has finished for PR 18296 at commit
|
Test build #78032 has started for PR 18296 at commit |
retest this please |
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.
You generally haven't exchanged why you think this change is necessary. Explaining what it is doesn't do that.
@srowen I have updated the description of this PR,thanks |
I don't quite understand how that addresses the question, but I don't know this code. @JoshRosen is the most likely reviewer, but maybe you can elaborate the example more. |
Test build #78037 has finished for PR 18296 at commit
|
@JoshRosen Could you help to review it, thanks |
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.
LGTM. I commented inline on why I think this is a good and correct change.
@@ -160,7 +160,7 @@ private[spark] class UnifiedMemoryManager private[memory] ( | |||
case MemoryMode.OFF_HEAP => ( | |||
offHeapExecutionMemoryPool, | |||
offHeapStorageMemoryPool, | |||
maxOffHeapMemory) | |||
maxOffHeapStorageMemory) |
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.
This looks like a bug in the old code. Good catch.
@@ -171,7 +171,8 @@ private[spark] class UnifiedMemoryManager private[memory] ( | |||
if (numBytes > storagePool.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(executionPool.memoryFree, numBytes) | |||
val memoryBorrowedFromExecution = Math.min(executionPool.memoryFree, | |||
numBytes - storagePool.memoryFree) |
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.
This change makes sense: if we hit this branch then we've failed to acquire enough memory to store a block. In particular, we might need M
bytes of memory but only A
are available in storage. In this case, we should only request the (M - A)
bytes of extra memory that we need, but the old code was incorrectly requesting all M
which would cause us to over-evict. Therefore, I think this change is correct.
Also cc @cloud-fan @jiangxb1987 |
LGTM, merging to master! |
## What changes were proposed in this pull request? 1.In `acquireStorageMemory`, when the Memory Mode is OFF_HEAP ,the `maxOffHeapMemory` should be modified to `maxOffHeapStorageMemory`. after this PR,it will same as ON_HEAP Memory Mode. Because when acquire memory is between `maxOffHeapStorageMemory` and `maxOffHeapMemory`,it will fail surely, so if acquire memory is greater than `maxOffHeapStorageMemory`(not greater than `maxOffHeapMemory`),we should fail fast. 2. Borrow memory from execution, `numBytes` modified to `numBytes - storagePool.memoryFree` will be more reasonable. Because we just acquire `(numBytes - storagePool.memoryFree)`, unnecessary borrowed `numBytes` from execution ## How was this patch tested? added unit test case Author: liuxian <[email protected]> Closes #18296 from 10110346/wip-lx-0614. (cherry picked from commit 112bd9b) Signed-off-by: Wenchen Fan <[email protected]>
Actually this is a bug fix, and it's a small fix(without tests, only 3 lines), so backporting in to 2.2 |
What changes were proposed in this pull request?
1.In
acquireStorageMemory
, when the Memory Mode is OFF_HEAP ,themaxOffHeapMemory
should be modified tomaxOffHeapStorageMemory
. after this PR,it will same as ON_HEAP Memory Mode.Because when acquire memory is between
maxOffHeapStorageMemory
andmaxOffHeapMemory
,it will fail surely, so if acquire memory is greater thanmaxOffHeapStorageMemory
(not greater thanmaxOffHeapMemory
),we should fail fast.2. Borrow memory from execution,
numBytes
modified tonumBytes - storagePool.memoryFree
will be more reasonable.Because we just acquire
(numBytes - storagePool.memoryFree)
, unnecessary borrowednumBytes
from executionHow was this patch tested?
added unit test case