Unity interception performance

Oct 13, 2009 at 1:31 PM


I'm working on a rather large web site project with Unity at the foundation of most of the platform. We had a lot of trouble getting it to perform fast enough for our needs.

The problem seems to be that every time I do a BuildUp, all interceptable methods are checked against all matching rules for all call handlers. Since we don't add/change any call handlers during runtime (we do this in web.config) that seemed unnecessary. I couldn't find a better way of fixing this other than actually adding some caching to the InterceptionStrategies and compiling our own version of Unity.

I've described the scenario and my rather crude solution in this blog post.

Is there a better way? If not, will there be a better way in Unity 2.0?


Anders Ljusberg

Feb 2, 2010 at 1:58 AM

Perf work is ongoing. Will try to address in v2.0.



Feb 2, 2010 at 5:53 AM

I did an experiment to cache the call handler/policy lookup stuff so the logic isn't repeated every time. It ended up being slower than just calculating every time. Not promising.


Feb 2, 2010 at 10:17 AM

Thanks for the answers. My guess is that my rather crude solution to this problem only is worthwhile in some cases. Maybe this could be configurable/pluggable in some way?



Feb 2, 2010 at 8:49 PM

We will certainly be looking at interception perf pretty hard over the next month or two. I can't promise anything other than that it's definitely on our radar and we do want to improve it.