Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
8.3
-
None
-
None
Description
As pointed out by ben.manes in SOLR-13817 Solr code base in many key places uses a similar pattern of non-atomic get / put calls to SolrCache-s. In multi-threaded environment this leads to cache misses and additional unnecessary computations when competing threads both discover a missing value, non-atomically compute it and update the cache.
Some of these places are known performance bottlenecks where efficient caching is especially important, such as SolrIndexSearcher, SolrDocumentFetcher, UninvertedField and join queries .
I propose to add SolrCache.computeIfAbsent(key, mappingFunction) that will atomically retrieve existing values or compute and update the cache. This will require also changing how the SolrCache.get(...) is used in many components.