Skip to content
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

Closed
wants to merge 13 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same in ExternalAppendOnlyMap)

throw new Exception("spark.storage.memoryFraction should be between 0 and 1.")
}
(Runtime.getRuntime.maxMemory * memoryFraction).toLong
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ 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) {
throw new Exception("spark.shuffle.memoryFraction should be between 0 and 1.")
}

if (safetyFraction > 1 && safetyFraction <= 0) {
throw new Exception("spark.shuffle.safetyFraction should be between 0 and 1.")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you remove all the blank lines that you added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed and updated


(Runtime.getRuntime.maxMemory * memoryFraction * safetyFraction).toLong
}

Expand Down