Defining entity bean methods results in slower execution. W
jsimone Dec 28, 2004 1:17 PMI am using JBoss 4.0RC2, MySQL 4.1.7, Sun JVM 1.5. I have the following test which does one create and then 1000 gets :
public void testCreateOnceAndRepeatedlyRead() throws Exception { String cid = _confMgr.addConference(DTOGen.conference(1)); String eid = _confMgr.addEvent(DTOGen.event(1,"A"),cid); for (int i = 0; i < 1000; i++) { EventDTO dto = _confMgr.getEvent(eid); assertNotNull(cid); System.out.println("testCreateOnceAndRepeatedlyRead passed."+(i+1)); } }
I then run this test 2 ways changing nothing except ADDING the following definition in JBOSS.XML :
<entity> <ejb-name>Event</ejb-name> <jndi-name>EventHome</jndi-name> <local-jndi-name>EventHome</local-jndi-name> <configuration-name>Standard CMP 2.x EntityBean</configuration-name> <method-attributes> <method> <method-name>get*</method-name> <read-only>true</read-only> </method> <method> <method-name>find*</method-name> <read-only>true</read-only> </method> </method-attributes> </entity>
The first set of tests I ran 7 times WITHOUT the above declaration in JBOSS.XML.
32.6 secs
24.3 secs
25.4 secs
23.4 secs
23.3 secs
24.1 secs
23.4 secs
Average time: 25.2 seconds to execute the JUnit test case
Now we add the optimization to declare get* and find* to be read-only methods expeciting a performance boost.
Repackage, redeploy, restart server.
The second set of tests I ran 7 times WITH ONLY the above declaration in JBOSS.XML. No other changes to application or server or the machine it is running on.
110.4 secs
105.8 secs
103.7 secs
102.8 secs
102.7 secs
102.7 secs
103.5 secs
Average time: 104.5 seconds to execute the JUnit test case (same test as before)
Can someone please explain why I would be seeing these results. The performance degradation is 104.5/25.2 = 4.1 times slower.
I was expecting that I would actually get better performance by declaring the Event methods get* and find* to be read-only.
I have read the JBoss docs and I am attempting to make my application run faster by making changes to the descriptor files. As you can see I have not had much luck in doing so.
I have not tried this on older versions of JBoss. The JDBC connection pool is set to min 5 and max 20 connections. The FILE logging is set to WARN and there are no warnings or errors in either the console log or the file log.
Could it be that my read-only declarations are not being respected? Even so, I would expect results to be the same as no declaration not 4.1 slower.
Joe