-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Performance Problem with Hibernate 3.2.0 GA comp. 3.2.0 RC2
PostPosted: Thu Nov 09, 2006 9:29 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
Hallo,

we've used the Hibernate for Version 3.2.0 CR 2 with Hibernate Annotations and Proxy interfaces for Lazy initialization. After we changed to Version 3.2.0 GA our Application is 5-7 times slower than before. My Java Profiler says that the Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.addCheckingTypes is called over 11 Million times (with recursion). This method was not present in the old release candidate. The problem is that this methods adds recursively all interfaces of a type and its subclasses into a List in our non trivial object hierarchy.

Thanks

Alex

Hibernate version: 3.2.0 GA

Name and version of the database you are using: Oracle Database 10g Version 10.2.0.1 Enterprise Edition


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 2:33 pm 
Newbie

Joined: Thu Nov 09, 2006 2:25 pm
Posts: 2
Please create a jira with an example of what you are doing in your case.

For your test case in which you see over 11 million calls to addCheckingTypes, roughly how many times was the org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke called?

The addCheckingTypes() is trying to detect an error situation.

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 3:55 pm 
Newbie

Joined: Thu Nov 09, 2006 2:25 pm
Posts: 2
Just as a note to myself and others, the isCastable check was added to handle passing test case org.hibernate.test.interfaceproxy.InterfaceProxyTest

Otherwise, we get this failure (failed to get classcastexception as expected):

<testcase classname="org.hibernate.test.interfaceproxy.InterfaceProxyTest" name="testInterfaceProxies" time="0.828">
<error message="object is not an instance of declaring class" type="java.lang.IllegalArgumentException">java.lang.IllegalArgumentException: object is not an instance of declaring class
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:185)
at org.hibernate.test.interfaceproxy.SecureDocument$$EnhancerByCGLIB$$e59e25.getOwner(&lt;generated&gt;)
at org.hibernate.test.interfaceproxy.InterfaceProxyTest.testInterfaceProxies(InterfaceProxyTest.java:74)
at org.hibernate.test.TestCase.runTest(TestCase.java:248)
at org.hibernate.test.TestCase.runBare(TestCase.java:314)
</error>


Top
 Profile  
 
 Post subject: Hibernate Proxy Interfaces
PostPosted: Fri Nov 10, 2006 5:05 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
The CGLIBLazyInitializer.invoke() method was called 64.000 Times. I found out that the Problem were the @Proxy annotations with a specified proxy interface in all of our classes (this was necessary in the old version to prevent ClassCastExceptions). If we specify the proxy interface only on the classes where we need it, the performance is much better.

Thanks

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 5:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is a factor of 171 !? that sounds very fishy ;(

Could you give a concrete example/mapping that shows when this occur and does not occur ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Example
PostPosted: Fri Nov 10, 2006 8:36 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
These are just the class annotations of our persistent objects because our Application is to complex for an easy example.

Code:
@Entity(name = BEAN_NAME_AttributeDefinition)
@Table(name = TABLE_NAME_AttributeDefinition)
@PrimaryKeyJoinColumn(name = OID_COLUMN_REF)
@Proxy(lazy = true, proxyClass = AttributeDefinitionProxy.class)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AttributeDefinitionHb extends NameableAccessControlledObjectHb implements AttributeDefinitionProxy {
....
}


Code:
@Entity(name = BEAN_NAME_NameableAccessControlledObject)
@Table(name = TABLE_NAME_NameableAccessControlledObject)
@PrimaryKeyJoinColumn(name = OID_COLUMN_REF)
@Proxy(lazy = true, proxyClass = NameableAccessControlledObjectProxy.class)
public class NameableAccessControlledObjectHb extends NameableHb implements NameableAccessControlledObjectProxy {
....
}


Code:
@Entity(name = BEAN_NAME_Nameable)
@Table(name = TABLE_NAME_Nameable,
      uniqueConstraints = {
      @UniqueConstraint(
            columnNames = {IDENTIFICATION_NAME, NAMESPACE_OID }
      )
})
@Inheritance(strategy = InheritanceType.JOINED)
@Proxy(lazy = true, proxyClass = NameableProxy.class)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class NameableHb extends IdentifiableHb implements NameableProxy {
....
}


Code:
@MappedSuperclass
public abstract class IdentifiableHb extends PersistentHb implements IdentifiableProxy, Serializable {
.....
}


If we remove the proxyClass attribute of the @proxy annotation, which was necessary in allmost every position in the old version when you have to use it in one place, the performance is much better.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 11:43 am 
Newbie

Joined: Wed Apr 26, 2006 10:13 am
Posts: 8
Location: Waltham, Massachusetts USA
Alex,

Are you going to create a Jira for this issue?

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 7:35 pm 
Newbie

Joined: Wed Apr 26, 2006 10:13 am
Posts: 8
Location: Waltham, Massachusetts USA
Alex,

I'll create a Jira for this, but since I don't have a test case that reproduces the problem that you are seeing, it will be hard to ensure that I have fixed it. I'll need you to test the fix. Is that something that you will be able to do?

I'll add the jira number to this forum message.

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 8:14 pm 
Newbie

Joined: Wed Apr 26, 2006 10:13 am
Posts: 8
Location: Waltham, Massachusetts USA
I created jira HHH-2229 (http://opensource.atlassian.com/project ... e/HHH-2229) for this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 11, 2006 12:13 am 
Newbie

Joined: Wed Apr 26, 2006 10:13 am
Posts: 8
Location: Waltham, Massachusetts USA
Alex,

I checked a fix in for this issue but I need you to verify it. Can you apply the patch file CGLIBLazyInitializer.patch that is available on HHH-2229.

If your not going to test the patch, let me know that as well.

Thanks,
Scott


Top
 Profile  
 
 Post subject: Problem solved
PostPosted: Mon Nov 13, 2006 5:20 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
Hallo,

for me the problem is solved now. We have removed to proxyInterface Annotations where we don't need them and the performance is much better now and comparable to the old version. I did now test the patch because we can't reproduce the old situation with the new code after the changes, but I think the removal of the recursion is a good idea.

Thank you very much for your support!

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 5:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you mean "did not" and not "did now", right ? :)

Any chance you could go back to your previous setup and test the patch ? Just so we can verify we actually fixed something.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Patch
PostPosted: Mon Nov 13, 2006 1:03 pm 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
Did not is right! I have tagged the old version in our CVS so I will try to check the patch. It will take some time because I have to prepare this test.

Alex


Top
 Profile  
 
 Post subject: The patch is OK.
PostPosted: Thu Nov 16, 2006 7:10 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
I've used the patch to build hibernate and the performance is much better in the cases then the invoke method of the CGLIBLazyInitializer class is called.

Thank you very much

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 7:23 am 
Newbie

Joined: Wed Apr 26, 2006 10:13 am
Posts: 8
Location: Waltham, Massachusetts USA
Alex,

Thank you for verifying the patch. I'll update the Jira.

Scott


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.