Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompile some functions which back up macros #173

Open
Tortar opened this issue Sep 22, 2024 · 1 comment
Open

Precompile some functions which back up macros #173

Tortar opened this issue Sep 22, 2024 · 1 comment

Comments

@Tortar
Copy link

Tortar commented Sep 22, 2024

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

@aplavin
Copy link
Member

aplavin commented Sep 22, 2024

I'm not too familiar with optimal precompilation setups, but personally won't be against a PR that provides measurable improvements to TTFX. Please, just ensure that precompile times don't become unreasonably long :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants