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

Use single curl multi handle to re-use connections #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jeroen
Copy link
Member

@jeroen jeroen commented Mar 2, 2024

This is a minimal proof of concept patch to test the performance implications of using a shared curl "multi-handle" to re-use http connections for multiple downloads to the same server (hence avoiding repeated TLS handshakes).

A more extensive patch, which includes cleaning up all connections when R quits, is available in #166

Quick benchmark:

options(repos=c(CRAN='https://cloud.r-project.org'))
x <- available.packages()
pkgs <- row.names(x)[1:100]
system.time(download.packages(pkgs, tempdir(), available = x))

Before:

   user  system elapsed
 15.212   1.113  24.098

After:

   user  system elapsed
  0.327   0.521   1.661

@sgsokol
Copy link

sgsokol commented Mar 4, 2024

Nice update.
However, one point remains unclear for me: as curl_multi_cleanup(c->mhnd) is now commented out, how and when c->mhnd will be cleaned up?

@jeroen
Copy link
Member Author

jeroen commented Mar 4, 2024

This is just to show the proof of concept. We would probably need to call curl_multi_cleanup when R exits.

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