Tail Call Improvements in .NET Framework 4

First a little background reading before going into tail call improvements in CLR 4 – David Broman did an excellent job at covering the basics in his post here: http://blogs.msdn.com/davbr/archive/2007/06/20/enter-leave-tailcall-hooks-part-2-tall-tales-of-tail-calls.aspx.  He also captured a mostly complete list of the restrictions as they stood for CLR 2 here: http://blogs.msdn.com/davbr/pages/tail-call-jit-conditions.aspx.   The primary reason for a tail…


JIT ETW tracing in .NET Framework 4

If you care about performance at a very low level, at one point you’ve asked yourself why the compiler, JIT, or runtime did or did not inline a certain method.  Unless you worked on the compiler, JIT, or runtime, you really had no way of telling, other than trial and error (sort of like asking…


Performance implications of unmanaged array accesses

I was recently shown the following code and asked why the loop calling SafeAccess executed significantly faster than the second loop calling UnsafeAccess:          static int [] intarray = new int [5000];               static void SafeAccess(int a, int b)        {            int temp = intarray[a];            intarray[a] = intarray[b];            intarray[b] =…


How to see the Assembly code generated by the JIT using Visual Studio

by Brian Sullivan     In Visual Studio you can set a breakpoint at any line in your source code.   When you run your program Visual Studio will break and stop execution when it reaches your breakpoint.  At this point you can right click on your source code and select Go To Disassembly.   You will…


Running NGen as part of installing a Microsoft Exchange patch roll up takes ~2 hours [Lakshan Fernando]

I work in the CodeGen test team and wanted to share a recent customer experience that was related to ngen. One of our Customer Service and Support (CSS) engineers in France contacted us regarding an installation delay with the latest Microsoft Exchange Server 2007 update rollup. Apparently the patch installer was spending 2 hours generating…