Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize any nested lambda compilation (LINQ) by compiling right after collect one-by-one #370

Closed
dadhi opened this issue Aug 21, 2023 · 1 comment · Fixed by #371
Closed
Assignees
Milestone

Comments

@dadhi
Copy link
Owner

dadhi commented Aug 21, 2023

Currently, we are collecting all nested lambdas before going to compile, which keeps all ClosureInfo in the heap.
I don't see a reason for it now, and we may just use one ClosureInfo on stack for the specific nested lambda compilation.

@dadhi dadhi added this to the v3.4.0 milestone Aug 21, 2023
@dadhi dadhi self-assigned this Aug 21, 2023
dadhi added a commit that referenced this issue Aug 21, 2023
@dadhi
Copy link
Owner Author

dadhi commented Aug 28, 2023

Improved in NestedLambdasVsVars.cs benchmark:

Before

Method Mean Error StdDev Ratio RatioSD Gen0 Gen1 Gen2 Allocated Alloc Ratio
LightExpression_with_sub_expressions_CompiledFast 21.32 us 0.387 us 0.717 us 1.00 0.00 1.4648 1.4038 0.0305 9 KB 1.00
Expression_with_sub_expressions_Compiled 571.67 us 11.221 us 12.922 us 26.75 1.11 3.9063 2.9297 - 28.47 KB 3.16

After

Method Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
LightExpression_with_sub_expressions_CompiledFast 19.31 us 0.321 us 0.343 us 1.00 0.00 1.1902 1.1292 7.32 KB 1.00
Expression_with_sub_expressions_Compiled 602.67 us 22.702 us 65.502 us 30.55 3.29 3.9063 2.9297 28.7 KB 3.92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant