1

I am curious whether it is possible to determine how/whether adaptive optimization is being in a C# application. Any pointers will be appreciated

paseena
  • 4,207
  • 6
  • 32
  • 51

2 Answers2

2

There is no adaptive optimization in currently shipping .NET jitter versions from Microsoft. Once the machine code is generated it doesn't get altered anymore. Nor is there a sub-system that monitors code execution to provide profiling data that a 'hot-spot' optimizer could use.

You'll find an overview of jitter optimizations in this answer.

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • i have a confusion after I read this : http://en.wikipedia.org/wiki/Just-in-time_compilation. It says that it is not advisable to use Ngen because the quality of code is not good in comparision to JITed. Does it mean that .NET JIT compiler inserts adaptive optimization? – paseena Mar 20 '11 at 22:43
1

You can look at the x86 disassembly that happens at runtime with Visual Studio to see what's happened.

Deciphering it might be tough, though, since it's bytecode that's getting translated and not source code.

user541686
  • 205,094
  • 128
  • 528
  • 886
  • Yeah I meant MSIL -- I just said "binary" in the sense that it's a "binary" (i.e. an executable format) and not source code (text files). But yes, it's bytecode and not machine instructions; just changed that, thanks. – user541686 Mar 19 '11 at 00:33
  • thanks for your reply. do you mean i should look at MSIL code emitted by compiling done by the C# compiler? – paseena Mar 19 '11 at 00:41
  • @quantcoder: No -- the MSIL code is the *input* to the JIT compiler, *not* the optimized output. You need to actually look at the native disassembly: in Visual Studio, while running the program, go to the Debug menu->Windows->Disassembly. You might need to brush up on some x86 assembly before you do, though, since it's not easy to decipher. – user541686 Mar 19 '11 at 00:44
  • thanks for your reply. unfortunately, i do not have visual C# professional and so i cannot see the disassembly window. is there some other alternative? – paseena Mar 20 '11 at 22:48
  • @quantcoder: Yes; you can also use the [Debugging Tools for Windows](http://msdn.microsoft.com/en-us/windows/hardware/gg463016). However, you might have to download the Windows SDK too, so it might be a large download. – user541686 Mar 20 '11 at 22:58