Friday, October 26, 2012

Improve your application performance by doing nothing(or almost)

One of the optimizations you get for free in the new .NET Framework 4.5 release is Multicore JIT compilation.  Today, the assumption is that you have at least two processors. This feature takes advantage of this extra processing power by using parallelization to reduce the JIT compilation time during application startup.
If you want to get all the details, check the following post
Enable Multicore JIT for your ASP.NET web applications
For your ASP.NET web applications it’s easy, you have to do nothing. Once your application/webserver is upgraded to ASP.NET 4.5, your application start up will go faster. Microsoft took into consideration that ASP.NET applications runs in a hosted environment, so they turned on Multicore JIT for these applications automatically. So if you're running ASP.NET 4.5, you don't have to do any extra work to turn on Multicore JIT.
If you want to turn Multicore JIT off in your ASP.NET 4.5 applications, use the new profileGuidedOptimizations flag in the web.config file as follows:
<?xml version="1.0" encoding="utf-8" ?> 
 <!-- ... --> 
  <compilation profileGuidedOptimizations="None" />  
  <!-- ... -->  

Enable Multicore JIT for your Windows client applications
In a Windows client application, all you need to do is use the System.Runtime.ProfileOptimization class to start profiling at the entry point of your application—the rest happens automatically.

public App() 

The SetProfileRoot call tells the runtime where to store JIT profiles, and the StartProfile call enables Multicore JIT by using the provided profile name. The first time your application is launched, the profile does not exist, so Multicore JIT operates in recording mode and writes out a profile to the specified location. The second time your application launches, the CLR loads the profile from the previous launch, and Multicore JIT operates in playback mode.

No comments: