avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-2051) Thread contention accessing JsonProperties props
Date Fri, 08 Sep 2017 19:16:00 GMT

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

Daniel Kulp commented on AVRO-2051:
-----------------------------------

Redid the pull request to base off a branch so I can keep my fork more in sync.....

Anyway, I made the hashCode and propsEquals package protected which should keep those from
being exposed.    I needed to add these methods as the subclass (Protocol) needs to know those,
but I wanted to keep the "props" field private to make sure any subclass or other does not
do any direct access to the props field.   This forces subclasses (and others) to use the
addProp method where we can make sure properties don't "change".   (Properties can only be
added, not modified)

I don't think putting the ConcurrentHashMap into utils makes sense.   This is a VERY particular
use case and only certain methods are implemented for it.   By keeping it anonymous and limiting
access (via a private field), we can make sure the proper methods are called.   For example,
for a proper public class, keySet() would need to be implemented to return the keys in the
proper order.    I didn't implement it as, in this case, it's not ever called.  Likewise,
clear/remove/etc... are not implemented as they are not needed in this case.  (the comment
in the code mentions this)



> Thread contention accessing JsonProperties props
> ------------------------------------------------
>
>                 Key: AVRO-2051
>                 URL: https://issues.apache.org/jira/browse/AVRO-2051
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.2
>            Reporter: Daniel Kulp
>
> See https://lists.apache.org/thread.html/dd34ab8439137a81a9de29ad4161f37b17638394cea0806765689976@%3Cuser.avro.apache.org%3E
> Basically, the getJsonProp method, being synchronized, is causing thread contention issues
when trying to share schemas between threads.    My proposal (pull request forthcoming) is
to treat "props" as an immutable map and do a copy+add+swap for the addProp method.   This
will make the addProp call slower (particularly for large maps of props), but would make the
reads significantly faster as no locking will be needed.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message