You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
I'm hunting down unwanted allocations in my scripts, and it seems that one of them actually comes from within StochasticDiffEq.jl. It is triggered when a I step a stochastic integrator (I use SOSRA2() at the moment, but I've seen it for other ones as well). I'm using in-place, non-allocating derivative functions, and indeed, when stepping an ODE integrator like Tsit5(), I see no allocations.
In the simulations that I want to run, I expect to take many many timesteps (~1e8), so a stray allocation that happens every step takes up a lot of memory and gc time. With my limited Julia experience (less than three weeks), I've tried my best to investigate the issue! My findings are included below.
I'm more than happy to try and fix the issue myself, but my Julia-fu is not up to spec yet, so any pointers are welcome :).
Example to reproduce
I have a script called test_alloc.jl with the following contents:
The problem also pops up when I compare solveing the ODE vs solveing the SDE:
julia>@timesolve(ode_problem, Tsit5())
0.032882 seconds (46 allocations:4.812 KiB)
retcode: Success
Interpolation:1st order linear
t:2-element Array{Float64,1}:0.010000.0
u:2-element Array{Array{Float64,1},1}:
[1.0, 0.0]
[-0.006419164047044267, 0.002051192765260945]
julia>@timesolve(sde_problem, SOSRA2())
0.050645 seconds (159.23 k allocations:2.435 MiB)
retcode: Success
Interpolation:1st order linear
t:2-element Array{Float64,1}:0.010000.0
u:2-element Array{Array{Float64,1},1}:
[1.0, 0.0]
[8.572151454186196, 14.606344527329984]
julia> num
159155
We see that the number of expected iterations (adaptive timestepping is off) is very close to the number of allocations in the SDE case.
My investigation
To pinpoint the problem, I've been tracking memory allocations with julia --track-allocation=user. After analysis with Coverage.analyze_malloc on my package directory, it seems that the only allocation is made in src/iterator_interface.jl:11:
Problem
I'm hunting down unwanted allocations in my scripts, and it seems that one of them actually comes from within StochasticDiffEq.jl. It is triggered when a I step a stochastic integrator (I use SOSRA2() at the moment, but I've seen it for other ones as well). I'm using in-place, non-allocating derivative functions, and indeed, when stepping an ODE integrator like Tsit5(), I see no allocations.
In the simulations that I want to run, I expect to take many many timesteps (~1e8), so a stray allocation that happens every step takes up a lot of memory and gc time. With my limited Julia experience (less than three weeks), I've tried my best to investigate the issue! My findings are included below.
I'm more than happy to try and fix the issue myself, but my Julia-fu is not up to spec yet, so any pointers are welcome :).
Example to reproduce
I have a script called
test_alloc.jl
with the following contents:I run the following commands in the REPL to show the issue:
The problem also pops up when I compare
solve
ing the ODE vssolve
ing the SDE:We see that the
num
ber of expected iterations (adaptive timestepping is off) is very close to the number of allocations in the SDE case.My investigation
To pinpoint the problem, I've been tracking memory allocations with
julia --track-allocation=user
. After analysis withCoverage.analyze_malloc
on my package directory, it seems that the only allocation is made insrc/iterator_interface.jl:11
:StochasticDiffEq.jl/src/iterator_interface.jl
Line 11 in b6015ae
The
.mem
file that is left after doing a single step onsde_integrator
with allocation tracking on looks like this:The
.mem
file that corresponds tosrc/perform_step/sra.jl
, whereperform_step!
is located, contains only 0's in the allocation column.Version information
Julia version information:
StochasticDiffEq: version
6.32.1
The text was updated successfully, but these errors were encountered: