-->
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.  [ 59 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Sat May 21, 2005 4:38 am 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
max wrote:
yes and fastclassemitter is doing code generation and classloading AFAIK.

I still dont get why it should take 12 seconds for 30 classes.

/max



neither do i :)

The timing is done on a Dell Inspiron 5150 with a P4 3.2 GHz with lots of
memory so there's no good reason for this.

Is there any way to get a benchmark value out of some agreed scenario
(i.e a mapping file of some description with the associated classes) that
we can compare?

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 21, 2005 4:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
feel free to create one.

At the moment the best we have is in ConfigurationPerformanceTest - but that one is just a bunch of hbm.xml from hibernate test suite.

-max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 1:39 am 
Newbie

Joined: Tue Nov 02, 2004 2:37 am
Posts: 3
I am experiencing a similar slow down in building Configuration and SessionFactory after upgrading to Hibernate 3.0.2 from Hibernate 2.1.8. In our case we around 400 persistent classes, so it really is quite slow in elapsed time, in the order of 2-3 minutes depending on the system. Disabling reflection optimisation shaves about 20 secs off the startup time, the bulk of the time is still in building the Configuration.

I have experimented with serializing the entire Configuration object, but received a java.lang.NoClassDefFoundError: org/jaxen/VariableContext

while writeObject was trying to serialize a namespace node of the dom4j Document, which seemed to result in serialisation of a DocumentFactory. Should instances of org.hibernate.Configuration be Serializable ? The ConfigurationPerformaceTest that comes with Hibernate, and comments on the developers list seem to indicate it should be.

If it's useful I could provide a profiler breakdown of the time taken in building the Configuration and the SessionFactory for a fairly large real world example.

Cheers,

Andrew


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 1:54 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Probably cglib cache is too "soft" and it generates the same code many times, try to increase initial JAVA hep size (-Xms128M )


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 4:19 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
BTW try -Xverify:none, it must help if class loading is a problem.


Top
 Profile  
 
 Post subject: Some statistics
PostPosted: Mon May 23, 2005 10:07 am 
Newbie

Joined: Tue Sep 21, 2004 10:09 am
Posts: 5
Location: Rome, Italy
Hi,

I just want to show you some statistics about our project.

We have more than 600 mapped classes and we have serialized the Configuration object in order to speed up starting time.
    Time for mapping 600 classes: 20 seconds
    Time for deserializing Hibernate configuration: less than 1 second
    Time for building SessionFactory: 20 seconds

Conclusions: we have reduced the starting time from 40 secs to 20 secs, and this is very important for us, but the time for building SessionFactory still remains the same. The SessionFactory cannot be serialized because it has only transient attributes.

Regards

Pietro Pizzo


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 11:11 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
20 secs is not so bad for 600 classes, cglib needs ~15 ms per class, verifier ~10 ms. (it is on my PC with trivial classes) it is not very fast to open and read 600 files too. It is possible to configure cglib to cache generated classes on disk, but I do not think it will be very helpful. Probably it is better to load and generate classes "lazy" if startup is important.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 5:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, and we looked into this - but it require us to but thread synchronizaiton code in vital places in hibernate that would/could make it less performant in more often used places and much more complicated than necessary.....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 6:24 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Quote:
Time for mapping 600 classes: 20 seconds
Time for deserializing Hibernate configuration: less than 1 second
Time for building SessionFactory: 20 seconds


In my case, the shortest time I've been able to achieve for my project
in its current state is 9 seconds, for 34 classes. This is quite a bit slower
than the case quoted above. In my profiling attempts, I found that the
'culprit' method is actually within the asm jar - org.objectweb.asm.Type.getDescriptor,
followed by ByteVector.putUTF8. So maybe the problem is not in cglib, but
rather in asm.
Also, I don't know if this is the same for others, but I'm using JDK5, which
may itself have an impact (verification is longer?)

In any case this still is a problem for reptively running unit tests which
need to load/initialise the SessionFactory, and so my original question
remains: Is there a way to somehow serialise the contents of the
SessionFactory and then load it from disk? Obviously this should be taken
with whatever caveats about stale caches and mapping data, but it should
be still beneficial to do.

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 7:04 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Quote:
BTW try -Xverify:none, it must help if class loading is a problem.


I've just tried, and there's no discernible difference

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 4:38 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Yes signature parsing is not very fast (string manipulation), but most of overhead on startup is the first proxy instance creation (generated static initializer is very heavy ). It is possible to generate class only and to create proxies using reflection, it is not very fast on old JVM implementations, but it will work without synchronization :

Code:
 

       
          //class generation:
           Enhancer en = new Enhancer();
            en.setSuperclass(aClass);
            en.setInterfaces(new Class[]{fakeClasses[i]});
            en.setCallbackType(MethodInterceptor.class);
            Class cls = en.createClass();
            en.setUseCache(false);

            //instance creation,
           //it will invoke class initializer at the first time,
           // initializer generates code  too ("fast class" stuff ) :

            Factory f =  (Factory) cls.newInstance();
            f.setCallback(0,interceptor);
            return f;
       


It must help to save ~30% of cglib and ASM overhead on startup.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 4:40 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
bonnyr wrote:
Quote:
BTW try -Xverify:none, it must help if class loading is a problem.


I've just tried, and there's no discernible difference


It depends on JVM implementation, probably your verifier is very fast and it is not visible.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 7:29 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
test this patch
http://opensource.atlassian.com/project ... se/HHH-525


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 8:29 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
baliukas wrote:


Tried it, and indeed for the bare test (simply loading the config and building
the SessionFactory), it cut the SessionFactory building time from 12 seconds to about 6 seconds.

Thanks for this, it helps. This however begs the question of whether the
whole initialisation performed inside the Enhancer (called by CGLIBLazyInitiialiser
can be deferred and itself be created lazily.
If I was making sure all the classes are present in whatever classpaths such that there is no
initialisation error, could I configure CGLIB to perform the initialisation
of the enhanced class in installments, as it were?

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 1:11 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I will review code, it must be possible to optimize code generation itself (startup was not a priority). It is possible to generate all stuf lazy, but it will need synchronized call per proxy instance (probably nobody wants it)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 59 posts ]  Go to page Previous  1, 2, 3, 4  Next

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.