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 for faster TTFX #174

Closed
wants to merge 3 commits into from

Conversation

Tortar
Copy link

@Tortar Tortar commented Sep 22, 2024

This has not a big impact but it works, e.g. now

julia> using Accessors

julia> struct Q k::Float64 end

julia> q = Q(1.0)
Q(1.0)

julia> @time @eval f(q) = @set q.k = 2.0;
  0.007665 seconds (2.08 k allocations: 161.078 KiB, 91.12% compilation time) # this pr
  0.021409 seconds (14.66 k allocations: 1023.523 KiB, 96.41% compilation time) # master

julia> @time @eval f(q);
  0.032977 seconds (23.63 k allocations: 1.616 MiB, 99.53% compilation time) # this pr
  0.032714 seconds (23.67 k allocations: 1.628 MiB, 99.52% compilation time) # master

Addresses partially #173

@Tortar
Copy link
Author

Tortar commented Sep 22, 2024

I guess that the time spent on function definitions is anyway happening at precompile time inside packages though, but the precompile statements in this pr are practically zero cost so I think that they could be added nonetheless.

@Tortar
Copy link
Author

Tortar commented Sep 26, 2024

hi @aplavin what do you think of this PR?

@aplavin
Copy link
Member

aplavin commented Sep 26, 2024

Idk, we can add this I guess, what do you think @jw3126?
The gain is just ~15 ms, right? So Accessors is already quite good in ttfx :)

@jw3126
Copy link
Member

jw3126 commented Sep 26, 2024

Mhh the gain is minor, I wonder if it is worth the additional dependency. How does this impact precompile time?

@Tortar
Copy link
Author

Tortar commented Sep 26, 2024

almost the same for precompile times (maybe 0.1 second more), but actually the additional dependency impacts a bit the importing:

julia> @time using Accessors
  0.039866 seconds (36.46 k allocations: 4.357 MiB, 10.73% compilation time) # this pr
  0.031610 seconds (25.88 k allocations: 3.539 MiB, 13.73% compilation time) # master

julia> struct Q k::Float64 end

julia> q = Q(1.0)
Q(1.0)

julia> @time @eval f(q) = @set q.k = 2.0;
  0.008145 seconds (2.08 k allocations: 144.578 KiB, 88.98% compilation time) # this pr
  0.022843 seconds (14.67 k allocations: 1.015 MiB, 95.64% compilation time) # master

julia> @time f(q);
  0.034677 seconds (23.59 k allocations: 1.614 MiB, 99.95% compilation time) # this pr
  0.034935 seconds (23.64 k allocations: 1.632 MiB, 99.93% compilation time) # master

so I close for now, let me know if you think it's still worth it

@Tortar Tortar closed this Sep 26, 2024
@jw3126
Copy link
Member

jw3126 commented Sep 26, 2024

Thanks @Tortar for experimenting with this.

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

Successfully merging this pull request may close these issues.

3 participants