Microsoft Speeds Up Windows Store Apps with .NET Native
.NET Native is an attempt from Microsoft to reduce the start up times and memory footprint of Windows Store applications.
Speculation about this project started to circulate in November last year when some noticed that a certain Windows Store app had a much faster start up time. Known internally as Project N, .NET Native improves the performance of .NET applications by precompiling managed code into native one using the Microsoft’s C++ back-end infrastructure. This technology is different from NGen (Native Image Generator) or dynamic compilation for Store apps.
The .NET Native toolchain initially generates MSIL which is then processed by the C++ optimizer generating MDIL (Machine-Dependent IL), according to Mani Ramaswamy, Project Manager of the .NET Native team, who provided technical details in a Channel 9 interview. The native app is statically linked against Mrt100.dll which is just a few hundred KB in size, according to Shawn Farkas, Dev Lead. Mrt100.dll represents a minimum CLR, refactored and optimized for static compilation. So, when the application starts up it runs against this minimal CLR without loading the entire .NET runtime, without involving any JIT compilation.
Applications can still use
dynamic to access objects whose type is decided at run time. This is made possible by discovering during code optimization and keeping all the possible types that might be accessed at run time, said Ramaswamy. Also, the standard background garbage collection is used.
These optimizations have increased the start up time up to 60%, while the memory footprint has been lowered by 15%, according to Ramaswamy. .NET Native is currently a preview and is targeted at Windows Store apps, but the team intends to extend it to the general desktop .NET apps.
Not much changes for the .NET developer. There are no machine abstractions introduced at the application level, and the entire developing-debugging experience remains the same. What changes is the build. One needs to generate separate builds for specific hardware platforms, of which two are already supported - ARM, x86-64bit –, while support for the x86-32bit is to come soon. One should expect 1-2 minutes longer build times due to optimizations.
Not everything works right now. MSDN has a section for Compiling Apps with .NET Native, including a page on migrating apps to .NET Native. There are some differences in the runtime, dealing with dynamic programming and reflection, a number of unsupported scenarios and APIs, and differences in working with Visual Studio.
Visual Basic 6 compiler
Pre-compiling, rather than JIT compiling, will speed up loading time, though not necessarily performance.
Of course, the backend compiler for this is the C++ compiler - just like the VB6 programming language has used since 1998 !
Bhoomi Mehta Nov 27, 2015
Srini Penchikala Nov 26, 2015