Skip to content

Commit

Permalink
[SPARK-6405] Limiting the maximum Kryo buffer size to be 2GB.
Browse files Browse the repository at this point in the history
Kryo buffers are backed by byte arrays, but primitive arrays can only be
up to 2GB in size. It is misleading to allow users to set buffers past
this size.
  • Loading branch information
mccheah committed Mar 26, 2015
1 parent 784fcd5 commit 60634f9
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,20 @@ class KryoSerializer(conf: SparkConf)
with Logging
with Serializable {

private val bufferSize =
(conf.getDouble("spark.kryoserializer.buffer.mb", 0.064) * 1024 * 1024).toInt
private val bufferSizeMb: Double = conf.getDouble("spark.kryoserializer.buffer.mb", 0.064)
if (bufferSizeMb > 2048) {
throw new IllegalArgumentException("spark.kryoserializer.buffer.mb must be less than " +
s"2048 megabytes, got: + $bufferSizeMb mb.")
}
private val bufferSize = (bufferSizeMb * 1024 * 1024).toInt

val maxBufferSizeMb: Int = conf.getInt("spark.kryoserializer.buffer.max.mb", 64)
if (maxBufferSizeMb > 2048) {
throw new IllegalArgumentException("spark.kryoserializer.buffer.max.mb must be less than " +
s"2048 megabytes, got: + $maxBufferSizeMb mb.")
}
private val maxBufferSize = maxBufferSizeMb * 1024 * 1024

private val maxBufferSize = conf.getInt("spark.kryoserializer.buffer.max.mb", 64) * 1024 * 1024
private val referenceTracking = conf.getBoolean("spark.kryo.referenceTracking", true)
private val registrationRequired = conf.getBoolean("spark.kryo.registrationRequired", false)
private val userRegistrator = conf.getOption("spark.kryo.registrator")
Expand Down

0 comments on commit 60634f9

Please sign in to comment.