A few thoughts... not very thoroughly investigated yet:
One call to AddAssembly() with 12 embedded hbm files, results in 12
calls to NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping,
String), unsurprisingly. This method contains the following line:
Dialect.Dialect dialect = Dialect.Dialect.GetDialect(properties);
GetDialect() eventually instantiates the dialect... i.e. when adding
one assembly to the mapping configuration, the dialect is instantiated
once for each embedded hbm-file. Since instantiating the dialect
involves various string and regular expression manipulation, this
isn't very cheap. (When running under the profiler, AddAssembly()
takes 7068ms, of which 1292ms are the 12 calls to GetDialect(), i.e.
18%. Might it be worth investigating if these multiple instantiations
can be avoided?
Also, some amount of time seems to be spent compiling regular
expressions. These are static expressions. Have anyone had a look at
precompiling them to a separate assembly, to avoid doing it on every
startup?
http://msdn.microsoft.com/en-us/library/9ek5zak6.aspx
/Oskar