Skip to content
Snippets Groups Projects
Commit a8725bf8 authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Don't allocate Kryo buffers unless needed

parent 4a25b116
No related branches found
No related tags found
No related merge requests found
...@@ -38,8 +38,6 @@ class KryoSerializer extends org.apache.spark.serializer.Serializer with Logging ...@@ -38,8 +38,6 @@ class KryoSerializer extends org.apache.spark.serializer.Serializer with Logging
def newKryoOutput() = new KryoOutput(bufferSize) def newKryoOutput() = new KryoOutput(bufferSize)
def newKryoInput() = new KryoInput(bufferSize)
def newKryo(): Kryo = { def newKryo(): Kryo = {
val instantiator = new ScalaKryoInstantiator val instantiator = new ScalaKryoInstantiator
val kryo = instantiator.newKryo() val kryo = instantiator.newKryo()
...@@ -118,8 +116,10 @@ class KryoDeserializationStream(kryo: Kryo, inStream: InputStream) extends Deser ...@@ -118,8 +116,10 @@ class KryoDeserializationStream(kryo: Kryo, inStream: InputStream) extends Deser
private[spark] class KryoSerializerInstance(ks: KryoSerializer) extends SerializerInstance { private[spark] class KryoSerializerInstance(ks: KryoSerializer) extends SerializerInstance {
val kryo = ks.newKryo() val kryo = ks.newKryo()
val output = ks.newKryoOutput()
val input = ks.newKryoInput() // Make these lazy vals to avoid creating a buffer unless we use them
lazy val output = ks.newKryoOutput()
lazy val input = new KryoInput()
def serialize[T](t: T): ByteBuffer = { def serialize[T](t: T): ByteBuffer = {
output.clear() output.clear()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment