Skip to content

Allocates when precompiled #35972

Closed

Description

If I make a package M with this content of src/M.jl:

module M
f(x) = x > 0 ? cbrt(x) : 0.0
precompile(f, (Float64,))
end

and run

using M, BenchmarkTools
x1 = fill(0.0, 1000000);
x2 = fill(1.0, 1000000);
@btime M.f.($x1);
@btime M.f.($x2);

the result is

  842.301 μs (2 allocations: 7.63 MiB)
  20.586 ms (2000002 allocations: 38.15 MiB)

Without precompile(f, (Float64,)) the excessive allocations go away.

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions