-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
We use the : throughout as a sentinel for "all dimensions." We do not typically call it as a function in this use case, even though Colon <: Function.
However, I think this means that it's getting the specialization rules for Functions and thus no longer specializing as it was previously expected to. In particular, this is introducing type-instabilities that are slowing down basic functions like mean:
#### master (b72e191ea9) ####
julia> using Statistics, BenchmarkTools
julia> @benchmark mean($(zeros(10)))
BenchmarkTools.Trial:
memory estimate: 16 bytes
allocs estimate: 1
--------------
minimum time: 11.117 ns (0.00% GC)
median time: 11.449 ns (0.00% GC)
mean time: 13.226 ns (1.25% GC)
maximum time: 635.868 ns (96.44% GC)
--------------
samples: 10000
evals/sample: 998
#### 1.4.0 ####
julia> @benchmark mean($(zeros(10)))
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 4.453 ns (0.00% GC)
median time: 5.994 ns (0.00% GC)
mean time: 5.884 ns (0.00% GC)
maximum time: 37.309 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 1000(I originally thought this was a Cthulhu bug, but it does appear that @descend is properly showing me how Julia is specializing this: JuliaDebug/Cthulhu.jl#77)
Metadata
Metadata
Assignees
Labels
No labels