Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5924#discussion_r29718641
  
    --- Diff: 
core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala ---
    @@ -125,6 +125,13 @@ class KryoSerializer(conf: SparkConf)
       override def newInstance(): SerializerInstance = {
         new KryoSerializerInstance(this)
       }
    +
    +  private[spark] override lazy val supportsRelocationOfSerializedObjects: 
Boolean = {
    +    // If auto-flush is disabled, then Kryo may store references to 
duplicate occurrences of objects
    +    // in the stream rather than writing those objects' serialized bytes, 
breaking relocation. See
    +    // https://groups.google.com/d/msg/kryo-users/6ZUSyfjjtdo/FhGG1KHDXPgJ 
for more details.
    +    newInstance().asInstanceOf[KryoSerializerInstance].getAutoReset()
    --- End diff --
    
    I couldn't seem to find a good way to determine whether auto-reset was 
enabled short of actually creating a serializer instance.  Fortunately, it's 
fairly cheap to create a KryoSerializerInstance that you don't write to because 
its buffers are allocated lazily. Combined with #5606, which enables serializer 
re-use in many circumstances, I don't think that this will carry a huge 
performance penalty (especially since this is a `lazy val`).
    
    I suppose that one alternative would be to move this method from 
`Serializer` to `SerializerInstance`. I chose not to take that approach because 
my other patch, #5868, checks serializer properties inside of 
`ShuffleManager.getWriter` in order to choose which writer implementation to 
use; at that call site, we don't have a SerializerInstance, so I'd still have 
to create an unnecessary serializer instance there.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to