Inlining of value types

Great news is coming from the .NET Runtime Team. The new coming service pack for the .NET framework addresses inlining of value types.

Last couple of days I've been commenting on Fredrik Normén's blog (here and here) and Roger Alsing's blog (here) about some possible performance improvements of their code samples. I've discussed the use of value types (structs) instead of reference types (classes), but when testing my proposed improvements, the use of value types didn't give me the performance improvement I was hoping for. In fact I encountered a performance drop! This was probably caused by the CLR's lack of inlining of value types.

I just read some great news about the coming Service Pack of the .NET framework on Vance Morrison's Weblog. The coming release will address these performance issues. Vance Morrison is a performance architect on the .NET Runtime Team and in this article he describes the following about the inlining of value types:

C# structs are what the .NET runtime calls value types. They are called this because when you have fields or arrays of such data structures, the value is embedded directly in the field (not referenced through a pointer). All the primitive types (int, char, bool) are value types, as well as a few types defined in the base class library like DateTime, Decimal, Point and Rectangle. The previous version of the code generator (for X86) did almost no optimization on value types. This was unfortunate, because although value types are not common (most types are classes, not structs), when they are used, they can be used heavily, and so optimization is important. In fact the biggest single piece of feedback we got on our feedback site related to performance was concerning more aggressive inlining of value type methods. The runtime’s 64 bit code generators could already optimize value types, but the code generator for X86 could not. Since X86 is still the dominate platform there was an unmet need. In this servicing we included the work we did to enable this for X86. Your own code often may not benefit from this improvement (because it does not use value classes much), but if you do use them, you tend to use them heavily, and the value could be substantial. ->

A beta of the new Service Pack 1 shipped two days ago and Microsoft planned to ship the final release of .NET 3.5 SP1 this summer. I think this is great news and I’m very exited about it!

- .NET General - No 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.

No comments:

No trackbacks:

Trackback link:

Please enable javascript to generate a trackback url

Remember personal info?


Before sending a comment, you have to answer correctly a simple question everyone knows the answer to. This completely baffles automated spam bots.

  (Register your username / Log in)

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.