Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
River_2.1.2
-
None
Description
The PreferredClassProvider.lookupLoader() method uses a single coarse lock to synchronize its cache of ClassLoader instances. Because the creation of a ClassLoader can be an expensive operation (including remote calls in some special cases) this global lock can be a significant bottleneck.
Attached is a patch to refactor that code to hold only a finer grained lock while constructing the ClassLoader in case of a cache miss. The refactor moves the ReferenceQueue field out of any synchronized block, because that class is already thread-safe. The refactor still holds a coarse lock while checking the cache, but holds only a finer lock (per cache line) while checking and possibly creating the ClassLoader.
See also RIVER-336 where an alternative version of this patch was proposed. But a following analysis revealed concurrency problems with that patch: http://mail-archives.apache.org/mod_mbox/river-dev/201104.mbox/browser