Skip to content

cutting down on allocations #21

Description

@anandijain

https://docs.julialang.org/en/v1/manual/profile/#Memory-allocation-analysis

for example take https://www.ebi.ac.uk/biomodels/BIOMD0000000469

julia> @benchmark SBML.readSBML(fn, doc -> begin
                   set_level_and_version(3, 2)(doc)
                   convert_simplify_math(doc)
               end)
BenchmarkTools.Trial: 1 sample with 1 evaluation.
 Single result which took 21.036 s (0.00% GC) to evaluate,
 with a memory estimate of 8.22 MiB, over 254217 allocations.

julia> @benchmark ODESystem(m)
BenchmarkTools.Trial: 1 sample with 1 evaluation.
 Single result which took 15.338 s (5.20% GC) to evaluate,
 with a memory estimate of 3.68 GiB, over 89488902 allocations.

We can see with these results that the vast majority of allocs are in constructing ODESystem. It also gets much much worse as model size increases. It is quite shocking to see ~4 GiB allocated for a 2MB file.

I'm pretty sure with just improving the code we can get 15 seconds down at least 2x. This will be very helpful for running tests against the biomodels dataset, which currently takes an incredible amount of time.

One issue is that there is an excessive amount of create_var and create_param. There should only be length(m.species) number of calls to create_var, and similarly for params and length(m.parameters) + length(m.compartments).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions