.NET 7 Preview 3 has been released , and the third preview of .NET 7 includes enhancements to observability, startup time, code generation, GC zones, Native AOT compilation, and more.
Native AOT compilation
The main advantages of Native AOT are startup time, memory usage, access to restricted platforms (no JIT allowed), and less disk space. The Preview 3 version has optimized and updated the Native AOT performance. The following is the latest Native AOT performance (compared with the existing AOT compilation "ReadyToRun"):
The next few .NET releases will continue to improve Native AOT compatibility and will add first-class support ( Crossgen apps ) to the dotnet SDK for publishing projects using Native AOT.
observability
.NET 7 continues to evolve support for the cloud-native OpenTelemetry specification. Preview 3 added support for spec updates ( #988 and #1708 ) to make tracking state mutable for samplers.
// ActivityListener Sampling callback listener.Sample = (ref ActivityCreationOptions<ActivityContext> activityOptions) => { activityOptions = activityOptions with { TraceState = "rojo=00f067aa0ba902b7" }; return ActivitySamplingResult.AllDataAndRecorded; };
Improve startup time
Performance remains a major concern for .NET 7 . dotnet/runtime#65738 PR , reimplemented precode and call count stubs (using tiered compilation helper stubs) to significantly reduce the amount of executable code that is created and then modified in the runtime.
Enabling this new Write-Xor-Execute feature can reduce startup time by 10-15%. Even without Write-Xor-Execute enabled, this change brought steady-state performance improvements (up to 8%) on some microbenchmarks and some ASPNet benchmarks.
Loop optimization
- The loop clone function improves the single call duration of System.Collections.Tests.Perf_BitArray.BitArrayLeftShift(Size: 512) by 21%:
GC zones are enabled by default
In Preview 3, all platforms except MacOS and NativeAOT have the GC region feature enabled by default, which helps improve memory utilization for high-throughput applications.
Details on GC zone functionality can be found in this Issue .
code generation
This release includes several optimizations and bug fixes for code generation and JIT compilation, such as
- Enable fast tail call optimization for ARM32
- Optimize "X & 1 == 1" to "X & 1" (#61412)
- ZeroObj Assertion
- Deduplication HWI code generation code
- Use push for 8/12 byte struct parameters on x86
...
More content can be viewed in the official blog .