An NGEN'd assembly will not run faster except at start up (code is only JIT'd once per program executing).
However, in 1.1 NGEN code *may* run slower as the runtime has to load both the native version and the IL version as the IL version contains the metadata the runtime needs to provide alot of the services it does. Because of the impact on working set, the program may, therefore have more paging taking place and so run slower. In addition, NGEN'd assemblies are "fragile" in that if any dependency changes the runtime must assume that any inlined methods may now be invalid and so reverts back to JITing.
However, Windows likes to share code images across processes which it cannot do with JIT'd code so NGEN can give an advantage there - but this depends on you NGENing an image that is used by alot of processes.
Version 2.0 puts the metadata in the native image to resolve the double load issue and has a background process that re-NGENs native assemblies that have been "broken" by dependency changes. So under version 2.0 NGEN is much morfe compelling. However, as with all performance optimizations make sure you test that it has helped before you go into production with it.
NGEN can help speed up start up time but won't necessarily.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Hi,
There is no evidence that JIT causes problems, but it is a theoretical
assumption that if we run a native executable, it would run faster.
Are there any problems with using NGEN.exe?
Thanks,
Ravi.
Are there any