-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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-26539][CORE] Remove spark.memory.useLegacyMode and StaticMemoryManager #23457
Conversation
@@ -45,7 +45,7 @@ import org.apache.spark.storage.BlockId | |||
* it if necessary. Cached blocks can be evicted only if actual | |||
* storage memory usage exceeds this region. | |||
*/ | |||
private[spark] class UnifiedMemoryManager private[memory] ( | |||
private[spark] class UnifiedMemoryManager( |
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.
Tests and other internals now need to use this constructor directly
@@ -61,7 +60,7 @@ class MemoryStoreSuite | |||
} | |||
|
|||
def makeMemoryStore(maxMem: Long): (MemoryStore, BlockInfoManager) = { | |||
val memManager = new StaticMemoryManager(conf, Long.MaxValue, maxMem, numCores = 1) | |||
val memManager = new UnifiedMemoryManager(conf, maxMem, (0.4 * maxMem).toInt, 1) |
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 mimics the behavior of the old memory manager with spark.storage.unrollFraction=0.4
val result4 = putIteratorAsBytes("b4", bigIterator, ClassTag.Any) | ||
assert(result4.isLeft) // unroll was unsuccessful | ||
assert(!memoryStore.contains("b1")) | ||
assert(!memoryStore.contains("b2")) | ||
assert(memoryStore.contains("b2")) // not necessarily evicted |
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 behavior changed after the change above. However, I am not sure this assertion is correct? there are 4800 bytes available. b2 takes 400. An attempt to put 4000 may fail (? well that was the previous and current behavior, anyway), but I don't see that it necessarily requires evicting b2; the allocation failed. We've recently had a very similar discussion about a different change that also uncovered this assertion as an issue.
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.
isn't b2 takes 4000 and b4 takes 40000 ?
I verified the test and I think the assertion is correct.
Actually, for current behaviour with UnifiedMemoryManager
, there may be 12000 bytes available. When we try to put b4 into memory, it will require 24064 memory once it unrolled 16 elements (which hit the memoryCheckPeriod
for first time). And 24064 bytes exceed the maxMemory of 12000, so, it would just return instread of evicting any blocks.
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.
Oops yes b2 takes 4000 and b4 40000. OK, certainly b4 can't fit. Yes on thinking this through a second time, this isn't quite the right change. The difference between total and storage memory in the unified memory manager is irrelevant here. It's just that this test needs less total memory available -- a little more than 8000 bytes, not 12000. Let me push a fix.
.set("spark.memory.useLegacyMode", "true") | ||
.set("spark.testing.memory", "100000000") | ||
.set("spark.memory.storageFraction", "0.999") | ||
.set("spark.testing.memory", "471859200") |
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 is the minimum allowed value. The new setting 0.999 mimics having almost no shuffle memory
Test build #100757 has finished for PR 23457 at commit
|
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.
Pretty Cool!
@@ -61,15 +61,10 @@ package org.apache.spark | |||
* }}} | |||
* | |||
* | |||
* There are two implementations of [[org.apache.spark.memory.MemoryManager]] which vary in how | |||
* they handle the sizing of their memory pools: | |||
* There is one implementations of [[org.apache.spark.memory.MemoryManager]]: |
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.
nit: implementations
-> implementation
val result4 = putIteratorAsBytes("b4", bigIterator, ClassTag.Any) | ||
assert(result4.isLeft) // unroll was unsuccessful | ||
assert(!memoryStore.contains("b1")) | ||
assert(!memoryStore.contains("b2")) | ||
assert(memoryStore.contains("b2")) // not necessarily evicted |
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.
isn't b2 takes 4000 and b4 takes 40000 ?
I verified the test and I think the assertion is correct.
Actually, for current behaviour with UnifiedMemoryManager
, there may be 12000 bytes available. When we try to put b4 into memory, it will require 24064 memory once it unrolled 16 elements (which hit the memoryCheckPeriod
for first time). And 24064 bytes exceed the maxMemory of 12000, so, it would just return instread of evicting any blocks.
Test build #100789 has finished for PR 23457 at commit
|
cc @jiangxb1987 |
Test build #100940 has finished for PR 23457 at commit
|
Test build #4500 has finished for PR 23457 at commit
|
@@ -61,15 +61,10 @@ package org.apache.spark | |||
* }}} | |||
* | |||
* | |||
* There are two implementations of [[org.apache.spark.memory.MemoryManager]] which vary in how | |||
* they handle the sizing of their memory pools: | |||
* There is one implementation of [[org.apache.spark.memory.MemoryManager]]: | |||
* | |||
* - [[org.apache.spark.memory.UnifiedMemoryManager]], the default in Spark 1.6+, enforces soft |
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.
nit: since just one implementation now, still need to mention this is default?
Test build #100973 has finished for PR 23457 at commit
|
Merged to master |
@@ -29,7 +29,7 @@ | |||
@Test | |||
public void leakedPageMemoryIsDetected() { | |||
final TaskMemoryManager manager = new TaskMemoryManager( | |||
new StaticMemoryManager( | |||
new UnifiedMemoryManager( | |||
new SparkConf().set("spark.memory.offHeap.enabled", "false"), | |||
Long.MAX_VALUE, | |||
Long.MAX_VALUE, |
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.
What does these mean after the change?
maxHeapMemory = Long.MAX_VALUE and onHeapStorageRegionSize = Long.MAX_VALUE?
@@ -60,7 +59,7 @@ class MemoryStoreSuite | |||
} | |||
|
|||
def makeMemoryStore(maxMem: Long): (MemoryStore, BlockInfoManager) = { | |||
val memManager = new StaticMemoryManager(conf, Long.MaxValue, maxMem, numCores = 1) | |||
val memManager = new UnifiedMemoryManager(conf, maxMem, maxMem, 1) |
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.
The same question here
Is it fine to simply replace it? Basically, the cases I pointed out above change the semantics. That means, onHeapExecutionMemory will be zero, if maxHeapMemory and onHeapStorageRegionSize are the same. |
You're right, the semantics are different, but I don't think they matter in the test context here. It is probably more accurate to pass something like (maxHeapMemory, maxHeapMemory / 2). The tests pass, at least, because I believe they don't care about execution memory, which is 0. |
Opened a ticket https://issues.apache.org/jira/browse/SPARK-26725 I think we should not write an invalid inputs in the test cases. |
@@ -94,7 +94,7 @@ private[execution] object HashedRelation { | |||
taskMemoryManager: TaskMemoryManager = null): HashedRelation = { | |||
val mm = Option(taskMemoryManager).getOrElse { | |||
new TaskMemoryManager( | |||
new StaticMemoryManager( | |||
new UnifiedMemoryManager( | |||
new SparkConf().set(MEMORY_OFFHEAP_ENABLED.key, "false"), | |||
Long.MaxValue, | |||
Long.MaxValue, |
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.
How about these?
…tructor in test suites ## What changes were proposed in this pull request? Adjust mem settings in UnifiedMemoryManager used in test suites to ha…ve execution memory > 0 Ref: #23457 (comment) ## How was this patch tested? Existing tests Closes #23645 from srowen/SPARK-26725. Authored-by: Sean Owen <sean.owen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…yManager ## What changes were proposed in this pull request? Remove spark.memory.useLegacyMode and StaticMemoryManager. Update tests that used the StaticMemoryManager to equivalent use of UnifiedMemoryManager. ## How was this patch tested? Existing tests, with modifications to make them work with a different mem manager. Closes apache#23457 from srowen/SPARK-26539. Authored-by: Sean Owen <sean.owen@databricks.com> Signed-off-by: Sean Owen <sean.owen@databricks.com>
…tructor in test suites ## What changes were proposed in this pull request? Adjust mem settings in UnifiedMemoryManager used in test suites to ha…ve execution memory > 0 Ref: apache#23457 (comment) ## How was this patch tested? Existing tests Closes apache#23645 from srowen/SPARK-26725. Authored-by: Sean Owen <sean.owen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
Remove spark.memory.useLegacyMode and StaticMemoryManager. Update tests that used the StaticMemoryManager to equivalent use of UnifiedMemoryManager.
How was this patch tested?
Existing tests, with modifications to make them work with a different mem manager.