Ngen vs RyuJIT is the fastest x64 running code when (pre-) launch doesn't matter

Are Ngen and RyuJIT two completely unrelated things in .NET 4.6 (especially with different optimization methods and algorithms)?

What produces the fastest (better optimized) x64 native code if we don't care about the cost of the jing itself and / or cold / warm start time?

We have launched an application for working with the server. The constant phase is very important in terms of performance. The start-up phase (pre-) is not important to us. So far, we have been on .NET 4.5 and have always generated our own Ngen images. We are currently upgrading to .NET 4.6, and we want to be sure that this will not reduce the performance of our continuous phase. I have read some information that RyuJIT - a great choice for improved time JITing, but jited-code can be less optimized compared to Ngen - see, for example,. The github commented one of RyuJIT errors .

+5
source share
1 answer

There is not enough difference between NGen and RyuJIT to make you happy. They perform very different tasks, NGen is compressed ahead of schedule and RyuJIT is compressed during the process. But NGen does not have his own trembling, he asks RyuJIT to do the job. The generated machine code is not fundamentally different. There are several optimizations that cannot be performed in advance, the code with the modified code is a bit slower.

Technically, NGen can do a better job, as the optimizer can spend more time analyzing the code and finding the best optimization. But Microsoft does not use it. It’s not entirely crystal clear why they have nothing to do with their support number 1-800. Code optimization is always the most risky part of the code generator, and errors in existing fluctuations have always been optimization errors. That this may change once is unthinkable.

You will be ahead when you can take advantage of .NET Native. It generates code ahead of time using the C ++ back-end compiler. But at present and, of course, for quite some time, it is only supported for packaged applications. In a store that ships through the Windows Store, you need to target Store, Phone, or Universal and use the Store as a vehicle for deployment. The package is very important in order to make .NET Native work, only a decent way to see what code needs to be translated. And it often still needs help to get it right, Reflection is a difficult problem to solve, the reason you use it on your machine. Note that for NGen, the same problem does not exist; it still relies on jitter to get some code in time. Like the target reflection code and generics. That this may change once is unthinkable.

As noted, the NGen code is a bit slower. Therefore, if you do not need a warm start delay, you do not want to use NGen.

Last but not least, RyuJIT does not generate faster code than its predecessor. Which have already done a very decent job of optimization. Too decent. The RyuJIT project started having problems with the obsolete x64 jitter, which was quite fundamental in the code base and could only be resolved with a sharp rewrite. Optimization was one of them; it did not have an upper bound on the time spent on it. Giving him very unreasonable break times on great methods. Therefore, if you want to squeeze the last ounce, and then deliberately disable RyuJIT so that it returns to legacy x64 jitter, you should try.

+10
source

Source: https://habr.com/ru/post/1235679/


All Articles