preface
. Net8 version, compared to. Net7 has changed a lot. In this article, let's take a look at some of its types of performance changes, officially recommended new types aimed at improving application performance.
wraparound
1.System.Collections.Frozen
Namespaces include the collection types FrozenDictionary< TKey, TValue> and FrozenSet. Once a collection is created, these types do not allow any changes to keys and values. This requirement enables faster read operations (e.g., TryGetValue()). These types are especially useful for collections that are populated at first use and then retained for long-term service, such as:
2.System.Buffers.IndexOfAnyValues
The type is intended to be passed to the method of finding the first match of any value in the passed collection. For example, String.IndexOfAny(Char[]) looks for the first match of any character in the specified array in the string that calls it. NET 8 adds new method overloads, such as String.IndexOfAny and MemoryExtensions.IndexOfAny that accept new type instances. When you create an instance of System.Buffers.IndexOfAnyValues, all the data needed to optimize subsequent searches will be derived at that time, which means that the work is done upfront.
3.System.Text.CompositeFormat
Types can be used to optimize format strings that are unknown at compile time (e.g., format strings are loaded from resource files). It takes some extra time up front to do things like parsing strings, but this saves work done every time you use it.
4.System.Buffers.IndexOfAnyValues
The type is intended to be passed to the method of finding the first match of any value in the passed collection. For example, String.IndexOfAny(Char[]) looks for the first match of any character in the specified array in the string that calls it. NET 8 adds new method overloads, such as String.IndexOfAny and MemoryExtensions.IndexOfAny that accept new type instances. When you create an instance of System.Buffers.IndexOfAnyValues, all the data needed to optimize subsequent searches will be derived at that time, which means that the work is done upfront.
5.System.Text.CompositeFormat
Types can be used to optimize format strings that are unknown at compile time (e.g., format strings are loaded from resource files). It takes some extra time up front to do things like parsing strings, but this saves work done every time you use it.
6. System.Numerics and System.Runtime.Intrinsics
Improvements to the System.Numerics and System.Runtime.Intrinsics namespaces. Vector256, Matrix3x2, and Matrix4x4 improve hardware acceleration on .NET 8. For example, Vector256 has reimplemented 2xVector128 where possible. Hardware internals now annotate using the ConstExpected property. This ensures that users know when the underlying hardware needs constants and when extraordinary values may accidentally harm performance.
Reference:The hyperlink login is visible. Original:The hyperlink login is visible.
|