Skip to content

Performance drop in Julia 1.6 #1422

@shipengcheng1230

Description

@shipengcheng1230

Hi, recently I noticed that my simulation runs slower than before. Consider the following MWE:

using BenchmarkTools
using OrdinaryDiffEq
using Base.Threads
using Random

N = 512
Random.seed!(42)
u = rand(2N-1, N)
du = similar(u)

function foo(du, u, p, t)
    @threads for i  eachindex(u)
        du[i] = sin(cos(tan(exp(log(u[i] + 1)))))
    end
end

prob = ODEProblem{true}(foo, u, (0.0, 0.01));
@btime foo(du, u, nothing, 1.0);
@btime solve(prob, Tsit5());

I tested on a workstation with two Intel(R) Xeon(R) Gold 6136 CPU @ 3.00GHz (2 * 12 CPUs).

Julia 1.4.2
  12-threads
  4.248 ms (63 allocations: 8.59 KiB)
  457.320 ms (3781 allocations: 200.29 MiB)

  24-threads
  2.185 ms (123 allocations: 17.13 KiB)
  324.000 ms (7273 allocations: 200.77 MiB)

Julia 1.5.4
  12-threads
  4.166 ms (61 allocations: 8.80 KiB)
  444.515 ms (3650 allocations: 200.30 MiB)

  24-threads
  2.115 ms (121 allocations: 17.52 KiB)
  334.617 ms (7122 allocations: 200.79 MiB)

Julia 1.6.1
  12-threads
  3.896 ms (61 allocations: 5.42 KiB)
  727.287 ms (3721 allocations: 200.12 MiB)

  24-threads
  2.160 ms (121 allocations: 10.77 KiB)
  515.827 ms (7194 allocations: 200.42 MiB)

Despite that the benchmark of the ODE function call is no worse on Julia 1.6, the total solving time is actually much longer. I am not sure if it relates to some upstream issues. It seems there is some extra overhead besides the ODE function evaluation.

Thank you!

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