.NET 9 is now available with several performance improvements


.NET 9 is now available, and with it comes a number of performance improvements and new functionality to support developers building with AI. 

According to Microsoft, this release features over 1,000 performance updates, one of which is that the Server GC has been altered to adapt to application memory requirements instead of the resources available in the environment. This change has resulted in a 15% increase in requests per second compared to .NET 8 and a 93% reduction in memory usage. 

“This change in approach has a profound impact in high core-count environments, where application memory is small or changes dramatically over time,” the .NET Team explained in a blog post

In addition, the .NET 9 runtime added support for Arm64 SVE and Intel AVX10, and in this release, the JIT compiler received improved performance for Arm64, loops, PGO, and bounds checks. 

.NET 9 also features updated Dynamic Profile Guided Optimization (PGO) to provide optimizations for more code patterns. 

Additionally, LINQ was optimized for common cases, and the methods Take and DefaultIfEmpty now return up to 10 times faster if the underlying array, collection, or enumerable is empty. 

And finally, low-level details of System.Text.Json have seen greater than 50% improvements across a range of operations. 

Another major theme of this release is expanding .NET capabilities for building AI into applications. 

“Companies across the industry have embraced .NET to build top-tier AI experiences for their customers including H&R Block, Blip, and KPMG. .NET powers your favorite coding assistant, GitHub Copilot, and the brand-new Microsoft Copilot experience was rebuilt from the group up with .NET,” the .NET Team wrote.

For this release, Microsoft collaborated with Semantic Kernel to provide a set of C# abstractions for the .NET ecosystem for interacting with AI services. This will make it easier for developers to integrate these services into their applications. 

Additionally, Microsoft.ML.Tokenizers features improved performance across popular model families like GPT, Llama, PHi, and Bert. It also adds support for new tokenization algorithms such as Byte-Level BPE, SentencePiece, and WordPiece. Tensor<T> also got a new type for representing multidimensional data, which simplifies interoperability between libraries.

For GitHub Copilot users, a number of new features have been added to the .NET experience, including smart variable inspection, an IEnumerable visualizer, issue resolution assistance, better AI completions for C#, and help with debugging tests.

Moving beyond AI, in ASP.NET Core, static web assets like JavaScript and CSS files are optimized during the build and publish phases. It now generates a unique fingerprint for those files, ensuring that it has a unique file name, which prevents stale versions of the file from accidentally being used. The files are also precompressed when the app is published, cutting down the download size and preventing the server from having to do compression work. 

And finally, the Blazor framework was updated with the ability to detect the component render mode at runtime and adjust rendering appropriately. Developers can also disable interactive elements during prerendering and then enable them again once the component is interactive. Additionally, the reconnection experience for apps using interactive server rendering has been updated with an improved UI, faster reconnection, and automatic reloading after a user’s connection is lost. 

“Blazor is better than ever in .NET 9 to empower you to build beautiful modern web & hybrid apps. This release brings performance improvements across all areas of Blazor, a new Blazor Hybrid and Web app template, and new APIs for developers to create delightful experiences,” the .NET team wrote. 

Other updates in .NET 9 include: 

  • Built-in support for OpenAPI document generation
  • Better security for ASP.NET Core
  • .NET MAUI updates
  • New updates to the .NET Aspire stack, such as the ability to start and stop resources from the dashboard, and new integrations with OpenAI, Ollama, Milvus, and more.

Microsoft is currently hosting .NET Conf 2024 through November 14, and will be diving deeper into the updates throughout the event. The company has also promised to publish blog posts that dive deeper into these updates in the coming months.