[ 
https://issues.apache.org/jira/browse/AVRO-1277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13609297#comment-13609297
 ] 

Leo Romanoff commented on AVRO-1277:
------------------------------------

BTW, regarding the use of ThreadLocals:
I think the issue is related to the current design of Avro. 
Serializers/Deserializers are supposed to be thread-safe as far as I 
understand. At the same time, there is no "context" object being passed through 
all the calls when performing serialization and deserialization. Hence you need 
to store the context somewhere, e.g. in the ThreadLocal variables. Is it 
correct understanding?

Some other frameworks, e.g. Kryo, take a different approach: They pass the Kryo 
instance through all the calls (i.e. Kryo is the context object) and they do 
not try to be thread-safe, i.e. you cannot use the same Kryo instance by 
multiple threads simultaneously. As a result, there are no ThreadLocals used by 
Kryo (and therefore no problems related to that) and its performance is 
significantly faster in most cases.
                
> Improve performance of reflection-based serializers
> ---------------------------------------------------
>
>                 Key: AVRO-1277
>                 URL: https://issues.apache.org/jira/browse/AVRO-1277
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.4
>            Reporter: Leo Romanoff
>            Priority: Minor
>         Attachments: AVRO-1277.patch
>
>
> I've played a bit with Avro serialization based on reflection, i.e. with the 
> classes from org.apache.avro.generic package.
> It works fine in this mode, but is rather slow compared to such frameworks 
> like protostuff or kryo.
> Quick look at the source code has shown that a lot of reflection-based 
> operations and class lookups are not cached. And such operations are usually 
> pretty expensive when executed by a JVM. 
> So I changed some of org.apache.avro.generic classes, introduced caching and 
> a few other optimizations. Now it seems to perform much better.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to