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

Parallel download with R's native libcurl #2099

Open
noamross opened this issue Feb 26, 2025 · 2 comments
Open

Parallel download with R's native libcurl #2099

noamross opened this issue Feb 26, 2025 · 2 comments

Comments

@noamross
Copy link

R-devel (4.5) uses internal libcurl's simultaneous downloads capability to install many packages very quickly with install.packages, similar to pak. Will renv be able to take advantage of this to parallelize package downloads?

@kevinushey
Copy link
Collaborator

Will this functionality be extended to download.file()? It would take a somewhat substantial amount of work, but it could be done.

@noamross
Copy link
Author

noamross commented Mar 5, 2025

It appears that it actually occurs in download.file() by default with method = "libcurl". From ?download.file in 4.5.0:

When method "libcurl" is used, there is support for simultaneous downloads, so url and destfile can be character vectors of the same length greater than one (but the method has to be specified explicitly and not via "auto"). For a single URL and quiet = FALSE a progress bar is shown in interactive use.
...
When simultaneously downloading two or more files (see the url argument) and download of at least one file succeeds, 0 is returned with attribute retvals, which provides an integer vector of the same length as url with a result code for each file (0 for success and non-zero for failure).

In testing, all files appear on disk simultaneously on disk, though are finished at different times:

download.file(
  c("https://link.testfile.org/PDF100MB",
    "https://link.testfile.org/PDF100MB",
    "https://link.testfile.org/PDF100MB",
    "https://link.testfile.org/PDF100MB"),
  c("a.pdf", "b.pdf", "c.pdf", "d.pdf"),
  method = "libcurl"
)

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