Skip to content

Conversation

@JeffBezanson
Copy link
Member

fixes #27774

@JeffBezanson JeffBezanson added arrays [a, r, r, a, y, s] deprecation This change introduces or involves a deprecation labels Jun 27, 2018
return map(f,A)
end
if !isa(dims, AbstractVector)
dims = [dims...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a new instability here, but this is already an unstable "outer" function with a stable kernel, so I was hoping it wouldn't affect things too much. Unfortunately it seems to have quite a large effect (6-10x) in my cursory tests:

# Commit 948b088f17 (3 days old master)
julia> g(f, A, dims) =  mapslices(f, A, dims)
g (generic function with 1 method)

julia> A = rand(500,500);

julia> @benchmark g(sum, $A, 1)
BenchmarkTools.Trial:
  memory estimate:  111.84 KiB
  allocs estimate:  4040
  --------------
  minimum time:     713.670 μs (0.00% GC)
  median time:      729.114 μs (0.00% GC)
  mean time:        750.090 μs (2.53% GC)
  maximum time:     51.052 ms (98.37% GC)
  --------------
  samples:          6637
  evals/sample:     1

# jb/mapslicesdims/d184a46949 (fork: 1 commits, 0 days)
julia> g(f, A, dims) =  mapslices(f, A, dims=dims)
g (generic function with 1 method)

julia> A = rand(500,500);

julia> @benchmark g(sum, $A, 1)
BenchmarkTools.Trial:
  memory estimate:  345.75 KiB
  allocs estimate:  15517
  --------------
  minimum time:     4.575 ms (0.00% GC)
  median time:      4.606 ms (0.00% GC)
  mean time:        4.718 ms (1.90% GC)
  maximum time:     55.249 ms (91.39% GC)
  --------------
  samples:          1059
  evals/sample:     1

@JeffBezanson
Copy link
Member Author

I did a bisect, and it turns out that regression was caused by #27417.

@mbauman mbauman merged commit 440a1a5 into master Jun 28, 2018
@mbauman mbauman deleted the jb/mapslicesdims branch June 28, 2018 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays [a, r, r, a, y, s] deprecation This change introduces or involves a deprecation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mapslices' dim argument should be a keyword

3 participants