Native Image Generator in Microsoft dot net

The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly'sMSIL and generate native machine code which is cached to disk.

After the image is created .NETruntime will use the image to run the code rather than from the hard disk. Running Ngen.exe onan assembly potentially allows the assembly to load and execute faster, because it restores codeand data structures from the native image cache rather than generating them dynamically.

Below are some points to be remembered for Native Image Generator:-

√Native images load faster than MSIL because JIT compilation and type-safety verificationis eliminated.

√If you are sharing code between process Ngen.exe improves the performancesignificantly. As Native image generated Windows PE file so a single DLL file can beshared across applications. By contrast JIT produced code are private to an assemblyand can not be shared.

√Native images enable code sharing between processes.√Native images require more storage space and more time to generate.

√Startup time performance improves lot. We can get considerable gains when applicationsshare component assemblies because after the first application has been started theshared components are already loaded for subsequent applications. If assemblies inan application must be loaded from the hard disk, does not benefit as much fromnative images because the hard disk access time shadows everything.

Assemblies in GAC do not benefit from Native image generator as the loader performsextra validation on the strong named assemblies thus shadowing the benefits of NativeImage Generator.

If any of the assemblies change then Native image should also be updated.

You should have administrative privilege for running Ngen.exe.

While this can fasten your application startup times as the code is statically compiledbut it can be somewhat slower than the code generated dynamically by the JIT compiler.So you need to compare how the whole application performance with Ngen.exe andwith out it.

To run Ngen.exe, use the following command line.ngen.exe install This will synchronously precompile the specified assembly and all of its dependencies.

The generatednative images are stored in the native image cache.In .NET Framework 2.0 there is a service (.NET Runtime Optimization Service) which canprecompile managed assemblies in the background.

You can schedule your assemblies to beprecompiled asynchronously by queueing them up with the NGEN Service. Use the followingcommand line. ngen.exe install /queue:Assemblies which are critical to your application's start up time should either be precompiledsynchronously or asynchronously with priority 1. Priority 1 and 2 assemblies are precompiledaggressively while Priority 3 assemblies are only precompiled during machine idle-time.

Synchronously precompiling your critical assemblies guarantees that the native images will beavailable prior to the first time your end user launches the application but increases the time takento run your application's set up program.

You can uninstall an assembly and its dependencies (if no other assemblies are dependent onthem) from the native image cache by running the following command. ngen.exe uninstall Native images created using Ngen.exe cannot be deployed; instead they need to be created on theend user's machine. These commands therefore need to be issued as part of the application'ssetup program. Visual Studio .NET can be used to implement this behavior by defining customactions in a Microsoft Installer (MSI) package.

54
RELATED POST


ERROR CHECK LIST FOR INSPECTIONS

WALK THROUGHS IN TESTING

TESTING FOR SPECIALIZED ENVIRONMENTS PART ONE

TESTING FOR SPECIALIZED ENVIRONMENTS PART TWO

VALIDATION TESTING

SYSTEM TESTING


DEBUGGING AND TESTING

DEFECT AMPLIFICATION AND REMOVAL

ITERATIVE SPIRAL MODEL

STANDARD WATER MODEL

CONFIGURATION MANAGEMENT


CONTROLLED TESTING ENVIRONMENT

RISK ANALYSIS PART ONE


RISK ANALYSIS PART TWO

BACK GROUND ISSUES

SOFTWARE REVIEWS PART ONE

SOFTWARE REVIEWS PART TWO

SOFTWARE RELIABILITY

SAFETY ASPECTS

MISTAKE PROOFING

SCRIPT ENVIRONMENT

V MODEL IN TESTING

No comments:

Post a Comment