feat(build-all): trim pkgcache _metadata every 25 packages during full builds

This commit is contained in:
Patrick Schratz 2026-07-03 09:24:02 +02:00
commit b53a24614b
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -96,6 +96,10 @@ s3_cache <- readRDS("/mnt/cache/packages/s3_cache.rds")
sprintf("S3 cache: %s files", length(s3_cache)) sprintf("S3 cache: %s files", length(s3_cache))
n <- nrow(chunk) n <- nrow(chunk)
# Every `trim_every` packages, bound the pkgcache _metadata dir so a full-platform
# run does not accumulate thousands of ~70 MB snapshots and fill the host disk.
# No-op on amd64 (R_PKG_CACHE_DIR is empty / cache not persisted).
trim_every <- 25L
mapply( mapply(
function(pkg, ver, sens, i) { function(pkg, ver, sens, i) {
cat(sprintf("[%d/%d] %s_%s (r_minor_sensitive=%s)\n", i, n, pkg, ver, sens)) cat(sprintf("[%d/%d] %s_%s (r_minor_sensitive=%s)\n", i, n, pkg, ver, sens))
@ -120,6 +124,12 @@ mapply(
upload = TRUE, upload = TRUE,
store_build_metadata = TRUE store_build_metadata = TRUE
) )
if (i %% trim_every == 0L) {
removed <- trim_pkgcache_metadata()
if (removed > 0L) {
cat(sprintf(" [pkgcache trim] removed %d stale _metadata entries\n", removed))
}
}
}, },
chunk$Package, chunk$Package,
chunk$Version, chunk$Version,