CMP overhead
giorgio42 Jul 16, 2002 3:07 AMEnvironment: JB3.1.0alpha (but most likely the same with 3.0.1), Win2K/XP/Solaris, JDK1.4.0, Oracle8.1.7.0.0
I have the following scenario:
Client -> SLSB Remote/txn=required -> EB Local/txn=required
In my application, when an entity bean instance is read from the store, it is converted to a value object by copying the entity bean properties, for example:
private ValueObject copyAttributes(EntityLocal entity) {
...
valueObject.setId( entity.getId() );
valueObject.setName( entity.getName() );
...
return valueObject;
}
Reading a list of entities is done by iterating over the a finder result and converting each object in turn.
My assumption was, because the local interface is used here, that each of these operations is a simple assignment (or not much more).
Setting the logging level for plugin and resource to TRACE I see for each of the property accesses above the following sequence of operations (in this case, getName()):
2002-07-15 21:01:53,468 DEBUG [org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor] invokerBInding is null in ProxyFactoryFinder
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.LogInterceptor] Start method=getName
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Current transaction in MI is TransactionImpl:XidImpl [FormatId=257, GlobalId=serenissima//26, BranchQual=]
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TX_REQUIRED for getName
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Thread came in with tx TransactionImpl:XidImpl [FormatId=257, GlobalId=serenissima//26, BranchQual=]
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.EntityLockInterceptor] Begin invoke, key=382
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.EntityInstanceInterceptor] Begin invoke, key=382
2002-07-15 21:01:53,468 TRACE [org.jboss.resource.connectionmanager.CachedConnectionManager] old stack for key: ProxyTarget[org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler@e142a5]
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.EntitySynchronizationInterceptor] invoke called for ctx org.jboss.ejb.EntityEnterpriseContext@49494e, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=serenissima//26, BranchQual=]
2002-07-15 21:01:53,468 TRACE [org.jboss.ejb.plugins.EntitySynchronizationInterceptor] register, ctx=org.jboss.ejb.EntityEnterpriseContext@49494e, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=serenissima//26, BranchQual=]
2002-07-15 21:01:53,484 TRACE [org.jboss.resource.connectionmanager.CachedConnectionManager] popped object: ProxyTarget[org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler@e142a5]
2002-07-15 21:01:53,484 TRACE [org.jboss.ejb.plugins.EntityInstanceInterceptor] End invoke, key=382, ctx=org.jboss.ejb.EntityEnterpriseContext@49494e
2002-07-15 21:01:53,484 TRACE [org.jboss.ejb.plugins.EntityLockInterceptor] End invoke, key=382
2002-07-15 21:01:53,484 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TxInterceptorCMT: In finally
2002-07-15 21:01:53,484 TRACE [org.jboss.ejb.plugins.LogInterceptor] End method=getName
In a test I am reading 1000 entities each having 10 properties, so this sequence is executed 10000 times.
The effect on performance is quite disastrous (compared to raw JDBC):
Reading 1000 entities takes about 20 seconds, while it takes less than 2 seconds reading them using JDBC directly, looping through the resultset and creating the value objects "manually".
It should be noted that in the CMP scenario all data is preloaded with one single SELECT (pagesize=1000,on-find, default eager load-group) and then taken from the read-ahead cache.
The time for executing the SELECT is almost neglectable. The test has been done with logging level=INFO, no logging output is generated while reading the entities.
Is there a way to avoid this overhead when accessing EB
properties through the local interface? Or is this mandated by the spec?
Thanks in advance.
Georg