Looking at code_llvm(sumofsins2, (Int,)), it looks like sin(3.4) used to be 
constant collapsed [1], but is now recomputed each time through the loop.

[1] That's the 0xBFD05AC910FF4C6C in the LLVM code in John's post
reinterpret(Float64, 0xBFD05AC910FF4C6C) == -0.2555411020268312 == sin(3.4)

On Monday, January 26, 2015 at 11:23:36 PM UTC-8, Mauro wrote:
>
> This is a performance regression, also for 0.3.5.  My timings for 0.3.5: 
>
>
> julia> @time [sumofsins1(100_000) for i in 1:100]; 
> elapsed time: 0.446675737 seconds (320109932 bytes allocated, 21.32% gc 
> time) 
>
> julia> @time [sumofsins2(100_000) for i in 1:100]; 
> elapsed time: 0.115537618 seconds (896 bytes allocated) 
>
>
> but for 0.2.1: 
> julia> @time [sumofsins1(100_000) for i in 1:100];   
> elapsed time: 0.347052858 seconds (320072020 bytes allocated) 
>
> julia> @time [sumofsins2(100_000) for i in 1:100];   
> elapsed time: 0.008610216 seconds (896 bytes allocated) 
>
>
> Can you check whether an issue for this has been filed and if you can't 
> find one file one? 
>
> On Tue, 2015-01-27 at 07:36, Kuba Roth <kuba...@gmail.com <javascript:>> 
> wrote: 
> > Hi there, 
> > Recently I run into this very interesting post: 
> > 
> http://www.johnmyleswhite.com/notebook/2013/12/06/writing-type-stable-code-in-julia/
>  
> > 
> > Surprisingly, when tested both examples against the latest 0.4 build - 
> the 
> > speed difference of the type-stable version is only 2-3 times faster 
> then 
> > unstable one. 
> > I wonder what is the source of such a huge disparity and what version of 
> > Julia was used? 
> > 
> > My timings: 
> > unstable: 0.425013212 seconds (305 MB allocated, 7.56% gc time in 14 
> pauses 
> > with 0 full sweep) 
> > stable: 0.14287404 seconds (896 bytes allocated) 
> > 
> > John's: 
> > unstable: 0.412261722 seconds (320002496 bytes allocated) 
> > stable: 0.008509995 seconds (896 bytes allocated)   
> > 
> > Thanks, 
> > kuba 
>
>

Reply via email to