Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
AbstractFallbackTransactionAttributeSource's Map synchronization causes lock contention [SPR-4664] #9341
We are encountering the serious perfomance problem when we using Spring 2.X. CPU hit 100% when a lot of threads are doing the work below:
And we check source of AbstractFallbackTransactionAttributeSource.java, we found Spring are using HashMap with Synchronized for thread safe purpose.
Why not use JDK 1.5 's CurrentHashMap?
Accoring to Doug Lea, this won't be a bug of JDK, and could be fixed with our way of using HashMap.
Affects: 2.5 final
Here are the source code of AbstractFallbackTransactionAttributeSource(spring 2.5.1).
Juergen Hoeller commented
Thanks for raising this! I've revised AbstractFallbackTransactionAttributeSource accordingly, using a concurrent Map for the attribute cache in order to avoid lock contention.
This will be available in the next 2.5.4 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it a try and let me know whether it works for you...