-
Notifications
You must be signed in to change notification settings - Fork 154
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 faster retrieval of remote information for GitHub remotes #142
Conversation
@gaborcsardi My main question with this is the |
Codecov Report
@@ Coverage Diff @@
## master #142 +/- ##
=========================================
Coverage ? 86.86%
=========================================
Files ? 29
Lines ? 1614
Branches ? 0
=========================================
Hits ? 1402
Misses ? 212
Partials ? 0
Continue to review full report at Codecov.
|
So, the thing is, in pkgdepends (and co.) if the package name is not the same as the repo name, you need to include the package name in the remote name. It looks like this: https://github.com/r-lib/pkgdepends/blob/ed31a93b514c023f80ba617dedc2672f837d8271/tests/testthat/test-parse-remotes.R#L167-L170 We could maybe just include this in remotes as well? Maybe together with your heuristic, so there won't be too much breakage? |
Yeah that sounds good to me! |
Ok I think this is ready for review now, we now support |
@gaborcsardi Any additional comments on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
What happens is we assume some package name based on the local name, but it is actually wrong?
R/github.R
Outdated
} else { | ||
tmp <- tempfile() | ||
on.exit(unlink(tmp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think add = TRUE
is good practice in general.
R/github.R
Outdated
rawToChar(res$content) | ||
} else { | ||
tmp <- tempfile() | ||
on.exit(unlink(tmp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add = TRUE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need add = TRUE
if there is another on.exit()
call in the same scope no? I guess add = TRUE
unconditionally is safer, I can add it.
@@ -41,33 +39,27 @@ | |||
#' install_github("hadley/private", auth_token = "abc") | |||
#' | |||
#' } | |||
install_github <- function(repo, username = NULL, | |||
install_github <- function(repo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the username
argument should be the NEWS, I think.
|
||
params | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this all just the pkgdepends code? Or new code? Dont' mind, just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is code from remotes, I just moved it out of install-git.r
to a separate file to make testing it separately easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the bigger diff because of this :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, np.
I think the worst that could happen if we assume the wrong name is the local sha would be from the wrong package, so the package would be re-installed when it may not have had to be. Git's SHA1s should prevent spurious collisions between the wrong packages even if we guess the name wrong and lookup the local sha from the wrong package, so I believe we should never get a false negative and fail to install something when we should. |
So this is all good now, I think, right? |
`remote_package_name.github_remote` and `remote_sha.github_remote` will lookup package name locally if possible and use faster REST APIs if the curl package is installed. This makes the remote lookup about 7-10x faster when the package to be installed has not changed since the last install. pkgload::load_all("~/p/remotes") remote <- github_remote("r-lib/devtools") bnch <- bench::press( use_curl = c(FALSE, TRUE), use_local = c(FALSE, TRUE), bench::mark( get_shas = { package_name <- remote_package_name(remote, use_local = use_local, use_curl = use_curl) local_sha <- local_sha(package_name) remote_sha <- remote_sha(remote, local_sha, use_curl = use_curl) }, iterations = 3, filter_gc = FALSE ) ) #> Running with: #> use_curl use_local #> 1 FALSE FALSE #> 2 TRUE FALSE #> 3 FALSE TRUE #> 4 TRUE TRUE bnch[c(2:10)] #> # A tibble: 4 x 9 #> use_curl use_local min mean median max `itr/sec` mem_alloc #> <lgl> <lgl> <bch:t> <bch:t> <bch:t> <bch> <dbl> <bch:byt> #> 1 FALSE FALSE 563.8ms 606.8ms 586.1ms 670ms 1.65 4.65MB #> 2 TRUE FALSE 160.9ms 273.5ms 165.6ms 494ms 3.66 206.08KB #> 3 FALSE TRUE 269.7ms 273.1ms 269.9ms 280ms 3.66 19.37KB #> 4 TRUE TRUE 74.1ms 86.5ms 84.7ms 101ms 11.6 19.12KB #> # ... with 1 more variable: n_gc <dbl> summary(bnch, relative = TRUE, filter_gc = FALSE)[c(2:10)] #> # A tibble: 4 x 9 #> use_curl use_local min mean median max `itr/sec` mem_alloc n_gc #> <lgl> <lgl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 FALSE FALSE 7.61 7.01 6.92 6.65 1 249. Inf #> 2 TRUE FALSE 2.17 3.16 1.96 4.90 2.22 10.8 NaN #> 3 FALSE TRUE 3.64 3.16 3.19 2.78 2.22 1.01 NaN #> 4 TRUE TRUE 1 1 1 1 7.01 1 NaN
Thank you for the review! |
remote_package_name.github_remote
andremote_sha.github_remote
willlookup package name locally if possible and use faster REST APIs if the curl
package is installed. This makes the remote lookup about 7-10x faster when the
package to be installed has not changed since the last install.