Julia 1.9 seems to be slower than 1.8 for some comprehension and splatting code. Here’s a minimal working example. I’ve written functions for doubling the values of a dictionary, including a “normal” version involving a Dict comprehension and a contrived “crazy” version with both comprehension and splatting. For both versions, Julia-1.9.0-rc2 is slower than Julia 1.8.5 on my Linux laptop.
The benchmarking code is below:
# DoubleDict.jl
using BenchmarkTools
function double_dict_normal(a::Dict)
Dict(k => v * 2 for (k, v) in a)
end
function double_dict_crazy(a::Dict)
Dict(map(i -> i[1] => i[2] * 2, [a...]))
end
d1 = Dict(i => i+1 for i in 1:10^7)
@btime double_dict_normal(d1);
@btime double_dict_crazy(d1);
The result from Julia-1.8.5 is
290.535 ms (7 allocations: 272.00 MiB)
1.772 s (29999742 allocations: 1.54 GiB)
The result from Julia-1.9.0-rc2 is
320.734 ms (7 allocations: 272.00 MiB)
2.014 s (29999742 allocations: 1.54 GiB)
What should I take away from this? Does it mean I should pay more attention to avoiding allocation and type instability when using Julia 1.9?