Github user aarondav commented on the pull request:

    https://github.com/apache/spark/pull/397#issuecomment-40320307
  
    Apparently the JVM implements "biased locking" 
(http://www.oracle.com/technetwork/java/6-performance-137236.html#2.1.1) when 
an object's monitor is uncontended, which eliminates all synchronization 
overhead (at the cost of an extremely expensive "bias revocation" operation if 
any contention appears). So we would expect there to be no relevant performance 
loss of this synchronization in this case, except perhaps for very small 
streams which are completed before being biased.
    
    However, the API of `def toByteArray: Array[Byte]` and `def toArray: 
(Array[Byte], Int)` with different performance characteristics is pretty 
strange. I think the current solution is probably fine, as the implementation 
is pretty straightforward. I'll eat those words when the first JIRA comes back 
with a bug introduced from this patch, though.


---
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.
---

Reply via email to