Have you ever used ngen.exe?

Hannoun Yassir picture Hannoun Yassir · Apr 4, 2009 · Viewed 18.3k times · Source

Has anybody here ever used ngen? Where? why? Was there any performance improvement? when and where does it make sense to use it?

Answer

Marc Gravell picture Marc Gravell · Apr 4, 2009

I don't use it day-to-day, but it is used by tools that want to boost performance; for example, Paint.NET uses NGEN during the installer (or maybe first use). It is possible (although I don't know for sure) that some of the MS tools do, too.

Basically, NGEN performs much of the JIT for an assembly up front, so that there is very little delay on a cold start. Of course, in most typical usage, not 100% of the code is ever reached, so in some ways this does a lot of unnecessary work - but it can't tell that ahead of time.

The downside, IMO, is that you need to use the GAC to use NGEN; I try to avoid the GAC as much as possible, so that I can use robocopy-deployment (to servers) and ClickOnce (to clients).