After moving Microsoft search engine Bing to .NET Core 2.1, internal server latency dropped by 34%, writes Microsoft engineer Mukul Sabharwal, mostly thanks to improvements contributed by the .NET community.
According to Sabharwal, a number of improvements to .NET Core account for most of the performance gain, including vectorization of string equality and string.IndexOf/LastIndexOf using the new Span<T>
type, which speeds up HTML rendering and manipulation; devirtualization for EqualityComparer
(Image from Microsoft blog).
As mentioned, most of the improvements were contributed by the .NET community, notes Sabharwal, although many GitHub’s PRs originated from Microsoft employees.
There were two key factors that made possible to transition Bing to .NET Core 2.1, according to Sabharwal. One is support for ReadyToRun images, which enables JIT compilation as a pre-deployment step. Without ReadyToRun images, all code should be JIT-compiled on each machine where it is meant to run, with a significant reduction in service capacity due to the sheer number of machines powering Bing. Using the .NET Core crossgen tool, it was instead possible to pre-compile the application in Microsoft labs and then deploy the images.
The second key factor is .NET Standard 2.0, a collection of over 32k APIs which helped developers ensure that their code was easily portable to .NET Core 2.1 on multiple platforms.
As a final remark, Sabharwal stresses the importance of using xcopy to deploy the .NET Core runtime inside the Bing application from their continuous integration pipeline. This made it possible to have Bing transitioned to .Net Core 2.1 just two days after the official .Net Core 2.1 release.
As InfoQ reported at the time of its announcement, one of the biggest selling points for .NET Core 2.1 is performance improvement, along with new deployment options in the form of self-contained deployments. On the performance front, most notably .NET Core 2.1 brought support for the new System.Span<T>
type, which has been lately added to F# 4.5 as well. Additionally, the JIT compiler got many optimizations, including the ones listed above.
If you want to get more in-depth information about .NET Core 2.1 performance improvements, do not miss Microsoft engineer Stephen Toub’s post.