views:

44

answers:

1

For every application_start, I call ActiveRecordStarter.Initialize (actually it's part of the ActiveRecordIntegration facitliy). This seems to be very heavy, takeing around 3.5 seconds to initialize my 16 objects.

some background: 1. got 16 AR objects for now, almost never changed (maybe once a week). 2. most of the changes are not AR related, still I'm "suffering" from the huge application startup time when developing locally (need to wait 3.4sec to AR to load, although nothing really changed there).

My thoughts: it seems that if I'll persist the configuration of AR into binary file and load it, if noting changed (for example, by looking at the AR objects and doing some MD5 on their source files to see changes). If something was changed, I need to re-create the binary file. From testing I've done, it looks like most of the time is from there.

So: a. am I going in the right direction there? maybe I'm doing something wrong? b. did you fix it already and care to share it with me? :)

A: 

You're correct, the NHibernate session factory can take some time to build, and serializing it to a file is a good way to improve that.

For an implementation of this, take a look at this article and the corresponding code in the Castle NHibernate facility.

Mauricio Scheffer
As always, thanks you Mauricio!I'm not sure where can I add this. Do I need to change ActiveRecrodStarter internals? can you direct me to the relevant place, I'm not that familiar with AR internals (at least until now :))
Oren Ellenbogen
@Oren: I'd try implementing this through a custom ISessionFactoryHolder (see xml reference docs for how to inject your own: http://www.castleproject.org/activerecord/documentation/trunk/manual/xmlconfigref.html )
Mauricio Scheffer
it seems to be a bit out of my scope, ActiveRecordStarter is one BIG monster (with many internals), making it very hard for me to understand what to tweak there. do you think that such request (integrating optimized NH configuration in AR starter) can be published to the user group?
Oren Ellenbogen
@Oren: yeah, it seems that a custom ISessionFactoryHolder won't cut it in this case, you'll have to refactor ActiveRecordStarter. Please add this to the tracker (http://issues.castleproject.org/dashboard) and try to implement it... as I like to say "open source is the ultimate do-it-yourself" ;-)
Mauricio Scheffer