Skip to content

Precompile some functions which back up macros #173

Description

@ameligrana

I wonder if we could precompile some functions to reduce first time latency calls, e.g. I think we can go from f timings to g timings in this example scenario:

julia> struct A
           x::Int
       end

julia> struct B
           y::Float64
       end

julia> using Accessors

julia> f(s) = @set s.x = 3
f (generic function with 1 method)

julia> g(s) = @set s.y = 3.0
g (generic function with 1 method)

julia> s = A(1)
A(1)

julia> @time @eval f(s)
  0.160497 seconds (98.85 k allocations: 7.246 MiB, 99.89% compilation time)
A(3)

julia> s = B(1.0)
B(1.0)

julia> @time @eval g(s)
  0.013224 seconds (39.48 k allocations: 2.671 MiB, 98.70% compilation time)
B(3.0)

which is more than 10 times better

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