-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Block inlining of IntroSort #89310
Block inlining of IntroSort #89310
Conversation
With PGO and (via dotnet#88749) one level of recursive inlining enabled, the jit sees the recursive call made by `IntroSort` as an attractive inline candidate, but it isn't. Fixes dotnet#89106.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@EgorBo @stephentoub PTAL Benchmark is pretty noisy but this should resolve the regressions we've seen.
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
@@ -2207,6 +2207,7 @@ private void IntrospectiveSort(int left, int length) | |||
} | |||
} | |||
|
|||
[MethodImpl(MethodImplOptions.NoInlining)] |
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.
Can we include a comment as to why this is here? I imagine the calculus around whether this is valuable could change in the future.
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.
Added.
Note IntroSort
is nominally doubly recursive but has already had the tail recursive call transformed into a loop manually. If we were ever tempted to undo that and rely on the JIT to do something similar, we might find the NoInline
annotation would inhibit that transformation too.
@EgorBo we might consider special heuristics for recursion, generally if the method is large and doesn't have a frequent fast path that avoids recursion, then there's not much to be gained.
Note there is a longer-term regression here from PGO, see #87194. |
With PGO and (via #88749) one level of recursive inlining enabled, the jit sees the recursive call made by
IntroSort
as an attractive inline candidate, but it isn't.Fixes #89106.