[.net] Very sad IL optimization. Am I missing something?

Started by
11 comments, last by Arild Fines 17 years, 10 months ago
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.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
Advertisement
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-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
From http://msdn2.microsoft.com/en-us/library/ms241594.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
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement