-
Notifications
You must be signed in to change notification settings - Fork 130
Improve startup time with the Multicore JIT
Microsoft introduced a Multicore JIT, which uses parallelization to reduce the JIT compilation time during application startup. With Multicore JIT, methods are compiled on two cores in parallel. The more code you execute on your startup path, the more effective Multicore JIT will be at reducing startup time.
In .NET 4.5.1 they improved the Multicore JIT. Now it supports dynamically loaded assemblies as well.
It records the work of the JIT every startup and saves it in a binary “profile” file. The file is quite small. It has about 30KB.
The Multicore JIT reads this file during startup and starts pre-compiling the methods in the background that were recorded in the file.
The Multicore JIT is enabled by default for ASP.NET apps and Silverlight 5 apps. In a desktop application it needs to be enabled via the ProfileOptimization class. This is necessary so that we can tell the CLR where to save the profile file.
var profileRoot = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData),
ApplicationInfo.ProductName, "ProfileOptimization");
Directory.CreateDirectory(profileRoot);
// Define the folder where to save the profile files
ProfileOptimization.SetProfileRoot(profileRoot);
// Start profiling and save it in Startup.profile
ProfileOptimization.StartProfile("Startup.profile");
It is common to use NGEN within the installation for .NET desktop applications. As a result the JIT has not much to do anymore because the assemblies are already pre-compiled. Using the Multicore JIT might still be useful because during development it can reduce the startup time as well.
- MSDN Blog: An easy solution for improving app launch performance
- MSDN Blog: Announcing the .NET Framework 4.5.1 Preview (see chapter: Multi-core JIT improvements)
- Ngen.exe (Native Image Generator)