The Dict{K,V} notation means its keys have type K and its values have type V. In your slow example, Dict{Int64,Any}, the keys are Int64 but there is no available type information about the values (hence they are recorded as the Any type). It may perform faster if, instead of Any, the values are all of the same concrete type and this is known to the compiler. Notice that’s what happened in your fast-performing example Dict{Int64,Float64}, all the values were guaranteed to be of the same type Float64. This situation is called “strictly-typed”, unlike the case where values have Any type. Having strict type information can allow Julia to make significant optimisations.
The |Dict{K,V}| notation means its keys have type |K| and its values
have type |V|. In your slow example, |Dict{Int64,Any}|, the keys are
|Int64| but there is no available type information about the values
(hence they are recorded as the |Any| type). It may perform faster if,
instead of |Any|, the values are all of the same concrete type /and
this is known to the compiler/. Notice that’s what happened in your
fast-performing example |Dict{Int64,Float64}|, all the values were
guaranteed to be of the same type |Float64|. This situation is called
“strictly-typed”, unlike the case where values have |Any| type. Having
strict type information can allow Julia to make significant optimisations.
W dniu 2017-01-21 21:18, Christopher Rackauckas pisze: What happens if
you make that same dictionary be strictly typed? Sorry, “strictly
typed” I understand , What do You mean ? Paul
I ran into a similar problem with JLD, it took over 20 minutes to load my data. I just wanted to leave this here if anybody runs into something similar, with JLD2 it only took 50 seconds to load the same data.
using JLD2
@time load("outfiles/aggregated_results.jld2")
49.773390 seconds (9.72 M allocations: 2.651 GiB, 7.02% gc time)
Dict{String,Any} with 7 entries: