-
Notifications
You must be signed in to change notification settings - Fork 3
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
.rang_query_sysreqs
is kind of slow with Github packages
#40
Comments
R> system.time(rang::resolve("schochastics/rtoot"))
user system elapsed
7.894 0.828 47.624
R> system.time(rang::resolve("rtoot"))
user system elapsed
0.233 0.001 1.333 That's actually quite substantial! Have you identified a bottleneck? |
x <- resolve("schochastics/rtoot", get_sysreqs = FALSE)
system.time(.rang_query_sysreqs(x))
## user system elapsed
## 3.601 0.371 30.717 y <- resolve("rtoot", get_sysreqs = FALSE)
system.time(.rang_query_sysreqs(y))
## user system elapsed
## 0.069 0.004 0.677 |
system.time(.system_requirements_github("schochastics/rtoot", os = "ubuntu-20.04"))
## user system elapsed
## 0.205 0.008 1.339 @schochastics The exact reason is that all CRAN packages are queried one by one when there is a Github package, rather than in one query as in the all-CRAN case. |
@chainsawriot finally reached that conclusion too now. I think we could speed it up by grouping the refs? .query_sysreqs_safe_grps <- function(targets, os = "ubuntu-20.04") {
grps <- list("cran" = c(), "github" = c())
refs <- vapply(targets, .parse_pkgref, return_handle = FALSE, character(1))
for (i in names(grps)) {
grps[[i]] <- targets[refs == i]
}
tryCatch({
cran_handles <- vapply(grps[["cran"]], .parse_pkgref, character(1), return_handle = TRUE, USE.NAMES = FALSE)
output <- .system_requirements_cran(handle = cran_handles, os = os)
}, error = function(e) {
output <- .query_sysreqs_safe(targets = targets, os = os)
})
for (pkg in grps[["github"]]) {
output <- c(output, .system_requirements_gh(.parse_pkgref(pkg), os))
}
return(unique(output))
}
targets <- c("github::schochastics/rtoot", "cran::tibble", "cran::vctrs",
"cran::glue", "cran::cli", "cran::rlang", "cran::pkgconfig",
"cran::pillar", "cran::utf8", "cran::magrittr", "cran::lifecycle",
"cran::fansi", "cran::jsonlite", "cran::httr", "cran::R6", "cran::openssl",
"cran::askpass", "cran::sys", "cran::mime", "cran::curl", "cran::dplyr",
"cran::tidyselect", "cran::withr", "cran::generics", "cran::clipr")
system.time(a <- .query_sysreqs_safe(targets))
user system elapsed
3.067 0.451 20.978
system.time(b <- .query_sysreqs_safe_grps(targets))
user system elapsed
0.406 0.021 2.442
sort(a)==sort(b)
[1] TRUE TRUE TRUE TRUE TRUE The function can be easily adapted to include other refs. |
system.time(rang::resolve("schochastics/rtoot"))
## user system elapsed
## 1.181 0.018 9.084 Pre system.time(rang::resolve("schochastics/rtoot"))
user system elapsed
4.419 0.387 38.502 |
perfect :) |
https://github.com/chainsawriot/rang/blob/22b30f31f302b75c691c77de713bd1b8461b8f72/R/resolve.R#L338-L341
Maybe a better approach is to separate Github and CRAN packages and do the query, rather than switch to safe when there is just one Github package (usually).
The text was updated successfully, but these errors were encountered: