Recompiling with the new version

by Michael S. Kaplan, published on 2005/05/21 20:50 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/05/21/420796.aspx


If you look at version 1.0 and 1.1 of the .NET Framework, they both have a Guid structure and a Guid.Equals() method which takes an object o and returns "true if o is a Guid that has the same value as this instance; otherwise, false."

Since every type derives from System.Object it is easy to just pass another Guid in for the second paramteter to do the comparison. But that ease comes with a price -- the Object has to be boxed (boxing in simple terms means wrapping a primitive type in a GC heap object) prior to the comparison happening, and that boxing has a performance cost.

However, starting in Whidbey Guid.Equals() has a new overloadoverride that takes a Guid. Calling with that overloadoverride will be significantly faster in your code -- and you do not even have to call it differently!

But the old code that has been compiled to use the old overloadoverride will never see the benefit; you will have to recompile to get the full benefit in your existing code base. And this is just one small example -- there are obviously many such improvements in the new version.

Now this phenomenon is a problem that people using C++ may have run across many times before, but in the relatively sheltered world of Win32 (which has a strong C compatibility bias), the ability to have overloadsoverrides with different types is a relatively unknown feature, as is the fact that the "choosing the overloadoverride with the best fit" can cause the choice to change between versions if better choices become available.

But even ignoring that, there can be new compilation optimizations involving size/speed and other changes that make the recompile a worthwhile thing to try, even beyond whatever features you add.

The cost is of course the inability to run with the older version of the library -- in the case of managed code with the older version of the .NET Framework.

If there are critical features that you need (like the custom culture or normalization features in Whidbey!) than this would be a no-brainer.

But if its just for the hidden benfits of a few overloadsoverrides, it is a much tougher call.

So you have weight the costs and benefits carefully. But it is worth doing that analysis, with each new version....


# mihailik on 23 May 2005 1:30 AM:

Michael, you use word "override" where "overload" is right one.

# Michael S. Kaplan on 23 May 2005 1:36 AM:

Whoops, you are correct. I think I will do a little edit on that one....

go to newer or older post, or back to index or month or day