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

Julia 1.3 runs my script at least 10x slower than Julia 1.1 does on my computer #33014

Closed
jdjohnston opened this issue Aug 21, 2019 · 5 comments
Labels
performance Must go faster regression Regression in behavior compared to a previous version

Comments

@jdjohnston
Copy link
Contributor

jdjohnston commented Aug 21, 2019

Please see the fuller discourse post.

Summary: On my computer, Julia 1.3 (from about DEV.308 through current) runs the posted script at least 10x slower than Julia 1.1.1 and even Julia 1.3-DEV through about DEV.164.

My best guess is that, in mid-May, there was a deliberate design decision to be less aggressive in the use of garbage collection. I can see how that would be useful on systems with much RAM, but on my laptop (1879MiB, per lshw) it's not helpful. Probably true for others with limited RAM, including embedded systems. If my guess is correct, would it be reasonable to have a command-line option so the user can tune gc aggressiveness, somewhat like the existing --optimize option?

I've attached the script in question as a text file:
peuler92.jl.txt

@StefanKarpinski
Copy link
Member

I can reproduce this and it's also slow on release-1.2. If was fast on ce17e05 which is 787 commits before release-1.2 so it happened somewhere in there if someone wants to bisect.

@jdjohnston
Copy link
Contributor Author

@StefanKarpinski, thanks for looking at this. For me the performance of Julia 1.2.0 is comparable to 1.3-DEV.164, i.e. as fast as 1.1.1 and maybe a little faster.

@goggle
Copy link
Contributor

goggle commented Aug 22, 2019

@c42f pointed out, that #31722 might have caused this issue.

@KristofferC KristofferC added performance Must go faster regression Regression in behavior compared to a previous version labels Aug 22, 2019
@c42f
Copy link
Member

c42f commented Aug 25, 2019

To repeat a probable MWE from the discourse post:

sumsqdig(n::Int) = sum(i*i for i in digits(n))
julia> VERSION
v"1.3.0-alpha.156"

julia> @btime sumsqdig(5000_000)
  661.931 ns (4 allocations: 192 bytes)
julia> VERSION
v"1.1.0"

julia> @btime sumsqdig(5000_000)
  91.624 ns (3 allocations: 176 bytes)

If this is due to the code in digits becoming very slightly more complex (#31722) and interacting badly with inlining, that's neither a regression in the compiler nor the API, just an unfortunate interaction. So it might be tricky to fix with a small tweak.

A good fix would remove the allocation from digits by making it return some immutable AbstractVector of digits (perhaps using one of the ideas from #31722 (comment)). That's technically a breaking change though so I'm not sure how best to proceed.

@jdjohnston
Copy link
Contributor Author

Somewhere between Julia 1.3.1 & Julia 1.4.1 there's been a dramatic improvement in performance for this problem (on my laptop, at least). And, yes, it continues on through Julia 1.5.1 :). For myself, I would consider this particular issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

5 participants