FastExpressionCompiler icon indicating copy to clipboard operation
FastExpressionCompiler copied to clipboard

Implement IArgumentProvider for the BlockExpression to minimize the consumed memory

Open dadhi opened this issue 3 years ago • 2 comments

Related to #266

dadhi avatar Nov 02 '20 12:11 dadhi

Maybe we should raise a Bug a Microsoft:

You should not use this API. It is public only due to assembly refactoring, and it exists only for internal performance optimizations. It enables two optimizations that reduce the size of the trees:

found here: https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.iargumentprovider?view=netcore-3.1

but in the source: https://github.com/dotnet/runtime/blob/6072e4d3a7a2a1493f514cdf4be75a3d56580e84/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/IArgumentProvider.cs i could not find it

jogibear9988 avatar Nov 02 '20 18:11 jogibear9988

@jogibear9988 Yes, so far Block does not implement the IArgumentProvider in the System Expression.. but that's fine considering it as internal optimization. It does not prevent me from the implementing it for the LightExpression.BlockExpression.

I did this already for some types that implement provider in System (New, MethodCall, Invoke) and for some that not (Index, ArrayBounds, ArrayInit). I can do whatever is necessary to improve things in the LightExpression - and likely in the future System will support the same thing as well.

dadhi avatar Nov 02 '20 18:11 dadhi

Now it is implemented for Block but for the 2 arguments only (comparing to the 5 in the .NET 8). As an implementation we are using SmallList2 instead of separate Block class per argument count.

dadhi avatar Nov 07 '23 16:11 dadhi