Hi
We have several solutions, sharing projects, each solution consisting of about 6000 classes (some private, some shared).
The assembly scanning and registering is fine, but the Build method takes up a lot of time.
We then did a profiling of autofac, and found that this method this the culprit, especially the ToArray() part, which then goes further down to ServiceRegistrationInfo, which then checks for the IsInitialized field.

The profiling is attached (don't complain about the Update, the Build has the same problem, and I did not write that :))
void UpdateInitialisedAdapters(IComponentRegistration registration)
{
var adapterServices = _serviceInfo
.Where(si => si.Value.ShouldRecalculateAdaptersOn(registration))
.Select(si => si.Key)
.ToArray();
if (adapterServices.Length == 0)
return;
Debug.WriteLine(String.Format(CultureInfo.InvariantCulture,
"[Autofac] Component '{0}' provides services that have already been adapted. Consider refactoring to ContainerBuilder.Build() rather than Update().",
registration));
var adaptationSandbox = new AdaptationSandbox(
_dynamicRegistrationSources.Where(rs => rs.IsAdapterForIndividualComponents),
registration,
adapterServices);
var adapters = adaptationSandbox.GetAdapters();
foreach (var adapter in adapters)
AddRegistration(adapter, true);
}
For fun, we removed this method call (we just returned as the first line), and all our tests passed, and the program functions as excepted.
Now:
We have a lot of tests, and a lot of them are written by creating their own servicelocator, so this adds up to a lot if time (about 2 seconds per test), we can shave off over 30 minutes of our testing.
In addtion the startup of the of the application is improved by 2 seconds, which is quite a lot.
The isolated improvement is from 2 seconds to 0,1 seconds in the containerbuild.
So my question is:
What scenarios is this needed for? And could we optimize this call to either be fast or parameter driven? These seconds and minutes means a lot to our project.