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

Slowdown in Julia 0.2 #5011

Closed
magistere opened this issue Dec 2, 2013 · 9 comments
Closed

Slowdown in Julia 0.2 #5011

magistere opened this issue Dec 2, 2013 · 9 comments
Assignees
Labels
performance Must go faster regression Regression in behavior compared to a previous version
Milestone

Comments

@magistere
Copy link
Contributor

On Julia 0.2 release I got significant slowdown in my old test script comparing with Julia 0.2-prerelease-d6f7c7c. Run time increased from 5s to 40s.

import Base.div

const width = 640
const height = 480
const iters = 260

immutable Pixel
  r::Uint8
  g::Uint8
  b::Uint8
end

+(p1::Pixel, p2::Pixel) = Pixel(uint8(p1.r+p2.r),uint8(p1.g+p2.g),uint8(p1.b+p2.b))
div(p::Pixel, n::Int) = Pixel(uint8(div(p.r,n)),uint8(div(p.g,n)),uint8(div(p.b,n)))

function avg!(a::Array{Pixel,2}, b::Array{Pixel,2})
  for j = 2:height-1, i = 2:width-1
    b[i,j] = div(a[i-1,j] + a[i+1,j] + a[i,j-1] + a[i,j+1], 4)
  end
end

function test()
  in = Array(Pixel,width,height)
  out = Array(Pixel,width,height)
  tic()
  for i = 1:iters
    avg!(in,out)
    avg!(out,in)
  end
  toc()
end

test()
@kmsquire
Copy link
Member

kmsquire commented Dec 2, 2013

Hi @magistere, since you know a good commit and bad commit, are you up to doing a git bisect? #1689 (comment)

@magistere
Copy link
Contributor Author

Thanks, Kevin. I've found the commit 9489e6a that causes this slowdown.

@kmsquire
Copy link
Member

kmsquire commented Dec 3, 2013

cc: @JeffBezanson

@ghost ghost assigned JeffBezanson Dec 3, 2013
@StefanKarpinski
Copy link
Member

Maybe add this to our performance benchmarks?

On Monday, December 2, 2013, Kevin Squire wrote:

cc: @JeffBezanson https://github.com/JeffBezanson


Reply to this email directly or view it on GitHubhttps://github.com//issues/5011#issuecomment-29673966
.

@vtjnash
Copy link
Member

vtjnash commented Apr 25, 2014

this is improved in 0.3 master, but still far from the original:

julia> @time test()
elapsed time: 14.814826383 seconds
elapsed time: 15.471788592 seconds (9518721684 bytes allocated)
14.814826383

julia> VERSION
v"0.2.1+13"
julia> @time test()
elapsed time: 6.039069812 seconds
elapsed time: 6.300719424 seconds (4157816 bytes allocated)
6.039069812

julia> VERSION
v"0.3.0-prerelease+2742"
julia> VERSION
v"0.2.0-prerelease+3768"

julia> @time test()
elapsed time: 1.596434471 seconds
elapsed time: 1.690605844 seconds (3749388 bytes allocated)
1.596434471

@ViralBShah
Copy link
Member

This sort of stuff should certainly go into the perf benchmarks.

@vtjnash
Copy link
Member

vtjnash commented Apr 25, 2014

i think we may need to make inline_worthy a little smarter: changing the threshold there from current value of 40 to 240 (tested on my jn/6599 bugfix branch) results in net smaller code generation (current testing seems to show that that number corresponds roughly to the number of assembly bytes!) and results in a net speed increase over pre-0.2 best timing.

@ViralBShah
Copy link
Member

I am tempted to close this as a 0.2 thing, but running the code fragment here takes 15 seconds for me.

@simonster
Copy link
Member

Yes, this is still an issue. See @vtjnash's comments here.

@JeffBezanson JeffBezanson added this to the 0.4 milestone Feb 3, 2015
mbauman pushed a commit to mbauman/julia that referenced this issue Jun 6, 2015
It's pretty bad that you could get a 10x slowdown just from adding up a few
things, hence it was time for an undisciplined hack.
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

7 participants