Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConcurrentReferenceHashMap instead of blocking 'synchronized' #158

Merged
merged 1 commit into from May 5, 2016

Conversation

@dstepanov
Copy link
Contributor

@dstepanov dstepanov commented May 2, 2016

During profiling application I have found many threads are at some point waiting for FeatureContext call.
My solution is to use ConcurrentReferenceHashMap class created by Doug Lea and released under public domain.

Many projects are doing the same:
https://github.com/hibernate/hibernate-validator/blob/master/engine/src/main/java/org/hibernate/validator/internal/util/ConcurrentReferenceHashMap.java
https://github.com/javagems/grizzly-http-webserver/blob/a47796b1cd6f17919aa405a9bfae7e223a46cef4/src/com/sun/grizzly/util/ConcurrentReferenceHashMap.java

@dstepanov dstepanov changed the title Use ConcurrentReferenceHashMap instead of blocking synchronized Use ConcurrentReferenceHashMap instead of blocking 'synchronized' May 2, 2016
@chkal
Copy link
Member

@chkal chkal commented May 4, 2016

Hey. Thanks a lot for the pull request.

I'm open for any improvement over the current synchronized implementation. To be honest, I'm not an expert for tuning such multi-threaded scenarios. So any help here is welcome.

A few things:

  • Your pull request contains many white spaces changes which makes reading it very hard. Could you perhaps fix that? There is a code format profile in the source code repository that you could use. Or simply don't apply your code format after applying the change.
  • Do you have any link to the original class by Doug Lea?
  • You could move the ConcurrentReferenceHashMap to the util package there are some other places where this could be useful.

Awesome! Thanks a lot!

@dstepanov dstepanov force-pushed the dstepanov:featurecontext-without-synchronized branch 2 times, most recently from 5346470 to 5e0c625 May 5, 2016
@dstepanov dstepanov force-pushed the dstepanov:featurecontext-without-synchronized branch from 5e0c625 to b3b25e6 May 5, 2016
@dstepanov
Copy link
Contributor Author

@dstepanov dstepanov commented May 5, 2016

Hey,

I have added back spaces removed by Idea 😄 added link to the original file and moved ConcurrentReferenceHashMap to util, it was in the same package to have package scope.

@chkal chkal merged commit 9d94acf into togglz:master May 5, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@chkal
Copy link
Member

@chkal chkal commented May 5, 2016

Awesome! Thanks a lot. I just merged your patch. 🍻

@dstepanov
Copy link
Contributor Author

@dstepanov dstepanov commented May 5, 2016

Great. Thanks! 😃 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.