Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to reduce JIT time during initial start of Windows Store apps


View products that this article applies to.

Summary

When a user installs a Windows Store app that is written in Microsoft Visual C# or in Microsoft Visual Basic, there are no native images for the app. Instead, the just-in-time (JIT) compiler runs during app startup. If there is a large volume of code in the startup path, users may experience slower-than-expected performance when they start the app. However, you can reduce the impact of JIT compilation when the Windows Store app starts by using the multi-core JIT compilation feature.

↑ Back to the top


More information

Native images are automatically generated for all Windows Store apps that are written in Visual C# or in Visual Basic. This occurs as a background task. After the native images are generated, JIT compilation is no longer required for most methods, and your app benefits from improved startup performance. Native images are typically generated within 24 hours of installation, although it may take longer, depending on the way the computer is used. Until that time, startup performance may be affected by JIT compilation time. For more information, go to the following Microsoft websites:�If an app executes a large volume of code during startup, the time that is required by the JIT compiler may be noticeable to users. On multi-core computers, you can frequently reduce this time by 20 to 50 percent by using the multi-core JIT feature. To use multi-core JIT for Windows Store apps, follow these steps:
  1. Generate a profile of the code that is executed during app startup.
  2. Deploy the profile as part of the app.

At startup, the profile data is used to predict which methods will be needed so that they can be compiled beforehand on a separate core.

You must generate the profile by using the same version of the app that you plan to package the profile with, because any code changes can invalidate the profile. An invalid profile typically makes startup performance worse.

Note�This feature resembles the multi-core JIT feature for desktop apps. For desktop apps you can turn on multi-core JIT for individual application domains by using the�ProfileOptimization class (http://go.microsoft.com/fwlink/p/?LinkId=253476). This class is not available for Windows Store apps.

Generating and packaging profiles

The common language runtime (CLR) uses a file-based trigger to determine whether to generate multi-core JIT profile data for a�Windows Store�app. To generate a profile, follow these steps:

  1. Create a 0-byte trigger file that is named [StartupExe]_[AppId].profile.�

    Notes
    • [StartupExe]�is your app�s executable file name, without the .exe extension. For example, if your app�s executable is named �MyApplication.exe," use �MyApplication.� For WWA apps, use �WWAHost.�
    • [AppId]�is the identifier that is associated with the app entry point in the package manifest (Package.appxmanifest). For most apps, this will be �App,� but for apps that have multiple entry points, this may differ.
  2. Put the trigger file into the root folder of the Visual Studio project for your main executable, and set�Build Action to Content in the file properties.
  3. Deploy your app by selecting Deploy Solution�on the�Build menu in Visual Studio.
  4. Start your app from the start screen.

    Notes
    • It's important to start your app without using a debugger, because that can add unnecessary code paths to the profile.
    • You must run the app on a multi-core computer. Otherwise the profile will not be generated.
  5. After the app runs for 10 seconds, a profile is generated in C:\Users\[UserName]\AppData\Local\Packages\[PackageName]\AC. This profile will have the same name as the trigger file from step 1.
  6. Replace the trigger file in your Visual Studio project with the profile that is generated in step 5, and then create the final app package.

Important�If you make any code changes to your app, you must re-generate the profile.





↑ Back to the top


Article Info
Article ID : 2715214
Revision : 6
Created on : 5/15/2013
Published on : 5/15/2013
Exists online : False
Views : 451