-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
.. becomes slow and allocates for 4 or more dimensions #20
Comments
Odd. Yeah, maybe something needs to make use of |
Just to clarify: the slowness is not dependent on the number of array dimensions but on the number of ellipsis dimensions, i.e., it becomes slow if more than 3 dimensions are "slurped" by the julia> u = rand(1, 2, 3, 4, 5, 6, 7);
julia> @benchmark view($u, $1, $:, $.., $:, $:) # this is fast, as `..` only slurps 3 dimensions (3-5)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 4.020 ns (0.00% GC)
median time: 4.866 ns (0.00% GC)
mean time: 4.997 ns (0.00% GC)
maximum time: 37.419 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 1000
julia> @benchmark view($u, $1, $:, $..,$:) # that's again slow with `..` replacing 4 dimensions (3-6)
BenchmarkTools.Trial:
memory estimate: 1.53 KiB
allocs estimate: 66
--------------
minimum time: 3.955 μs (0.00% GC)
median time: 5.232 μs (0.00% GC)
mean time: 5.570 μs (2.66% GC)
maximum time: 827.886 μs (98.18% GC)
--------------
samples: 10000
evals/sample: 7 |
Yes, it's hit whenever the splat case is hit: https://github.com/ChrisRackauckas/EllipsisNotation.jl/blob/master/src/EllipsisNotation.jl#L14 I wonder if it needs to be made fully recursive in order to make the compiler fully specialize it, or whether it needs an |
Without really knowing what's going on, I think the line you quoted is not the (only) culprit: I can construct a case where the respective julia> u = rand(1, 2, 3, 4);
julia> @benchmark view($u, $1, $:, ..)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 3.461 ns (0.00% GC)
median time: 3.982 ns (0.00% GC)
mean time: 4.327 ns (0.00% GC)
maximum time: 37.940 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 1000
julia> @benchmark view($u, $1, ..)
BenchmarkTools.Trial:
memory estimate: 800 bytes
allocs estimate: 35
--------------
minimum time: 2.067 μs (0.00% GC)
median time: 2.307 μs (0.00% GC)
mean time: 2.462 μs (0.85% GC)
maximum time: 212.839 μs (98.22% GC)
--------------
samples: 10000
evals/sample: 9 By my count, both versions only use |
A lot of time seems to be spent in
Is there some inlining/tuple-magic to make
..
fast for arrays with four or more dimensions?The text was updated successfully, but these errors were encountered: