Hi,

I'm investigating big performance problems in my Hibernate + EHCache webapp. What happens is that after several runs of my benchmark scenario, the webapp becomes very slow and the number of requests per second drops dramatically.

When I monitor the application with Yourkit, I see that there is a very high contention in Hibernate ReadWriteCache. In fact, I've got a full dump where all threads are blocked in ReadWriteCache (put, lock or other methods) and the only running thread is in net.sf.ehcache.store.MemoryStore.findEvictionCandidate:

http-127.0.0.1-8080-Processor640  CPU time: 0:06
sun.misc.Unsafe.getObjectVolatile(Object, long)
java.util.concurrent.atomic.AtomicReferenceArray.get(int)
net.sf.ehcache.store.MemoryStore.findEvictionCandidate(Element)
net.sf.ehcache.store.MemoryStore.removeElementChosenByEvictionPolicy(Element)
net.sf.ehcache.store.MemoryStore.doPut(Element)
net.sf.ehcache.store.MemoryStore.put(Element)
net.sf.ehcache.Cache.put(Element, boolean)
net.sf.ehcache.Cache.put(Element)
net.sf.ehcache.hibernate.EhCache.put(Object, Object)
net.sf.ehcache.hibernate.EhCache.update(Object, Object)
org.hibernate.cache.ReadWriteCache.afterInsert(Object, Object, Object)

In EHCache source code, I see that there is a special algorithm for cache with more than 100 entries, which is my case (200000 entries, no disk store).

Is it possible that this algorithm is slow in some cases?

Thanks.