-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Startup times are a significant issue.
PostPosted: Fri Nov 11, 2005 4:09 am 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
Hi,

We are currently evaluating Hibernate as our persistence layer for our next big project. This project will be built on a pre-existing enterprise database that has 600+ tables.

As part of the evaulation process we have generated mapping files for about 300+ of those tables.

This is where we run into a potential show-stopper for us:

The startup of the application is taking 40+ seconds. Most of this time is being spent building the session factory, as it appears that the factory is loading and validating all 300+ mapping files. I will have a very difficult time introducing hibernate into our environment (especially in development) when starting the application takes this long. The code/run/debug cycle will simply be unacceptable.

I have switched the mappings to use the addCacheableFile and this has not really improved the performance that much. Again, it appears that most of the time is being spent in the creating of the factory.

Can we cut down on the amount of validation the session factory build is performing on the mappings?

Is there a way to have the factory load the mappings on demand? And if this functionality does not currently exist, how hard would it be to implement this feature in the factory implementation?

Perhaps pre-load all the class/object names and as the objects/classes are encountered by the engine, load their entire definition at that point?

I would really like to leverage hibernate for our next project and projects going forward, but this one issue could put a halt on that.

Thanks for your time.

Tyler Van Gorder
tkv@landacorp.com
Landacorp.

ps. I would be willing to work with someone to help implement this feature, I just simply don't know the internals well enough.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 7:51 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Have you tried to run it in profiler ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 1:05 pm 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
baliukas wrote:
Have you tried to run it in profiler ?


I have not yet run it through a profiler, as we are in the evaluation phase I was hoping someone might be able to point out something obvious that can improve the performance.

I will run it through a profiler and get back to you later today.

thanks

Tyler.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 1:20 pm 
40 seconds sounds about right for 300 tables. Can you partition the tables into smaller independent sets? Then developers could start the application just for the set they are working on. But in general, 40 seconds doesn't sound bad for such a large application.


Top
  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 1:32 pm 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
fljmayer wrote:
40 seconds sounds about right for 300 tables. Can you partition the tables into smaller independent sets? Then developers could start the application just for the set they are working on. But in general, 40 seconds doesn't sound bad for such a large application.


I would prefer not to have to partition the tables, as we have all the meta data for the tables in an excel spreadsheet. We have a java program that reads that spreadsheet and uses velocity to generate our persistent java classes, their associated mapping files and the DDL for the database. I have not provisions (currently) in the generator to partition the objects in groups.


The 40 second startup times will kill us in the development/debug cylce. Everytime we make a coding change and want to test it, we would have to wait for the session factory to be built.

40secs X20 Times a DayX8 developers == 106 Minutes a day, Lost productivity. That is pretty costly, when you figure the salaries of our developers.
======================================


Again, it just seems like on-demand loading of the mappings could be possible, I just wanted to ask the hibernate developers how difficult this would be to refactor the session factory to do this.


Tyler.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 1:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Very difficult. Besides, we have profiled this and a large majority of the time spent in SessionFactory "creation" is actually spent in the xml parsers which actually happens during Configuration processing.

I used to work on an application mapping nearly 400 tables and 40 seconds seems unreasonable for your 300 tables. It's been awhile since I worked on that, so I can't really remember the specifics, but I seem to recall being able to build the SessionFactory locally much faster than 40 secs with more mappings.

One thing I'd recommend checking is to make sure you have your DOCTYPE definitions correct within the mapping files. Based on the DOCTYPE, Hibernate registers an EntityResolver with the XML parsers to be able to resolve the DTD locally. If the DOCTYPE def is messed up, it'll make network calls to hibernate.org which would seriously slow it down.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
xml parsing is not his issue since he is using cachableFile.

The time is most likely build on the necessary classloading/generation.

But yes, try and use a profiler to verify it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 8:10 pm 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
max wrote:
xml parsing is not his issue since he is using cachableFile.

The time is most likely build on the necessary classloading/generation.

But yes, try and use a profiler to verify it.


Hi Max,

Ok, I have a call tree from jprofiler, exported as HTML.

How can I get this to you? zipped up it is only 40K.


Tyler.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 2:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put it on a jira issue ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 1:13 am 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
max wrote:
put it on a jira issue ?


Ok, I have created a JIRA issue and attached the call tree (zipped HTML) document.

The Key is: HHH-1154

Thanks.

Tyler


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 8:11 pm 
Newbie

Joined: Wed Oct 26, 2005 1:31 am
Posts: 10
Follow up on this:

The hibernate team recommended trying 3.1 and that has significantly helped in the performance department, my load times are down from 42 seconds to 25 seconds.
===========================================

From the JIRA issue:

Thanks everyone for you help, I downloaded 3.1 RC 2 and it has definately helped, here are my numbers loading 333 persistent classes now:

33.7171 Seconds (Cached resources off, JDK 1.4)
25.5620 Seconds (Cached resources Off, -Dhibernate.cglib.use_reflection_optimizer=false, JDK 1.4)
24.7500 Seconds (Cached resources Off, -Dhibernate.cglib.use_reflection_optimizer=false, JDK 1.5)
131.375 Seconds (Cached resources, 2nd run (deserialization of mapping files))


The 25 Seconds is quite an improvement from 42. I did notice in my testing that it appears the "optimizations" seem to slow the loading down rather than speeding it up. Especially, the de-serialization vs using an XML parser to load the mapping files.

There also seems to be quite a hit when the reflection optimizer is true. Is that because performance is not realized until the engine is actively issuing queries? More curious than anything.


Thanks again.

Tyler.

ps. Is there anything else I can do to further reduce the startup time? Yes I'm greedy. 8-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 2:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i can't belive you get 131 seconds when rereading the serialized xml that does NOT make sense.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 4:06 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
snowtoad wrote:
There also seems to be quite a hit when the reflection optimizer is true. Is that because performance is not realized until the engine is actively issuing queries? More curious than anything.

"reflection optimizer" generates byte code to avoid reflection (property get/set become direct calls) it takes time to generate code. It is better to dissable this stuff for development, you will have better error messages without it.
Sometimes it makes sence to dissable "reflection optimizer" in production, modern JVM implementations optimize reflective calls in the same way as CGLIB, you can save permanent memory.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 11:35 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
baliukas wrote:
Sometimes it makes sence to dissable "reflection optimizer" in production, modern JVM implementations optimize reflective calls in the same way as CGLIB, you can save permanent memory.


This is very interesting. Do you have any specifics on this? For example, could you say which JVMs optimize reflective calls (Sun's JRE 1.4.2, 5.0, ... ??)? I mean, I can always try to test it out myself, but if you already know Sun's 1.4.2 does this optimization, for example, that would save me the effort. Thanks!

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 15, 2005 2:13 pm 
Beginner
Beginner

Joined: Thu Feb 03, 2005 10:42 pm
Posts: 30
steve wrote:
One thing I'd recommend checking is to make sure you have your DOCTYPE definitions correct within the mapping files. Based on the DOCTYPE, Hibernate registers an EntityResolver with the XML parsers to be able to resolve the DTD locally. If the DOCTYPE def is messed up, it'll make network calls to hibernate.org which would seriously slow it down.


I also have significantly slow startup times and it is killing my development time. As far as I can tell my doctype is proper, but could you expand on what needs to be in place for your DTD to locally resolve?

Here is my DOCTYPE

Code:
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  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.