Description
Some tests shows that use Collections.synchronizedMap for create a LRU cache cause some contention.
We have 3 places susceptibles for this optimization:
- org.apache.myfaces.shared.resource.ResourceHandlerCache
- org.apache.myfaces.shared.application.DefaultViewHandlerSupport
- org.apache.myfaces.lifecycle.DefaultRestoreViewSupport
Instead use Collections.synchronizedMap, we can use solr org.apache.solr.util.ConcurrentLRUCache. For example:
_checkedViewIdMap = new ConcurrentLRUCache<String, Boolean>((maxSize * 4 + 3) / 3, maxSize);
We set the lower mark on maxSize and the upper mark at 1.33 maxSize. Solr implementation is very good for these cases. In typical situations, user will set maxSize to a value that prevents cache cleanup.