Catel or WPF performance

Topics: Issues / bugs
Sep 14, 2012 at 3:28 PM


I now using Catel for multiple projects - in fact all my WPF projects. All my applications feel very slow, especially on startup. E.g. my current projects takes about 8 seconds to start and it does not do a lot.

I'm still no export on WPF in general, so...

Is this normal WPF behavior or could this be an Catel issue or am I simply doing something completely wrong? Or to state the question differently, how do I know which part is the part that slows starting down so much?

Thanks for any insights,


Sep 14, 2012 at 3:59 PM

Catel uses reflection a lot. To make sure it performs when the app is running, the startup can be pretty slow because all types and assemblies are cached. This way, during the application execution the application will perform very fast. Best is to use a splash screen for this. For example, take a look at Orchestra. It uses Catel, Prism, AvalonDock and pre-loads everything using a splash screen. Once it is loaded, it's fast.

Also, take a look at the performance considerations.

You might also want to try a performance profiler, it will show you exactly where the problem is (to the code line exactly). We have very good experience with ANTS performance profiler.

If you have profiler results and feel that Catel is slow on a specific part, let us know and we will take a look at it.

Sep 15, 2012 at 4:33 PM

Hi Geert,

I am also in doubt if this performance issue will impair the user experience on startup of my application.
Until now, the size (in count of views and VMs) is low, and startup time is some seconds.
Because there will be a great number of views in the complete application,
I hope the startup time will not raise proportional to the count of them...

The application consists of some nearly independent parts. Call it modules.
Usually a user will only use a few of them.
If this reflection thing it the core of the problem, would it be possible to put Catel into a semi-manual mode for doing this?
I think about a static method called with a list of assemblies to be analyzed.
So I could provide Catel just these assemblies used by the currently needed module.
Catel could be smart enough detecting repetitive calls with the same assemblies, ignoring them...

How do you think about this?


Sep 17, 2012 at 8:56 PM

No, the startup time will not increase. I have been thinking about adding an ignore filter to Catel to make sure that it does not initialize all types at once. Or maybe a background process that initializes the types, but this might make it all much more complex.

Reflection is done once for the main module. Then all is cached and all reflection is extremely fast (that's why we started caching in the first place). If a module is lazy loaded, and you try to load a type, Catel will automatically initialize it (if not yet initialized). Thus, it caches reflection in a lazy-loaded way for unloaded modules.

So, Catel is already smart not to re-register existing assemblies. Do you mind sending me a copy of your app so far (can be private). Then I can analyze it with a performance profiler to pinpoint the issue and think of a solution.

Sep 17, 2012 at 10:24 PM

What is Catel ServiceLocator performance comparing to these IoCs:

Sep 18, 2012 at 4:51 PM

I forked the test code and added catel. Hopefully we will be in the list soon.

Sep 19, 2012 at 9:48 AM

The ResolveType performance for not Singletons is not exciting ;-)

Sep 19, 2012 at 7:02 PM

I was able to pinpoint the issue. Well, issue, it were 2 things:

1) Logging (if you execute something 100.000 times, then even logging will have impact on the performance. I have removed some logging, but we think that logging can be of great help in case of crashes, issues or unexpected behavior. Therefore, we don't want to remove all logging because that would break one of the good things of Catel, and that is that everything is very easily traceable.

2) Instead of Activator.CreateInstance we now use the constructor to inject the code, the performance is now good

Can we improve the performance even more?

Yes, this should be possible. However, this would cost a huge amount of time and can be complex (for example, cache constructors and invalidate the constructor cache in case a new type is added / resolved). We don't see any high priority to implement this, but you are always free to help out ;-)

Sep 19, 2012 at 8:57 PM

Ok, easier than I expected. I implemented constructor caching, Catel is now a pretty fast in the list when I run it on my dev machine. They will probably update when we release 3.4.

Sep 20, 2012 at 11:23 AM

Your development speed is exciting, thanks.

Sep 24, 2012 at 10:02 AM

I will update the comparison as soon as version 3.4 is released.