JBoss CMP performance nightmare.
transient Dec 20, 2002 5:25 AMI have created an app with JBoss 3.0.4.
I have a CMP bean.
It has finders etc that have required transaction, a read ahead of 100 and
and on-find strategy using local interfaces.
SQL Access to db is fine. Since in a transaction I get 1 query. This is good.
What is not good by a long shot is the fact the fetching 1000 records takes
6 seconds just to process the getXXX() methods on the local interface.
Consider the following:
Test case 1:
Objective: return collection of value objects:
ArrayList result = new ArrayList();
Collection c = findSomething(code);
Iterator i = c.iterator();
while ( i.hasNext() ) {
BeanLocal l = (BeanLocal)i.next();
result.add(l);
}
Total time 980ms. Not too bad.
Test case 2:
Objective: return collection of value objects:
ArrayList result = new ArrayList();
Collection c = findSomething(code);
Iterator i = c.iterator();
while ( i.hasNext() ) {
BeanLocal l = (BeanLocal)i.next();
String goober = getGoober();
result.add(l);
}
Total time 6000ms. Pathetic.
Adding more getXXX() slows down even more.
Whatever getXXX() is doing ( dynamic proxy etc, check for dirty read etc ) is way too complex.
The problem in performance of CMP is the time taken to access the getXXX() methods. If the
transaction and read ahead options are set correctly then the DB access part of the process seems to
work quite well.
Before any one says "Hey don't load 1000 beans this way you should not do this in EJB"
I say you would be wrong.
What this indicates is that the process of getXXX() is sludge on a stick.
Whether 1000 iterations in a loop or 1000 concurrent access to fetches for separate clients
the whole process is CPU bound.
In addition to this there does not seem to be a way to toggle a bean to be read only or not
to prevent the getXXX's from bothering to check db etc.
Ok so you can declare it a deploy time. Big deal. You need to be able to dynamically change it
to manage things like lookups. If I have to use JDBC or JDO to fetch 1000 records in real time
so my users don't fall asleep from abject boredom then CMP has missed the plot.