I am running 400 simulations, based on ModelingToolkit, each 11h of real-time.
With Julia 1.9, launching Julia with:
julia --project -i -q -t 16
it takes 44 s (second run).
With Julia 1.10-rc1, launching Julia with:
julia --project -i -q -t 16 --gcthreads=8,1
it takes 25.3 s (second run).
This is a speed-up by a factor of 1.7 . Very nice!
CORRECTED:
The reason is two-fold:
single threaded execution had a speed-up by a factor of 1.1
multithreaded execution had a much bigger speed-up, mainly due to a reduction
of the GC time from 60% to 40%.
@ChrisRackauckas Has multithreading of ModelingTookit simulations changed with Julia 1.10? I am using the same model, but run it again and again with different parameters. Under which conditions can this be used with multi-threading?
To answer my own question: Multi-threading only works with MKL. But that could be a separate topic.
This is what my core loop looks like:
Δαs = se.Δα_max:-0.5:se.Δα_min
Δα_ests = se.Δα_max:-0.5:se.Δα_min
# we need a sorted dictionary for the results because the execution order
# of the threads is undefined
dict = SortedDict{Float64, Vector{Float64}}()
lk = ReentrantLock()
Threads.@threads for Δα0 in Δαs
println("Δα = $(Δα0)")
Eps = ep2alpha(se, Δα_ests; Δα0=Δα0)
lock(lk)
try
# writing to a dictionary is not thread safe, we need a lock here
dict[Δα0] = Eps
finally
unlock(lk)
end
end
Summary of performance improvements of Julia 1.10.0-rc1 compared to 1.9.3
Speed up single threaded:
Factor 1.1
Speed up multi threaded (16 threads):
Factor 1.7
Speed up startup time
Factor 1.6
(My startup time includes loading all packages, but also loading some configuration data). To get the full multithreaded speed advantage you must launch Julia with parameters similar to these: --gcthreads=8,1.