31

.NET Core 2.1 Previews Tiered Compilation

 5 years ago
source link: https://www.tuicool.com/articles/hit/2uIRFrr
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The JIT compiling process used by .NET has always had to balance two competing objectives – faster application startup time versus faster application steady-state performance.  From the end-user perspective, perception of an application's startup speed can be negatively impacted if the JIT pauses at launch to calculate the best steady-state performance.  On the other hand, if the JIT favors faster application start time, then the application's steady-state performance will be sub-optimal.

In an effort to resolve this conflict, Microsoft's Noah Falk has announced the availability of tiered compilation for .NET Core 2.1.  This lets the JIT do multiple compilations and produce code that can then be hotswapped at runtime for the best overall performance impact.  The end result is an application starts fast and still has great steady-state performance.  

Since this feature is still in a preview state it is not activated by default, but there a couple of ways to activate it for any .NET Core 2.1 application.  For applications that you are able to compile, simply add the MSBuild property <TieredCompilation>true</TieredCompilation> to your project's default property group.

If you are running a previously compiled application for which you do not have the source, you can set a new property in runtimeconfig.json file in the configProperties section:  System.Runtime.TieredCompilation=true

Finally the environmental variable COMPlus_TieredCompilation=1 can be used to enable tiered compilation without modifying any files.

It should be noted that at present this remains a feature specific to .NET Core, and is not slated for deployment on the .NET Framework.  Developers interested in experimenting with this new technology can also compares results viewing the JitBench project Microsoft has setup on GitHub.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK