perf(build-newer-r): skip packages that already have a binary in bulk
Decide the already-built candidates from one listing per slot and one ABI-verdict query instead of a DB connection and several S3 requests per package; anything undecidable still goes through bincraft.
This commit is contained in:
parent
7f6a15abb2
commit
c3e95f7c69
1 changed files with 195 additions and 0 deletions
|
|
@ -73,3 +73,42 @@ newer_r_candidates <- function(db, primary_r, target_r) {
|
|||
result <- db[selected, c("Package", "Version"), drop = FALSE]
|
||||
result[order(result$Package), , drop = FALSE]
|
||||
}
|
||||
|
||||
# Candidates that still need a build, decided from one bucket listing per slot
|
||||
# instead of a metadata-DB connection and several S3 requests per package.
|
||||
#
|
||||
# Mirrors bincraft's own skip decision: a package is done when a binary sits at
|
||||
# the path its cached ABI verdict routes it to, `<slot>/<minor>/` when
|
||||
# r-minor-sensitive and the flat `<slot>/` otherwise. A CRAN source sitting at
|
||||
# that key is a fallback, not a binary (see outstanding_packages()). Whatever
|
||||
# this cannot decide, no cached verdict or a slot that could not be listed,
|
||||
# stays in the list, so bincraft makes that call exactly as before.
|
||||
#
|
||||
# `sensitive` cached verdicts for the current classifier, named `<pkg>_<ver>`
|
||||
# `flat_etags` listing of the flat slot as for outstanding_packages(), or
|
||||
# NULL when it could not be listed
|
||||
# `minor_etags` the same for this interpreter's per-minor slot
|
||||
newer_r_outstanding <- function(
|
||||
pkgs,
|
||||
sensitive,
|
||||
flat_etags,
|
||||
minor_etags,
|
||||
cran_md5
|
||||
) {
|
||||
verdict <- unname(sensitive[paste(pkgs$Package, pkgs$Version, sep = "_")])
|
||||
version <- stats::setNames(pkgs$Version, pkgs$Package)
|
||||
keep <- rep(TRUE, nrow(pkgs))
|
||||
routes <- list(
|
||||
list(sensitive = FALSE, etags = flat_etags),
|
||||
list(sensitive = TRUE, etags = minor_etags)
|
||||
)
|
||||
for (route in routes) {
|
||||
idx <- which(verdict %in% route$sensitive)
|
||||
if (length(idx) == 0L || is.null(route$etags)) {
|
||||
next
|
||||
}
|
||||
keep[idx] <- pkgs$Package[idx] %in%
|
||||
outstanding_packages(pkgs$Package[idx], route$etags, version, cran_md5)
|
||||
}
|
||||
pkgs[keep, , drop = FALSE]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue