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

Add a couple of precompiles #21

Merged
merged 1 commit into from
Dec 27, 2020
Merged

Add a couple of precompiles #21

merged 1 commit into from
Dec 27, 2020

Conversation

timholy
Copy link
Member

@timholy timholy commented Dec 26, 2020

No description provided.

@yurivish
Copy link
Contributor

yurivish commented Dec 26, 2020

Hi Tim! I'm wondering – what does executing these precompile statements get you beyond what you'd get from calling the functions for the first time, which (IIUC) would compile them at the time of first use?

@timholy
Copy link
Member Author

timholy commented Dec 26, 2020

Lower latency on first use. I didn't measure here, but for reference: JuliaImages/ImageFiltering.jl#201.

I'm not sure the ones here "work," though; there are a few cases that don't, for reasons the community has yet to fully understand. (E.g., JuliaLang/julia#38983.) But eventually they will start working, so it's probably not bad to have them.

@yurivish
Copy link
Contributor

Thanks for the links! Just to make sure I understand, the tradeoff here is to incur the latency cost every time the package is loaded, regardless of whether any of these functions is used during the session, rather than incurring it at the first point of use? I haven’t been following the recent compiler improvements but I know there are varying levels of precompilation.

I can see why this might be preferable since one can go and make coffee or someone while the “using” statement is being executed...

@timholy
Copy link
Member Author

timholy commented Dec 26, 2020

the tradeoff here is to incur the latency cost every time the package is loaded,

No, the cost of precompile is paid just when it's precompiled. I.e., when the package is being built. (Precompiling SignedDistanceFields...) There's a small extra penalty to load the type-inferred MethodInstances but that's much smaller than needing to run inference every time you use the methods.

In other words, this is Julia's closest equivalent to make in the C/C++ world, where once you've compiled the application it's fast to launch.

@yurivish
Copy link
Contributor

Ah, got it. Thanks!

@yurivish yurivish merged commit 8fe7fa2 into master Dec 27, 2020
@timholy timholy deleted the teh/ttfp branch December 27, 2020 16:05
@timholy
Copy link
Member Author

timholy commented Dec 27, 2020

Your question was a good one, though; I remember thinking the same thing. It was also timely, as it prompted me to explain this specific point in JuliaLang/www.julialang.org#1111. (In the preview, scroll down to "It might be natural to wonder...")

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.

2 participants