New improvements in .NET Core 2.0
The most recent version of .NET Core, 2.0, comes with a number of improvements. .NET Core 2.0 is the fastest version of all times and can run on multiple platforms including various Linux distros, macOS (operating system), and Windows.
Note
Distros stands for Linux distribution (often abbreviated as distro), and it is an operating system made from a software collection, which is based upon the Linux kernel and, often, a package management system.
Performance improvements
.NET Core is more robust and performance efficient and, since it's open source, the Microsoft team with other community members are bringing more improvements.
The following are the improvements that are part of .NET Core 2.0.
RyuJIT compiler in .NET Core
RyuJIT is a next-generation JIT compiler that is a complete rewrite of the Just In Time (JIT) compiler and generates a lot more efficient native machine code. It is twice as fast as the previous 64-bit compiler and provides 30% faster compilation. Initially, it runs on only X64 architectures, but now it supports X86 as well and developers can use the RyuJIT compiler for both X64 and X86. .NET Core 2.0 uses RyuJIT for both X86 and X64 platforms.
Profile guided optimization
Profile-guided optimization (PGO) is a compilation technology used by C++ compiler to generate optimized code. It applies to the internal native compiled components of the runtime and JIT. It performs compilation in two steps, which are as follows:
- It records the information about code execution.
- From this information, it generates better code.
The following diagram depicts the life cycle of how the code is compiled:
In .NET Core 1.1, Microsoft already released the PGO for Windows X64 architecture, but in .NET Core 2.0, this has been added for both Windows X64 and X86 architectures. Also, as per observatory results, it was noted that the actual startup time is mostly taken by coreclr.dll
and clrjit.dll
for Windows. Alternatively, on Linux, there are libcoreclr.so
and libclrjit.so
, respectively.
Comparing RyuJIT with the old JIT compiler known as JIT32, RyuJIT is more efficient in code generation. The startup time of the JIT32 was faster than the RyuJIT; however, the code is not efficient. To overcome the initial startup time taken by the RyuJIT compiler, Microsoft used PGO, which brought the performance closer to JIT32 performance and achieved both efficient code and performance on startup.
For Linux, the compiler toolchain is different for each distro, and Microsoft is working on a separate Linux version of .NET that uses the PGO optimizations applicable to all distros.
Simplified packaging
With .NET Core, we can add libraries to our project from NuGet. All framework and third-party libraries can be added as NuGet packages. With a large sized application that refers many libraries, adding each library one by one is a cumbersome process. .NET Core 2.0 has simplified the packaging mechanism and introduced meta-packages that can be added as one single package that contains all the assemblies that are linked to it.
For example, if you wanted to work on ASP.NET Core in .NET Core 2.0, you just have to add one single package, Microsoft.AspNetCore.All
, using NuGet.
The following is the command that will install this package into your project:
Install-Package Microsoft.AspNetCore.All -Version 2.0.0