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.

Author: mcheah <[email protected]>

Closes apache#5218 from mccheah/feature/limit-kryo-buffer and squashes the following commits:

1d6d1be [mcheah] Fixing numeric typo
e2e30ce [mcheah] Removing explicit int and double type to match style
09fd80b [mcheah] Should be >= not >. Slightly more consistent error message.
60634f9 [mcheah] [SPARK-6405] Limiting the maximum Kryo buffer size to be 2GB.
  • Loading branch information
mccheah authored and pwendell committed Mar 27, 2015
1 parent 39fb579 commit 49d2ec6
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 = conf.getDouble("spark.kryoserializer.buffer.mb", 0.064)
if (bufferSizeMb >= 2048) {
throw new IllegalArgumentException("spark.kryoserializer.buffer.mb must be less than " +
s"2048 mb, got: + $bufferSizeMb mb.")
}
private val bufferSize = (bufferSizeMb * 1024 * 1024).toInt

val maxBufferSizeMb = 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 mb, 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 49d2ec6

Please sign in to comment.