-
Notifications
You must be signed in to change notification settings - Fork 240
Add an option to disable eager initialization of curl #601
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
Comments
See this issue for why the eager init constructor exists, for context: #333. The TL;DR is that it exists to help ensure that safety requirements of curl and OpenSSL are upheld so as to not invalidate our safe API wrapper. That safety requirement is essentially this:
Knowing that this is an incredibly difficult requirement to fulfill, the eager init ensures that this requirement is met safely and by default for most programs. I could see a crate feature to enable or disable this might be reasonable. Features are additive so normally I would say that this would have to be an opt-in feature that is enabled by However, for rustup's use-case, I'd have to ask if this actually solves rustup's problem. If rustup disables the eager init, can rustup meet this safety requirement? If it can't easily do so, then you'd need to call To put it differently, to take advantage of such an opt-out feature, you must know early in your |
That actually seems to have changed since #333: https://curl.se/libcurl/c/curl_global_init.html now mentions this requirement only if the "threadsafe" flag is not set. (My understanding is that this flag should be enabled in most situations). |
It would appear that
|
Would something along these lines work?
|
Initializing curl in turn initializes OpenSSL, which takes up a non-trivial amount of time (~30%) for
rustup which rustc
even though it is wasted effort when rustup doesn't need to download anything after all. Lazily initializing curl when it actually needs to download something would avoid paying the initialization penalty when not necessary.The text was updated successfully, but these errors were encountered: