ngen and profiling
Asked Answered
A

1

6

I'm trying to use NGen to see if native images of my application run better than the .NET ones. However, I'm having a little bit of trouble figuring out what to do.

My application is called MyApp.exe and it has several dependency DLLs.

I opened up the VS 2010 Command Prompt and ran:

ngen install MyApp.exe /Profile

The command output did not suggest any issues had been encountered.

I then went to C:\Windows\assembly to try and run the EXE but I couldn't find it there (I'm on Windows 7). A little bit of digging told me to use the command prompt to browse into C:\Windows\assembly\NativeImages_v4.0.30319_32. I was eventually ably to locate my MyApp.ni.exe there but of course couldn't open the containing folder in explorer.

I tried to run the program and it told me:

"C:\Windows\assembly\NativeImages_v4.0.30319_32...\MyApp.ni.exe is not a valid Win32 application."

The command output said Access is denied.

I had two questions:

  1. How can I run this program so that I can execute the native version.
  2. How would I go about profiling it? Looks like I won't be able to locate that folder from within the VS2010 profiler because it cannot be seen in explorer.

Thanks.

Antirachitic answered 24/6, 2011 at 18:17 Comment(4)
Note NGEN only replaces the JIT step - it is still a managed application etc. If you are having cold-start performance issues this might help, but in most cases NGEN won't help. It won't make your loops etc faster.Entasis
The application itself is pretty large, so I am just trying to figure out how to make it more performant. In the case that NGEN doesn't actually help, that's perfectly okay, but I just want to do my due diligence.Antirachitic
profile first (your app, now, without NGEN). Then (and only then) act. Otherwise you are wasting time that could be better spent making it faster. I honestly don't expect NGEN will help much here.Entasis
I have already profiled the application without NGEN. There are several other devs who are working on profiling the application and getting rid of other inefficient code. It doesn't matter if NGEN helps or not--part of due diligence is actually trying it to see if it does actually give any improvements.Antirachitic
A
1

Looks like I should have read a little more. Seems like I can just execute the EXE that was passed to NGEN and it should automatically load the native stuff from the cache.

One other issue is that I had to run ngen with both the /profile and /debug flags to make sure I could do both.

This is a nice tutorial on the issue:

http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx

Antirachitic answered 24/6, 2011 at 19:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.