Remove synchronization from ResourceBundleMessageSource [SPR-16235] #20782
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Masahiro Ide opened SPR-16235 and commented
The ResourceBundleMessageSource class caches the properties to HashMaps by default and
this class locks the hashmaps when getting/putting a entry from/to hashmaps. This synchronization causes slow down the property look-up in multi threaded application.
Here is the stack trace, notice the first line is holding lock on a hashmap, which is the hashmap that holds properties:
Because in major case, these hashmaps are ready-heavy and entries of these hashmaps will not be purged. To improve this, want to use a concurrent hashmap.
Here is the patch, jmh benchamrk and benchmark results.
As you can see, if my change is correct, using ConcurrentHashMap is 5~6X faster than large synchronization block.
Affects: 4.3.12, 5.0.1
Reference URL: https://github.com/imasahiro/spring-issue
Issue Links:
Referenced from: pull request #1605, and commits d9af4d6
The text was updated successfully, but these errors were encountered: