I'm trying to troubleshoot some startup time concerns. After doing some profiling, I've found the main culprit is ClassProxyGenerator.GenerateCode. This takes 400-600ms per type the first time. So if the entry point to the application has 8 dependencies (in a chain) which need proxies generated, the startup time of the application goes up by 4.8 seconds. This might not seem like a lot, but to a user, it seems like ages.
Any advice for improving this?
Update:
I can reproduce the time with the following console application:
var container = new WindsorContainer();
container.Register(Component.For<Interceptor>()); // dummy IInterceptor...does nothing
container.Register(Component.For<IMyRepository, MyAbstractRepository>().Interceptors<Interceptor>());
var t = DateTime.Now;
var instance = container.Resolve<IMyRepository>();
Debug.WriteLine("Resolved in " + (DateTime.Now - t).TotalMilliseconds);
Outputs somewhere between 550ms and 750ms.
IMyRepository is a repository interface for 30 entity types (generated by a T4 template). It has 31 IQueryables, 31 Save overloads, and 31 Delete overloads. MyAbstractRepository is a partial abstract class. It declares the same 3 x 31 methods.
If I remove all the save and delete methods and leave just the 31 IQueryables AND don't register the abstract repository
container.Register(Component.For<IMyRepository>().Interceptors<Interceptor>());
I still run around 250ms for the initial generation.
This is a very (very very) fast machine...so anything in the real world will likely perform slower than the numbers listed above.