Saturday, October 13, 2007

"I was told that CAB performance stinks"

I wish I had a nickel every time someone wrote to tell me:
I was told that there is a definite performance hit to using X.

It is absolutely true of course! There is no technology with zero performance impact. So if I told you "the performance is absolutely acceptable" would you believe me?

I hope not! For that response is every bit as unqualified as the accusation.

We really have to understand the application and the environment in which it runs before we can speculate about the probable performance effects of CAB (or anything else). We have to measure the performance before we know for sure.

That's not terribly helpful if you're standing on the cusp of a major architectural decision. You want to know "will CAB sink my application and my career along with it?"

Permit me to rephrase the question: "In general, are WinForm applications written in CAB perceived to perform poorly relative to WinForm applications written in raw .NET ?"

The short answer is "no". I haven't formally benchmarked the two kinds of applications but I have eyeballed the differences with my wrist watch and I can't tell the difference. We have a number of customers writing CAB-based applications (with .NET, Developer Express, and Infragistics control suites) and they do not report performance problems traceable to CAB.

With performance, like the proverbial tree in the forest, if no one sees it fall ... it did not fall.

Developers do report performance problems of course and CAB is oft times suspected. But further investigation typically reveals that the culprit was loading too many complex controls at once or wasteful loops or unfortunate choices in database access or some other of the usual suspects.

I'll bet there are ways to abuse CAB and deliver a dog of an app. It is true that CAB makes extensive use of reflection and there are some opportunities for improvement (e.g., caching previously analyzed type information).

The CAB in your application should be operating at coarse-grained levels such as the initialization of long-lived objects (like views and presenters); these are not the hot-spots where reflection kills you.

I would be grateful for any references to articles or blogs where bad CAB performance is discussed. As I said, I often hear the charge but have yet to see the evidence.

No comments: