-
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-1779] Throw an exception if memory fractions are not between 0 and 1 #714
Conversation
add a warning when memoryFraction is not between 0 and 1
Can one of the admins verify this patch? |
We should probably throw an exception, actually. It's a pathological state if the max memory is negative, or greater than what the JVM offers. |
Could you also do that in |
ok, updated. |
@@ -1045,6 +1045,9 @@ private[spark] object BlockManager extends Logging { | |||
|
|||
def getMaxMemory(conf: SparkConf): Long = { | |||
val memoryFraction = conf.getDouble("spark.storage.memoryFraction", 0.6) | |||
if (memoryFraction > 1 && memoryFraction <= 0) { |
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: the value of 0 is technically "between 0 and 1." This should be memoryFraction < 0
. Someone might want to not use the RDD cache at all and use all memory for spilling, for instance. (though I don't think this is common)
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.
(Same in ExternalAppendOnlyMap
)
Thanks, this looks good. (now we just need to test it) |
@@ -1045,6 +1045,9 @@ private[spark] object BlockManager extends Logging { | |||
|
|||
def getMaxMemory(conf: SparkConf): Long = { | |||
val memoryFraction = conf.getDouble("spark.storage.memoryFraction", 0.6) | |||
if (memoryFraction > 1 && memoryFraction < 0) { |
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.
Should throw an IllegalArgumentException.
Preconditions.checkArgument(0 < memoryFraction && 1 > memoryFraction,
"spark.storage.memoryFraction should be between 0 and 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.
thanks for that
【SPARK-1779】 => [SPARK-1779] |
@@ -76,6 +76,12 @@ class ExternalAppendOnlyMap[K, V, C]( | |||
private val maxMemoryThreshold = { | |||
val memoryFraction = sparkConf.getDouble("spark.shuffle.memoryFraction", 0.3) | |||
val safetyFraction = sparkConf.getDouble("spark.shuffle.safetyFraction", 0.8) | |||
if (memoryFraction > 1 && memoryFraction < 0) { |
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.
Should or(||) instead of and(&&).
[memoryFraction > 1 && memoryFraction < 0] => [memoryFraction > 1 || memoryFraction < 0]
The same to safetyFraction.
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.
yeah, i made a mistake
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, good call
Hey @witgo @andrewor14. I thought I commented earlier but it appears the comment didn't get posted. I think it would be a good idea to validate this at the time of Also - it would be good to echo back the value that was set to the user. Sometimes users don't know where a configuration option is coming from:
|
Hi @pwendell, thanks. I didn't notice validateSettings in SparkConf and it's good to validate this in it. |
I coded up a proposal where SparkConf owns the checking inside of getInt(), getDouble() and friends, described here: |
@@ -236,6 +236,27 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging { | |||
} | |||
} | |||
|
|||
// Validate memoryFraction | |||
val storageMemFraction = getDouble("spark.storage.memoryFraction", 0.6) |
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 could be written a bit more concisely like:
val memoryKeys = Seq(
"spark.storage.memoryFraction",
"spark.shuffle.memoryFraction",
"spark.shuffle.safetyFraction")
for (key -> memoryKeys) {
val value = getDouble(key, 0.5)
if (value > 1 || value < 0) {
throw new IllegalArgumentException("$key should be between 0 and (was '$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.
ok, updated!
Suggested a way to make this more concise, but looks good overall. |
for (key -> memoryKeys) { | ||
val value = getDouble(key, 0.5) | ||
if (value > 1 || value < 0) { | ||
throw new IllegalArgumentException("$key should be between 0 and (was '$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.
missing indent
Ah yes, this is much better. There is a missing indent, however. After you fix that I think this is good to go. |
Jenkins, test this please. |
hey @andrewor14 , i can not see FAILED unit tests info, so i do not know how to resolve it. can you help me |
test this please |
Pending tests this LGTM |
QA tests have started for PR 714. This patch merges cleanly. |
QA results for PR 714: |
@@ -236,6 +236,20 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging { | |||
} | |||
} | |||
|
|||
// Validate memoryFraction |
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: this is no longer only memoryFraction
. Maybe use "Validate memory fractions" instead
Also, could you update the description to "Throw an exception if memory fractions are not between 0 and 1" |
@andrewor14 if so, we do not know which one is outside (0,1) |
What do you mean? I was referring to the title of the PR, because it's now out of date based on your recent changes. |
test this please |
QA tests have started for PR 714. This patch merges cleanly. |
LGTM pending tests. |
QA results for PR 714: |
hi @andrewor14,unit tests error in sparkstreaming,we may retest this [info] - flume polling test multiple hosts *** FAILED *** |
test this please |
Jenkins, test this please. |
QA tests have started for PR 714. This patch merges cleanly. |
QA results for PR 714: |
Thanks - I'm going to merge this. |
… and 1 Author: wangfei <[email protected]> Author: wangfei <[email protected]> Closes #714 from scwf/memoryFraction and squashes the following commits: 6e385b9 [wangfei] Update SparkConf.scala da6ee59 [wangfei] add configs 829a195 [wangfei] add indent 717c0ca [wangfei] updated to make more concise fc45476 [wangfei] validate memoryfraction in sparkconf 2e79b3d [wangfei] && => || 43621bd [wangfei] && => || cf38bcf [wangfei] throw IllegalArgumentException 14d18ac [wangfei] throw IllegalArgumentException dff1f0f [wangfei] Update BlockManager.scala 764965f [wangfei] Update ExternalAppendOnlyMap.scala a59d76b [wangfei] Throw exception when memoryFracton is out of range 7b899c2 [wangfei] 【SPARK-1779】
… and 1 Author: wangfei <[email protected]> Author: wangfei <[email protected]> Closes apache#714 from scwf/memoryFraction and squashes the following commits: 6e385b9 [wangfei] Update SparkConf.scala da6ee59 [wangfei] add configs 829a195 [wangfei] add indent 717c0ca [wangfei] updated to make more concise fc45476 [wangfei] validate memoryfraction in sparkconf 2e79b3d [wangfei] && => || 43621bd [wangfei] && => || cf38bcf [wangfei] throw IllegalArgumentException 14d18ac [wangfei] throw IllegalArgumentException dff1f0f [wangfei] Update BlockManager.scala 764965f [wangfei] Update ExternalAppendOnlyMap.scala a59d76b [wangfei] Throw exception when memoryFracton is out of range 7b899c2 [wangfei] 【SPARK-1779】
* drop user info when ingesting conda list explicit uris * add test * special taste of scala * more test * fix test * more docs * 1 more docs
No description provided.