Print

The .NET 3.5 SP1 JIT changed for worse

The .NET JIT compiler has changed with the new SP1 release of the .NET 3.5 framework. Microsoft claims it's faster. I claim the opposite!

This weekend I've been running a serious performance comparison between the .NET framework 3.5 (runtime 2.0.50727.1433) and the -just released- .NET framework 3.5 SP1 (runtime 2.0.50727.3053). Reason to run these tests was Microsoft's promise to do some performance optimizations on the JIT compiler concerning the inlining of methods containing value types and to see whether I should change the design of CuttingEdge.Conditions library because of this.

I have to admit it: The new runtime does indeed inline methods that contain value types. However, were the good old 2.0.50727.1433 runtime inlined methods up to 32 bytes of IL (and sometimes even more), the tests I ran indicate that the fresh 2.0.50727.3053 only inlines methods up to 16 bytes of IL! Therefore, while the old runtime made it possible to inline methods with still some complexity, the new runtime practically limits inlining to simple getter and setter properties.

I actually don't really see where lowering the number of inlinable methods would actually help improve performance. Yes, I can understand this will help speeding up the JITting process, but who cares about this? I actually care about the performance of my CuttingEdge.Conditions library. I did my very best to optimize as much methods as I could in such a way that they would get inlined by the JIT compiler. In my local code base I've got 158 methods out of 193 that consist of 32 bytes of IL or less, but only 12 methods consist of 16 bytes or less. I hope you can see the performance implication this has on my library, and on .NET code in general!

For those of you who doubt my observations, please run this code in release mode and from the command line with both 1433 and 3053 and you will confirm my observations.

I hope someone at Microsoft can explain this to me, because I don't understand it!

UPDATE 2008-08-20:
I have been heared! Vance Morrison, an architect on the .NET runtime team, has answered my rants with some great feedback. Thanks Vance!

- .NET General, C# - four comments / No trackbacks - §

The code samples on my weblog are colorized using javascript, but you disabled javascript (for my website) on your browser. If you're interested in viewing the posted code snippets in color, please enable javascript.

four comments:

Someone at Microsoft has explained it:
http://blogs.msdn.com/vancem/archive/200..
Greg D - 20 08 08 - 15:30

Note that even the inlining problem is only fixed on x86, but not on x64. See the comment I added to the feedback item:

https://connect.microsoft.com/VisualStud..
Rüdiger Klaehn - 25 09 08 - 14:02

Interesting post, but I noticed something stupid/cool. You misspelled "where" as "were" ("However, were the good old..."), but on Vance Morrison's response he misspelled "were" as "where" ("However some things where clear...")

I hope neither of you fixes this because there's some Aspergers-ish part of my brain that really likes the symmetry. (Apologies for wasting your time if you read this.)
Daniel Earwicker (URL) - 19 08 09 - 17:17

To keep the symmetry, I will not fix this typo ;-)
Steven (URL) - 19 08 09 - 17:22