On Tue, Apr 29, 2008 at 2:37 PM, Funtick <[EMAIL PROTECTED]> wrote:
>
> Thanks Otis;
>
>
> > > Object get(Object key) {
> > > synchronized (map) {
> > > ... .incrementAndGet()
> > > ...
> > > }
>
> Existing code does not slow down performance in simplest cases. However, it
> slows down with read-only Faceted queries because each such query hits cache
> thousands times even in simplest scenario.
>
> This is ACCESS-ORDERED (LRU implementation) LinkedHashMap map = new
> LinkedHashMap(initialSize, 0.75f, true)
> - so that even GET is a structural modification (changind an order of a
> list!), it should be synchronized... even if it is not, "changing order"
> costs some CPU time.
>
> Simplest way to improve: go with INSERTION-ORDERED (FIFO implementation)
> linked hash map, and unsynchronize GET(); acceptable for many cases.
Why don't you try this and report the results.
I still think that the bottleneck is likely to be something else
(after all, you have to do quite a bit of work for every item
retrieved from the cache or inserted into the cache).
> I also don't understand why regenerateItem() is not synchronized (warm()
> method in LRUCache should be synchronized on _local_ map).
After a quick re-inspection of this code, it looks fine to me. If you
see something that isn't thread safe, please let us know.
-Yonik