[release/9.0-staging] Fix to #35212 - Query/Perf: Compile identifier lambdas passed to PopulateIncludeCollection rather than inline #35217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #35212
Port of #35213
Description
In EF9 we changed the way we generate shapers in preparation for AOT scenarios. As part of these changes we started inlining some delegates passed to PopulateIncludeCollection (as well as couple other methods), rather than compiling them. For scenarios with large number of entities we see significant perf degradation when these delegates are inlined, as opposed to compiled (like we used to do in EF8). This change reverts to EF8 behavior.
Customer impact
Queries using collection navigation with significant amount of data suffer large performance degradation when compared with EF8. No good workaround.
How found
Multiple customer reports on 9.0.0.
Regression
Yes, from 8.0. Perf regression only, no functional regression here.
Testing
Ad-hoc perf testing with BenchmarkDotNet. Functional change already covered by numerous tests.
Risk
Low - essentially reverting back to EF8 behavior, quirk added.
Benchmarks
before the fix (but already with invoke fix and no interpretation)
after the fix:
This gets us pretty close to the EF8 numbers which were: