Indexing a large matrix is MUCH slower (~ 150x) slower in 0.5 (and 0.6) than 0.4.7

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Indexing a large matrix is MUCH slower (~ 150x) slower in 0.5 (and 0.6) than 0.4.7

Ian Butterworth
I'm not sure of the etiquette, but I'm cross-posting this from stackoverflow as it seems like quite a significant issue...

As an example:

x = rand(10,10,100,4,4,1000)   #Dummy array

tic()
r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5))
toc()

Julia 0.5.0 -> elapsed time: 176.357068283 seconds

Julia 0.4.7 -> elapsed time: 1.19991952 seconds



I know this isn't really good practice, and I'm looking into using `view` but it's quite a bit performance decrease, so I thought I'd raise it.


http://stackoverflow.com/questions/40351485/why-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7
Reply | Threaded
Open this post in threaded view
|

Re: Indexing a large matrix is MUCH slower (~ 150x) slower in 0.5 (and 0.6) than 0.4.7

Yichao Yu
On Mon, Oct 31, 2016 at 6:34 PM, Ian Butterworth
<[hidden email]> wrote:

> I'm not sure of the etiquette, but I'm cross-posting this from stackoverflow
> as it seems like quite a significant issue...
>
> As an example:
>
> x = rand(10,10,100,4,4,1000)   #Dummy array
>
> tic()
> r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5))
> toc()
>
> Julia 0.5.0 -> elapsed time: 176.357068283 seconds
>
> Julia 0.4.7 -> elapsed time: 1.19991952 seconds
>
>
>
> I know this isn't really good practice, and I'm looking into using `view`
> but it's quite a bit performance decrease, so I thought I'd raise it.
>

AFAICT it's all compilation time.

>
> http://stackoverflow.com/questions/40351485/why-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7
Reply | Threaded
Open this post in threaded view
|

Re: Indexing a large matrix is MUCH slower (~ 150x) slower in 0.5 (and 0.6) than 0.4.7

Ian Butterworth
I don't think so.. It happens on repeat function runs. I also updated to use benchmarktools.jl 
Even though, it takes so long (> 10 mins) on 0.5.0 I've only been patient enough for it to complete once...


using BenchmarkTools
function testf(x)
    r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5));
end

x = rand(10,10,100,4,4,1000)   #Dummy array
@benchmark testf(x)

In 0.5.0 I get the following (with huge memory usage):

BenchmarkTools.Trial: 
  samples:          1
  evals/sample:     1
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  23.36 gb
  allocs estimate:  1043200022
  minimum time:     177.94 s (1.34% GC)
  median time:      177.94 s (1.34% GC)
  mean time:        177.94 s (1.34% GC)
  maximum time:     177.94 s (1.34% GC)

In 0.4.7 I get:

BenchmarkTools.Trial: 
  samples:          11
  evals/sample:     1
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  727.55 mb
  allocs estimate:  79
  minimum time:     425.82 ms (0.06% GC)
  median time:      485.95 ms (11.31% GC)
  mean time:        482.67 ms (10.37% GC)
  maximum time:     503.27 ms (11.22% GC)



On Monday, 31 October 2016 19:07:28 UTC-4, Yichao Yu wrote:
On Mon, Oct 31, 2016 at 6:34 PM, Ian Butterworth
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="h5SxadBkAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">i.r.but...@...> wrote:

> I'm not sure of the etiquette, but I'm cross-posting this from stackoverflow
> as it seems like quite a significant issue...
>
> As an example:
>
> x = rand(10,10,100,4,4,1000)   #Dummy array
>
> tic()
> r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5))
> toc()
>
> Julia 0.5.0 -> elapsed time: 176.357068283 seconds
>
> Julia 0.4.7 -> elapsed time: 1.19991952 seconds
>
>
>
> I know this isn't really good practice, and I'm looking into using `view`
> but it's quite a bit performance decrease, so I thought I'd raise it.
>

AFAICT it's all compilation time.

>
> <a href="http://stackoverflow.com/questions/40351485/why-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F40351485%2Fwhy-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_574GqrXsRBcS2UOETV5CWq56ww&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F40351485%2Fwhy-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_574GqrXsRBcS2UOETV5CWq56ww&#39;;return true;">http://stackoverflow.com/questions/40351485/why-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7
Reply | Threaded
Open this post in threaded view
|

Re: Indexing a large matrix is MUCH slower (~ 150x) slower in 0.5 (and 0.6) than 0.4.7

Yichao Yu
On Mon, Oct 31, 2016 at 7:49 PM, Ian Butterworth
<[hidden email]> wrote:
> I don't think so.. It happens on repeat function runs. I also updated to use
> benchmarktools.jl
> Even though, it takes so long (> 10 mins) on 0.5.0 I've only been patient
> enough for it to complete once...

As mentioned in the issue
(https://github.com/JuliaLang/julia/issues/19174#issuecomment-257456875)
I only tested on master since you said it happens there too. The PR
that probably fixed it was merged 7 days ago so you might want to try
a newer nightly. You can also try to apply the patch on the 0.5 branch
yourself although supposedly 0.5.1 should be prepared last weekend.

P.S. please cross link to the issue if you open one.

>
>
> using BenchmarkTools
> function testf(x)
>     r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5));
> end
>
> x = rand(10,10,100,4,4,1000)   #Dummy array
> @benchmark testf(x)
>
> In 0.5.0 I get the following (with huge memory usage):
>
> BenchmarkTools.Trial:
>   samples:          1
>   evals/sample:     1
>   time tolerance:   5.00%
>   memory tolerance: 1.00%
>   memory estimate:  23.36 gb
>   allocs estimate:  1043200022
>   minimum time:     177.94 s (1.34% GC)
>   median time:      177.94 s (1.34% GC)
>   mean time:        177.94 s (1.34% GC)
>   maximum time:     177.94 s (1.34% GC)
>
> In 0.4.7 I get:
>
> BenchmarkTools.Trial:
>   samples:          11
>   evals/sample:     1
>   time tolerance:   5.00%
>   memory tolerance: 1.00%
>   memory estimate:  727.55 mb
>   allocs estimate:  79
>   minimum time:     425.82 ms (0.06% GC)
>   median time:      485.95 ms (11.31% GC)
>   mean time:        482.67 ms (10.37% GC)
>   maximum time:     503.27 ms (11.22% GC)
>
>
>
>
> On Monday, 31 October 2016 19:07:28 UTC-4, Yichao Yu wrote:
>>
>> On Mon, Oct 31, 2016 at 6:34 PM, Ian Butterworth
>> <[hidden email]> wrote:
>> > I'm not sure of the etiquette, but I'm cross-posting this from
>> > stackoverflow
>> > as it seems like quite a significant issue...
>> >
>> > As an example:
>> >
>> > x = rand(10,10,100,4,4,1000)   #Dummy array
>> >
>> > tic()
>> > r = squeeze(mean(x[:,:,1:80,:,:,56:800],(1,2,3,4,5)),(1,2,3,4,5))
>> > toc()
>> >
>> > Julia 0.5.0 -> elapsed time: 176.357068283 seconds
>> >
>> > Julia 0.4.7 -> elapsed time: 1.19991952 seconds
>> >
>> >
>> >
>> > I know this isn't really good practice, and I'm looking into using
>> > `view`
>> > but it's quite a bit performance decrease, so I thought I'd raise it.
>> >
>>
>> AFAICT it's all compilation time.
>>
>> >
>> >
>> > http://stackoverflow.com/questions/40351485/why-is-indexing-a-large-matrix-170x-slower-slower-in-julia-0-5-0-than-0-4-7