[.net] Very sad IL optimization. Am I missing something?
Indeed, the JIT probably isn't optimizing at all. When running a debug session (even when it's a release build) the JIT will turn off (most, if not all) optimisations so that the code is A) readable and B) can be related back to the original source in a meaningful way. I have heard of there being away to force optimizations, but I can't for the life of me remember what it is.
Have you tried ngen.exe yet?
MSIL code can be compiled in two ways:
- On the fly (JIT) when the application is executed, meaning the compiler needs to be quick for the program to appear on the screen without delay.
- Manually using the "native image generator" which you can find as C:\Windows\Microsoft.NET\Framework\v2.0.50272\ngen.exe. This compiler will compile the MSIL code to machine code and it *should* perform all the optimization you're expecting from a good C++ compiler.
-Markus-
MSIL code can be compiled in two ways:
- On the fly (JIT) when the application is executed, meaning the compiler needs to be quick for the program to appear on the screen without delay.
- Manually using the "native image generator" which you can find as C:\Windows\Microsoft.NET\Framework\v2.0.50272\ngen.exe. This compiler will compile the MSIL code to machine code and it *should* perform all the optimization you're expecting from a good C++ compiler.
-Markus-
From http://msdn2.microsoft.com/en-us/library/ms241594.aspx:
This guy has some good stuff about the JIT: http://blogs.msdn.com/davidnotario/default.aspx
When you debug a managed application, Visual Studio suppresses optimization of just-in-time (JIT) code by default. Suppressing JIT optimization means you are debugging non-optimized code. The code runs a bit slower because it is not optimized, but your debugging experience is much more thorough. Debugging optimized code is harder and recommended only if you encounter a bug that occurs in optimized code but cannot be reproduced in the non-optimized version.
JIT optimization is controlled in Visual Studio by the Suppress JIT optimization on module load option. You can find this option on the General page under the Debugging node in the Options dialog box.
This guy has some good stuff about the JIT: http://blogs.msdn.com/davidnotario/default.aspx
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement