Here's a simple example:
function g(f, v)
foreach(f, v)
foreach(f, v)
end
using BenchmarkTools
@btime g(identity, foo) setup=(foo = rand(Int, 100))
On v0.6.1: 127.299 ns (0 allocations: 0 bytes)
On nightly (0.7.0-DEV.3234
): 6.770 μs (400 allocations: 6.25 KiB)
Removing the second call to foreach
fixes the performance issue. Replacing the foreach
call with for x in v; f(x); end
also fixes the issue.
versioninfo
for 0.6.1 is:
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)
versioninfo
for 0.7.0-DEV.3234 is:
Julia Version 0.7.0-DEV.3234
Commit 2cc82d2 (2018-01-02 11:44 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin15.6.0)
CPU: Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)
Environment:
I just checked today's nightly, and this issue is resolved. In fact, the code is about 3X faster on 0.7.0-beta2.43 than 0.6.3!
Most helpful comment
I just checked today's nightly, and this issue is resolved. In fact, the code is about 3X faster on 0.7.0-beta2.43 than 0.6.3!