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

Evaluating mul! in REPL is slow #36860

Closed
cafaxo opened this issue Jul 30, 2020 · 5 comments
Closed

Evaluating mul! in REPL is slow #36860

cafaxo opened this issue Jul 30, 2020 · 5 comments
Assignees
Labels
compiler:latency Compiler latency display and printing Aesthetics and correctness of printed representations of objects. regression Regression in behavior compared to a previous version

Comments

@cafaxo
Copy link
Contributor

cafaxo commented Jul 30, 2020

In version 1.4.2, the following is evaluated pretty much instantly:

julia> using LinearAlgebra

julia> mul!
mul! (generic function with 154 methods)

However, in the latest nightly build from commit f130d9b, the mul! takes multiple seconds to evaluate.

@cafaxo cafaxo changed the title Typing mul! into REPL is slow Evaluating mul! in REPL is slow Jul 30, 2020
@fredrikekre fredrikekre added the display and printing Aesthetics and correctness of printed representations of objects. label Jul 30, 2020
@JeffBezanson JeffBezanson added compiler:latency Compiler latency regression Regression in behavior compared to a previous version labels Aug 1, 2020
@cafaxo
Copy link
Contributor Author

cafaxo commented Aug 1, 2020

Did a small bisect using some nightlies I downloaded. Commit 109dee7 is good, commit 3d97a82 is bad.
The issue is caused by one of these commits.

@timholy
Copy link
Sponsor Member

timholy commented Aug 1, 2020

On nightly:

julia> @time methods(mul!);
  3.086545 seconds (5.46 M allocations: 513.957 MiB, 1.59% gc time)

This is not dependent on compilation, it happens even if you re-execute it.

@JeffBezanson
Copy link
Sponsor Member

This makes sense --- there is a new implementation of finding matching methods, and it (1) is optimized for returning a small number of matches (as happens during inference), and (2) can be a bit super-linear, so it takes a while to return all methods. Can maybe be fixed by adding a fast path for Tuple{Vararg{Any}}.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 16, 2020

Oh wow, I knew that function was causing severe performance problems whenever someone did method insertion during code loading (which was improved by #35983), but not that it hit this quite so bad. The main problem is that whoever wrote this code ("generic function with 154 methods") is having it remove any ambiguous methods from that count. Just counting them would be far easier:

julia> @time length(Base.MethodList(typeof(mul!).name.mt))
  0.000074 seconds (164 allocations: 6.703 KiB)
154

But from looking into a bit in the past, it appeared that these performance problems are all rooted in #36951, and are now being surfaced more clearly in one place, instead of being spread out over a couple places.

@JeffBezanson JeffBezanson self-assigned this Oct 16, 2020
JeffBezanson added a commit that referenced this issue Oct 16, 2020
@cafaxo
Copy link
Contributor Author

cafaxo commented Oct 21, 2020

Closed by #38065.

@cafaxo cafaxo closed this as completed Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency display and printing Aesthetics and correctness of printed representations of objects. regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants