-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[release/10.0] Fix performance degradation for primitive collections for multiple parameters translation and deep trees with closure over same variable #37313
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
Conversation
* Reduce allocations. * Allow for less looping when `uniquifier` is provided.
* This partially reverts back to previous behavior of having a running count. * But still uses the new naming.
b910fcf to
9c94053
Compare
…onal parameters in 11/later).
roji
left a comment
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.
LGTM, thanks.
3fafe58 to
4a261b0
Compare
|
cc @artl93 |
artl93
left a comment
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.
Customer reported, performance, regression. Approved.
|
Approved via email. |
Fixes #37152.
🔢
💭
The Manual benchmark is now very close to what it used to be in 9. The 2% difference in speed (some runs showed 5%, the Error/StdDev here is pretty high) is the "price" for now much more nicer parameter names.
The Contains benchmark is not comparing 🍎 and 🍎. In 9, the query was translated to
OPENJSON, while in 10 this is translated to multiple parameters. Before the fix the translation was very slow (~188x) and created a lot of allocations (~448x). Now the numbers are ~5x and ~10x. Again, this is comparing 1 parameter vs 1000 parameters - 🍎 vs 🍊.Fair to say, I know about a decent room for improvement in allocations (hence theoretically in speed as well, at least in benchmarks). But it is too risky for servicing. I might do it for 11.
It is also important to know that this benchmark measures only the translation. Once the query hits the database, the translation to multiple parameters should show its real benefits.
Description
EF 10 changed the default translation for parameterized collections from single parameter and JSON function to multiple parameters. We missed O(n^2) performance degradation in code path where we generate unique parameter names resulting in subpar performance.
Customer impact
Query translation takes significant time compared to other types of translation. Excessive allocations.
How found
Customer reported on 10.0.
Regression
Yes.
Testing
The change in the PR is covered by existing tests. We don't have specific benchmarks for translations.
Risk
Low. Added fast path optimization. Quirk added.