Looks like Joris has done some good work here:


-------- Original Message --------
Subject:        startup time
Date:   Thu, 29 Apr 2004 08:20:03 -0700 (PDT)
From:   Joris Verschoor <[EMAIL PROTECTED]>
To:     Gavin King <[EMAIL PROTECTED]>



Hi,

gmane doesn't seem to work, so I'm mailing you.


I've been fiddling a bit, and I managed to decrease the startup time by about 40% (loading all but duplicate hbm.xml files from the test directory ABCProxy/Simple)

I haven't done any SAXing, because it will clutter the source. And
maybe someone else is already doing that path.


*** XMLHelper *** I've adjusted the XMLHelper createSAXReader and createDOMReader to act cache the reader. Creating a reader takes some time. I didn't use a threadlocal, but I should.. Instead I created a static field, because I'm lazy, and if anybody wants the code, I'll fix it.


*** Databinder *** I changed in SessionFactoryImpl the Templates field in the constructor to a lazy loading mechanism. templates is only accessed when doing calling openDatabinder. Since I don't use that (JCA?) Theres no need to process the xslt file. If it's used, you could always first check if the user has set the property, so you'll get errors early.


*** Serializing Document objects *** I gained the most performance by serializing the Document objects and deserializing them, instead of parsing the XML files every time you start your application. This way you can still use DOM, and with only minor changes to hibernate the startup speeds up alot.

The problem here is, that caching is somewhat tricky:
-Where do I store my cached files and how to name them?
-Checking modifications, I did this using getResource().getFile().
But if it's in a jar, you'll need to check that first.  (I saw a
thread about checking if the xml files changed somewhere too, I
recall it would be difficult because of jars)

On the other hand, startup time is mostly annoying to developers.
When creating a webapp, I use an exploded war structure, so all
resources are files. This way I can cheat a bit. And you can always
fall back to loading the xml file if you can't get a save way to tlel
if a file is modified.


Also, in sessionfactoryimp, you can check for if (usrs || batchSize != 0) To prevent the DB connection in the constructor.


Maybe I'll try to use sax for reading the xmls next week.




O.T. Oh, I was thinking about storing configuration in a database. That
way you would only need to set the jdbc connection, and a bootstrap
query/table or whatever to return the configuration. When
developing/testing for multiple databases, you don't need to
swap/edit xmls.
I did this for a properties file I used to use for server
configurations, but now I just have a simple table ServerConfig
(property/servername/value).



Let me know what you think about it.










__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover



-- Gavin King +61 410534454

Hibernate
[EMAIL PROTECTED]
http://hibernate.org

JBoss Inc
[EMAIL PROTECTED]
http://jboss.com



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to