[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4068) Hibernate's ReadWriteCache synchronization slow down ehcache

shaoxian yang (JIRA) noreply at atlassian.com
Mon Aug 3 17:10:12 EDT 2009


Hibernate's ReadWriteCache synchronization slow down ehcache 
-------------------------------------------------------------

                 Key: HHH-4068
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4068
             Project: Hibernate Core
          Issue Type: Bug
            Reporter: shaoxian yang


Hi, I am setting up hibernate to work with ehcache. Hibernate has a wrapper to call underlying ehcache.  
 
Their wrappers are ReadWriteCache.java, which internally will call Ehcache. The two major methods in ReadWriteCache are synchronized: 
 
public synchronized Object get(Object key, long txTimestamp) throws CacheException { 
public synchronized boolean put( 
Object key,  
Object value,  
long txTimestamp,  
Object version,  
Comparator versionComparator, 
boolean minimalPut)  
 
 
I understand this is to ensure "read/write" strategy to read committed (when write and read thread get in at the same time, read does not get intermediate result and only get the latest committed result).  
 
However, isn't this also make concurrent read impossible when there is no write? ).  
 
It looks like we need some more advanced read/write lock at ReadWriteCache level. However, the class also have other synchronized methods which make me hesitate: 
 
public synchronized SoftLock lock(Object key, Object version) throws CacheException 
public synchronized void release(Object key, SoftLock clientLock) throws CacheException  
public synchronized boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock)  
throws CacheException 
public synchronized boolean afterInsert(Object key, Object value, Object version)  
throws CacheException 
public synchronized SoftLock lock(Object key, Object version) throws CacheException  
 
   
 
Basically I want to get the most out of ehcache performance gain. Currently, if I keep issuing the same query which read item from query cache, there is still overhead.

Can you advise me why we have to use read lock for every read when there is no write?  And is it necessary to acquire lock for any other operation than put/get in ReadWriteCache class?

Thanks in advance.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list