.NET 6 Preview 3 released, 2021/4/8 .NET 6 Preview 3 is released. Most of the improvements in this version come from the bottom layer. Let’s take a look at the new features and improvements.
Library improvements
A faster processing method when new value-added types are used as dictionary values
.NET 6 Preview 3 introduces a new unsafe API CollectionsMarshal.GetValueRef
, this API allows you to update the value in place without data copy, and reduce the hash calculation of the key from 2 times to 1 time. Dictionary stored in the scene updates to improve high performance at struct
very useful.
E.g:
ref MyStruct value = CollectionsMarshal.GetValueRef(dictionary, key); // If it does not exist, return Unsafe.NullRef<TValue>() if (!Unsafe.IsNullRef(ref value)) { // No need to copy value.MyInt++; }
Interface check and conversion performance improvement
The performance of interface conversion and checking whether the type implements an interface has been improved by 16~38%. This improvement is especially useful for improving the performance of pattern matching.
Runtime
.NET 6 Preview 3 also includes more runtime improvements
Code generation optimization
- Remove boundary check after checking Length
- Span boundary check omission and top-level range check node removal
- Add loop cloning support for byte array access
- JIT: non-void ThrowHelpers
- Floating point constant CSE
- Enable CSE and loop invariant promotion optimization for immutable static read-only fields
- Collapse more constant string null checks
- Eliminate zero initialization of tracked temporary memory without GC fields
Dynamic PGO
- Update the profile that returns the merge and tail calls
- Class profile: Unknown placeholder can be used for the collection class typehandle
Keep the value type structure in the register
- Complete the first part of the value type structure improvement: create more LCL_FLD
- Improve the survivability of’STORE_BLK(lcl_var)’
Complete. NET 6 exception handler write-through
- Enabled by default in JIT
- Put the single-defined exception handler into the register
- 7~18% performance improvement
.NET hot reload is initially available for web applications
.NET 6 Preview 3 enabled initial support for ASP.NET Core and Blazor thermal overload, only need dotnet watch
to use to start the project, but need to be modified Properties/launchSettings.json
before you can use thermal overload:
For ASP.NET Core applications, add "hotReloadProfile": "aspnetcore"
; for Blazor WebAssembly applications, add "hotReloadProfile": "blazorwasm"
.
Hot reloading can directly apply code updates without restarting the application and without losing the context and application state. This feature does not rely on Visual Studio, even if you use Notepad to modify the code, you can also perform hot reloading.
In addition, this is only the first step for .NET 6 hot reloading, and hot reloading support will be enabled for all other types of .NET application development in the future.
Conclusion
There are actually more updates about ASP.NET Core and EntityFramework Core, but I won’t introduce them one by one here.
The above is part of the updated content included in .NET 6 Preview 3. Thanks for reading.