-
Notifications
You must be signed in to change notification settings - Fork 647
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
Further improve pipeline invocation speed #6394
Conversation
…ontext directly instead of the interface and leveraging a bit of unsafe trickery for .NET 6
4cbc4d8
to
8eb3a30
Compare
8eb3a30
to
b9593af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for my own understanding, mostly.
var lambdaExpression = Expression.Lambda(body, outerContextParam); | ||
expressions?.Add(lambdaExpression); | ||
return lambdaExpression.CompileFast(); | ||
} | ||
|
||
#if NET | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does aggressive inlining have any effect since the method is only found via reflection? Or does this affect the compilation of the lambda expression as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to find any documentation whether expression trees that point to static methods that are aggressively inlined can be properly JITed. I did run tests with and without the inlining hint and I saw 3-5% gains when I added the inlining hint. Unfortunately, I do not have the test results on the laptop I'm currently typing on, but I'm happy to share it later in case you are interested.
...us.AcceptanceTests/ApprovalFiles/When_pipelines_are_built.Should_preserve_order.approved.txt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
This is a follow-up for .NET 6 as promised in #6237
Further improve pipeline invocation speed by accessing the specific context directly instead of the interface and leveraging a bit of unsafe trickery for .NET 6
This gives us another 11-23% Improvements on top of the latest rounds for the pipeline execution and 3-22% for the exception case. Plus, it simplifies the code because there is less expression tree code available that someone has to process while reading the code.
Additionally we can get rid of the TFM specific approvals because the method call is the same on both TFMs which brings in further cleanup too.
By directly invoking the method on the concrete context instead of
IExtendable
a few extra squeezes out of it too that also applies for the .NET Framework version.Pipeline execution
Pipeline exception
Pipeline warmup
Warmup is again slightly slower but that is expected since we are doing slightly more heavy lifting due to creating more generic methods during expression tree baking. It is still though in the
ys
area which is an acceptable price to pay.