[
https://issues.apache.org/jira/browse/AVRO-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16090365#comment-16090365
]
ASF GitHub Bot commented on AVRO-2051:
--------------------------------------
GitHub user dkulp opened a pull request:
https://github.com/apache/avro/pull/236
[AVRO-2051] Remove synchronization for JsonProperties.getJsonProp
This change does two basic things:
1) Makes "props" a private field and requires the subclasses to access it
via the additional methods. This allows some changing of the underlying
implementation a bit easier.
2) Change props to an AtomicReference and makes it act like an immutable
map. The addProp method does a full copy of the map, adds the new value, and
then atomicly swaps in the map thus not affecting other threads that would be
using the value that was "current" when they called the get method.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dkulp/avro master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/avro/pull/236.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #236
----
commit ad14635fa3af97b90282a79b7e04a0b8753e45b5
Author: Daniel Kulp <[email protected]>
Date: 2017-07-17T19:08:10Z
[AVRO-2051] Remove synchronization for JsonProperties.getJsonProp
----
> 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)