Meet RyuJIT: New JIT Compiler for .NET

The world is moving towards 64-bit computing, despite the fact that, as a result, programs do not always work faster or more efficiently than 32-bit ones. Many 32-bit programs, for various reasons, can run faster than 64-bit ones. One such example is the 64-bit JIT compiler for the .NET framework. It does a lot of work so that your program works very quickly, but alas, it is not as fast as we would like. This is what we are going to fix. Introducing the new generation x64 JIT compiler, which is able to compile 64-bit .NET code 2 times faster.

Talk about x64


It seems that 32-bit x86 computers have been around for a very long time. This is a great architecture that has one big problem: the address space of 32-bit pointers is limited to 4 GB. 64-bit computers with their extended pointers can address an almost unlimited amount of data. When the first x64 version of Windows appeared, RAM was relatively expensive, so 64-bit machines in most cases were used as servers. Now x64 architecture has become mainstream and computers are shipped, as a rule, with RAM volumes of at least 4 GB. Even some smartphones have switched to 64-bit processors, despite the fact that they have only 1 GB of RAM.
The .NET x64 JIT was designed to produce the most efficient code during the execution of long-running processes running on the server. This is its difference from the .NET x86 JIT, which is optimized for the fastest compilation of IL-code into machine code, which ensures quick launch of programs. Optimizing code performance is often justified for server applications. But “server applications” also include web applications, one of the requirements for which is the quickest start. The 64-bit JIT in current versions of .NET rarely boasts a quick compilation of IL-code, which forces many to use other technologies, such as NGen or background JIT.

RyuJIT to the rescue!


RyuWhat? The .NET Code Generation team is currently working on a brand new x64 compiler, codenamed RyuJIT. It works 2 times faster than the current version. This means that the launch time of the programs compiled by him is reduced by about 30% (the time spent on JIT compilation is only part of the process of executing applications, so the fact that JIT works 2 times faster does not mean that the application should accelerate as well ) In addition, the new JIT still provides the most efficient machine code.
The graph below shows how RyuJIT is faster than the current JIT64:
image
Obviously, all the examples worked faster with the new JIT. You probably noticed that the second example (RFC822 e-mail RegEx) literally went beyond the graph. This is because regular expressions work especially poorly on JIT64. Compiling this example with a JIT64 compiler took 60 seconds and required 1.4 GB of memory. In the case of RyuJIT, it took only 1.8 seconds and 199 MB.
The Paint.NET example came out more normal. Running the application on a test machine was reduced from 2.3 to 1.8 seconds. Compilation time was reduced 1510 ms to 970 ms. I think it’s clear that a quick start with minimal memory usage makes our world a better place.

And for dessert ...


The improved performance and reduced resources used by RyuJIT are great, of course, but not the most amazing thing about it. When JIT64 was just being developed, we decided to take the basis of command optimization from the C ++ compiler instead of the then 32-bit JIT compiler, which was better optimized for dynamic compilation scenarios. Most 64-bit computers were then used as servers, so it was important to focus on the quality of the compiled code instead of improving the performance of the compiler itself. And as a result, the .NET CodeGen team had to maintain code for two different compilers. Adding features and fixing bugs in two places hindered the introduction of innovations. And the addition of ARM architecture and MDIL for Windows Phone 8.0 in recent years has made this work even harder.
RyuJIT is based on the x86 JIT code base. While it works only for 64-bit architecture. This upgraded compiler will later become the basis for all our JIT compilers: x86, ARM, MDIL, and possibly something else. A common code base means that .NET applications will work as similar as possible on different platforms, in other words, bugs will be the same on different architectures. However, this also means that we will be able to introduce new technologies much faster.

What needs to be done to try it?


The CTP version of RyuJIT is available and right now you can try it in your test environment. There is no support for production yet.
You can download the RyuJIT installer now, but it only works on 64-bit versions of Windows 8.1 and Windows Server 2012 R2. Note that RyuJIT does not modify NGen on your system — we wanted the installation to be clean. And yet, after turning on RyuJIT, while writing the “Edit & Continue” code in VS, it will stop working for x64.
After installation, there are two ways to enable RyuJIT. If you want to enable it only for one specific application, add the environment variable “ COMPLUS_AltJit = * ”. If you want to enable it for all applications, you need to define a key in the registry “HKLM \ SOFTWARE \ Microsoft \ .NETFramework \ AltJit ”with the string“ * ”. Both of these methods force the 64-bit CLR to use RyuJIT instead of JIT64. In addition, both of these methods are reversible - installing RyuJIT does not change anything on your computer (except for placing files in the compiler directory).

Source: .NET Framework Blog
.NET Code Generation Team Blog

Also popular now: