TECH NEWS DESK:
If you are looking for .NET 7, Microsoft releases the third preview version of the framework to help you prepare your apps for the next version of .NET. The third preview of .NET 7 includes enhancements to observability, startup times, codegen, GC regions, native AOT compilation, and more. You can grab the build right now to start experimenting with new features.
What’s new and improved in .NET 7 Preview 3
Native AOT compilation
When Microsoft released .NET 7 Preview 2, the company announced that the Native AOT support in .NET 7 has been moved out of the experimental status and had been moved into the .NET 7 mainline development. With today’s build, Microsoft ships ReadyToRun for client and server scenarios, and Mono AOT for mobile and WASM.
What is Native AOT
Ahead-of-time (AOT) compilation refers to an umbrella of technologies which generate code at application build time, instead of run-time. Native AOT brings full native pre-compilation to .NET desktop client and server scenarios. Native AOT is not replacing these existing technologies, rather it’s offering a new set of capabilities that unlocks new form factors.
Native AOT is similar to .NET’s existing AOT technologies, but it produces only native artifacts. In fact, the Native AOT runtime does not know how to read the .NET assembly file formats – everything is platform-native. The executable file format parsing is fully handled by the underlying operating system, says Jon Douglas, Senior Program Manager (NuGet, Microsoft)
The main advantage of Native AOT is in startup time, memory usage, accessing to restricted platforms (no JIT allowed), and smaller size on disk. Applications start running the moment the operating system pages in them into memory. The data structures are optimized for running AOT generated code, not for compiling new code at runtime.
Microsoft .NET 7 continues to evolve support for the cloud-native OpenTelemetry specification. In the .NET 7 Preview 3, Microsoft now adds support for specification updates #988 and #1708. According to the company, this will make the trace state mutable for samplers.
The major focus of .NET 7 lies in performance improvements. In the latest update, Microsoft reimplemented the precode and call counting stubs (tiered compilation helper stubs) to significantly reduce the number of post-creation modifications of executable code in the runtime. This resulted in 10-15% startup time improvements.
This change also resulted in steady-state performance improvements (up to 8%) in some microbenchmarks and some ASPNet Benchmarks even without Write-Xor-Execute enabled.