Hi, 
I once suspect that hibernate take too much time in
doing dirty check during session flush. However Gavin
king and other hibernate-user disagreed with me.
I did a simple performance testing to verify the dirty
check performance. 

My conslusion is that the performance is not so good
if there are many objects in session. If a session has
around 1000 objects in memory, only will the dirty
check take about 200 million second. For detailed
performance metrics, see the table below.

The structure of my testing object is very simple. One
thing I am not sure is whether the dirty checking
algorithm is related to object structure or not. If it
is, the dirty check in reality will take more time.


My testing case is attached.

---------------test logic ----------------
1. load  some (n) number of objects in memory.
2. begin tranaction.
3. // do not do anything here.
4. commit.
Then calculate the time consumed from step 2 and 4. 

---------------- test code -----------------
List ps=new ArrayList(10010);
for (int i=1000; i<2100; i++)
{
   Parent p1=(Parent)session.load(Parent.class, new
Long(i));
   p1.getValues().size();
}
                        
long startTime=System.currentTimeMillis();
Transaction tx=session.beginTransaction();
tx.commit();
long endTime=System.currentTimeMillis();
System.out.println("total time(in
ms):"+(endTime-startTime));


-------------The performance metics---------
objects in memory       time (in ms) for dirty check (3
experiments)
10000                   741, 751,821
2000                    200, 230, 230
1000                    201, 191, 190,
100                     30, 30, 30
1                       10, 10, 10


jason


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Attachment: src.zip
Description: src.zip

Reply via email to