0% found this document useful (0 votes)
61 views2 pages

Reducing The Application Launch Time

The document discusses two methods for reducing application launch time in .NET applications: 1. Using the Native Image Generator (Ngen.exe) tool to compile assemblies' IL code into native code ahead of time, avoiding the need for just-in-time compilation at runtime. 2. Enabling multicore JIT starting in .NET Framework 4.5, which uses parallelization to reduce the time needed for JIT compilation during application startup. This involves profiling methods on the first launch and using that profile to compile methods in parallel on subsequent launches.

Uploaded by

bato cera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

Reducing The Application Launch Time

The document discusses two methods for reducing application launch time in .NET applications: 1. Using the Native Image Generator (Ngen.exe) tool to compile assemblies' IL code into native code ahead of time, avoiding the need for just-in-time compilation at runtime. 2. Enabling multicore JIT starting in .NET Framework 4.5, which uses parallelization to reduce the time needed for JIT compilation during application startup. This involves profiling methods on the first launch and using that profile to compile methods in parallel on subsequent launches.

Uploaded by

bato cera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Reducing the

Application Launch Time


 Jun 07, 2019

 3 minutes to read

When you build a .NET application, it is compiled into Microsoft Intermediate


Language (MSIL). When a user launches the application, its MSIL code is
compiled into machine code by the “just in time” (JIT) compiler. This process can
cause noticeable delays. External DLLs (e.g. the DevExpress ones) may be loaded
in addition to your own application, which means that any delay does not depend
on the size of your code alone.

This topic describes how to reduce the WPF application startup time if you have
noticeable delays in your application due to the JIT compilation.

#Compile IL code into native code


Use the Native Image Generator (Ngen.exe) tool to compile assemblies’ IL
code into native code. When an end-user runs your application, CLR loads the
precompiled code from the native image cache, so that no compilation is
required at runtime. The Ngen.exe tool ships with the .NET Framework SDK.

You can compile your application's (and its dependencies) IL code into native
code like follows:

 x64

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install
C:\MyApp.exe

Run Ngen.exe after your application's deployment.


NOTE
NGen.exe produces code that is not as highly optimized as the JIT compiler–
produced code.

Use MultiCore JIT


Starting with the .NET Framework 4.5, you can use
the System.Runtime.ProfileOptimization class to enable Multicore JIT. Multicore
JIT uses parallelization to reduce the JIT compilation time during application
startup.

NOTE
Using the MultiCore JIT is not as effective as compiling IL code into native code.

The code sample below demonstrates how to enable Multicore JIT in your
application.

 C#
 VB.NET

public App()
{
// Defines where to store JIT profiles
ProfileOptimization.SetProfileRoot(@"C:\MyAppFolder");
// Enables Multicore JIT with the specified profile
ProfileOptimization.StartProfile("Startup.Profile");
}

The first time the application starts, the JIT compiler records every method it
should compile. The CLR then saves a profile of the methods that were executed.
The ProfileOptimization.SetProfileRoot method specifies an existing folder where
the profiles are saved. Multicore JIT is not applied at this moment.

The second time the application runs, the ProfileOptimization.StartProfile method


loads the specified profile from disk and uses this information to compile
methods in the background before they are called from the main thread.

You might also like