Particular / NServiceBus

Build, version, and monitor better microservices with the most powerful service platform for .NET
https://particular.net/nservicebus/
Other
2.08k stars 647 forks source link

Scheduler setup causes message conventions to be evaluated multiple times #4107

Open DavidBoike opened 8 years ago

DavidBoike commented 8 years ago

When an endpoint starts up, the message conventions are applied to all types.

Then the Scheduler feature comes along and adds system message conventions in its setup:

context.Settings.Get<Conventions>().AddSystemMessagesConventions(t => typeof(ScheduledTask).IsAssignableFrom(t));

If you follow that method, it calls MessagesConventionCache.Reset();

So now that work is out the window, and (for example) the IsCommand delegate will get called twice more for the same message class, once as part of Conventions.IsMessageType and then as part of Conventions.IsCommandType(t).

Surely we could make this more efficient and shave off a good chunk of startup time for users with lots of included assemblies?

(But not a must-have for RC)

andreasohlund commented 8 years ago

Surely we could make this more efficient and shave off a good chunk of startup time

Do we have any times?

Should we profile the startup to see where we spend the most time currently?

danielmarbach commented 7 years ago

I created an endpoint with 6 message assemblies and a total of roughly 130 messages. image

Right now the convention scanning is almost not relevant in comparison to assembly scanning which takes up over 50 % of the endpoint configuration build time