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

performance regression in findfirst due to inlining #26446

Closed
JeffBezanson opened this issue Mar 13, 2018 · 4 comments
Closed

performance regression in findfirst due to inlining #26446

JeffBezanson opened this issue Mar 13, 2018 · 4 comments
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) performance Must go faster regression Regression in behavior compared to a previous version

Comments

@JeffBezanson
Copy link
Member

JeffBezanson commented Mar 13, 2018

julia> a = rand(10000000); z = a[end];

julia> @time findfirst(equalto(z), a)
  0.411288 seconds (10.01 M allocations: 153.062 MiB, 36.84% gc time)

In 0.6 there are no allocations. The reason for this is that findfirst is a simple wrapper for findnext, and so it does not get specialized on its function argument (since it doesn't call the function itself). However, findnext is being inlined into it anyway. I don't think we should inline in this case (perhaps whenever the argument types are not is_cacheable_sig for the target method, and/or because the target method has a loop).

@JeffBezanson JeffBezanson added performance Must go faster regression Regression in behavior compared to a previous version compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Mar 13, 2018
@KristofferC
Copy link
Member

KristofferC commented Mar 13, 2018

Perhaps #26418 has the same cause?

@vtjnash
Copy link
Member

vtjnash commented Mar 14, 2018

I vaguely thought we already had an issue for not inlining a called parameter into the unspecialized wrapper, but I can't find it. There is #25116, which is related though at least.

@vtjnash
Copy link
Member

vtjnash commented Jul 10, 2018

Fixed now?

julia> @time findfirst(isequal(z), a)
  0.019936 seconds (6 allocations: 192 bytes)
10000000

@vtjnash vtjnash closed this as completed Jul 10, 2018
@JeffBezanson
Copy link
Member Author

Yes #27857 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) performance Must go faster regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

3 participants