Aot crypto

Comment

Author: Admin | 2025-04-27

Improvements in LINQ in .NET 9). With Native AOT, however, significant use of LINQ can also measurably increase code size, in particular when value types are involved. As will be discussed later when talking about LINQ optimizations, one of the optimizations LINQ employs is to special-case based on the inputs what kind of IEnumerable its methods give back. So, for example, if you call Select with an array input, the IEnumerable you get back might actually be an instance of the internal ArraySelectIterator, and if you call Select with a List, the IEnumerable you get back might actually be an instance of the internal ListSelectIterator. The Native AOT trimmer can’t readily determine which of those paths might be used, so the Native AOT compiler needs to generate code for all such types when you call Select. If the T is a reference type, there will just be a single copy of the generated code shared for all reference types. But if the T is a value type, there will be a custom stamp of the code generated for and optimized for each unique T. That means if such LINQ APIs (and other similar APIs) are used a lot, they can disproportionately increase the size of a Native AOT binary. dotnet/runtime#98109 is an example of a PR that replaced a bit of LINQ code in order to measurably reduce the size of ASP.NET applications compiled with Native AOT. But you can also see that PR being thoughtful about which LINQ usage

Add Comment