-->
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 1, 2, 3, 4  Next
Author Message
 Post subject: How to speed up buildSessionFactory call?
PostPosted: Wed May 18, 2005 7:03 am 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Hibernate version: 3.03

I am using Hibernate 3.0.3 and the startup time is slow (well, too slow
for repetitive junit tests). I am pointing to the right DTD so that's not
the issue for me - it seems that buildSessionFactory takes forever
(building it for 34 mapped classes takes 2 seconds for creating the
configuration and the sessionFactory takes 12 seconds!?).

Is there a way to speed this up? Can the session factory data structures
be serialized (I've seen a reference to it but could not actually do it -
I get exceptions along the line of 'cannot initialise SessionFactory: null')
or something so that for running a series of tests repeatedly,
this will not become prohibitively long?

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 7:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
34 classes should not take 12 seconds...

How big are they ? (number of properties)

Have you followed guidelines at http://hibernate.org/194.html ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:41 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
max wrote:
34 classes should not take 12 seconds...

How big are they ? (number of properties)

Have you followed guidelines at http://hibernate.org/194.html ?


Max,

There seem to be some questions posted on .../194.html with regards to how this should be used. It appears that the method name has changed and it doesn't provide any insite into how to serialize the mapping files the first time.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you try and call it ? I've update the page to use the right names.

The method does the initial serialization for you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:16 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
max wrote:
did you try and call it ? I've update the page to use the right names.

The method does the initial serialization for you.


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:57 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pksiv wrote:
max wrote:
did you try and call it ? I've update the page to use the right names.

The method does the initial serialization for you.


Thanks.


One note.... in v3.0.3 the method is addCachableFile(...) but in CVS, the method has been renamed addCacheableFile(...). (Cach-e-able)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 10:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it has always been addCacheableFile and still is in cvs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 10:16 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pksiv wrote:
pksiv wrote:
max wrote:
did you try and call it ? I've update the page to use the right names.

The method does the initial serialization for you.


Thanks.


One note.... in v3.0.3 the method is addCachableFile(...) but in CVS, the method has been renamed addCacheableFile(...). (Cach-e-able)


My mistake. It's just the 194.html document that has addCachableFile().


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 10:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its in the wiki community area, feel free to correct it ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 7:03 pm 
Regular
Regular

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

Thanks for the reply. However, this does not address my situation because:
a. my classes are not really large. Most of these have less than 10
properties and only about 5 use sets or lists.
b. I'm already using the binary configuration route. As I stated, the
problem is not with the configuration loading, its the SessionFactory
building that takes the longest (13 seconds out of about 15 seconds
of Hibernate initialisation time).

So, is there a way to speed up the SessionFactory building part? I
understand that a lot of classes need to be instantiated as a result,
but isn't there a way to serialize the whole lot?

As I've stated before, I tried to serialize the SessionFactory to disk,
and while it succeeds, the resulting binary clearly has no actual
data in it and attempts to read it back from disk failed.

This said, the problem for me is not the projected start up time when
the complete application is mapped, it's the startup time for junit tests,
and unfortunately, very few of these tests require less than the complete
set of classes, since my model is highly interconnected.

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 7:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the time spent in sessionfactory is classloading of your model.
Even though we could serialize it out we would still need to perform the classloading.

Do you have some big static intializers or something ?

13-15 seconds really sounds like way to much.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 8:14 pm 
Regular
Regular

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

max wrote:
the time spent in sessionfactory is classloading of your model.
Even though we could serialize it out we would still need to perform the classloading.

Do you have some big static intializers or something ?

13-15 seconds really sounds like way to much.

/max


not that I know. Is there any way I can profile/breakdown this to
gather interesting information for you guys?

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 2:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
run a profiler on it and see where it uses its time...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 7:04 pm 
Regular
Regular

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

The buildSessionFactory spends most of its time in net.sf.cglib.reflect.FastClassEmitter constructor for the mapped classes.

I could send you the actual profile snapshot (either as a JourKit Java
Profiler file or as an HTML export).

I've read before that there were some issues with the versions of cglib
that may be used, but I think I've ensured that I'm using the correct
versions:
cglib: 2.1
asm*: 1.5.3

_________________
Cheers,

Bonny

please don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 2:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes and fastclassemitter is doing code generation and classloading AFAIK.

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

/max

_________________
Max
Don't forget to rate


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 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.