Repository navigation
perf: a runner container skips work its job does not need - #355
Merged
Merged
Conversation
An opt-in tmpfs /tmp, one Docker cleanup per job, a log capture that does not fork to wait, and why seed.sh's copy and a persistent BuildKit builder stay as they are.
The capture script ended each pass with sleep 0.2 and took page numbers through command substitutions: at least one process per running container five times a second. It now waits with read -t on a pipe it holds both ends of, and sets the page number in a variable. Output and resume protocol are unchanged.
job-cleanup.sh leaves /state/.runnerd-cleaned with its budget once every step succeeded; the entrypoint removes it before the runner starts, and skips the start-up cleanup when the marker is there, its budget is no lower and the Engine holds no container or volume. The cleanup prunes build contexts, git checkouts and layers only when GET /system/df?type=build-cache says the cache holds them, and walks the store once when the layer prune does not run.
tmp_tmpfs = "2G" mounts /tmp and /var/tmp as tmpfs, three quarters and a quarter, rw,exec,nosuid,nodev,mode=1777, through HostConfig.Tmpfs, which any Docker API version takes. Off by default: the pages count against the container's memory. The config refuses 0 and a size not below memory and min_memory. Never _diag or _work.
…ore report fail safe A marker written by the job-completed hook could outlive the cleanup it certified: a job process can change the store after the hook, an older image never removes the marker, and a crash can leave it behind. The start-up cleanup now always runs. The build-cache probe keeps shared records for the type checks, counts only unshared bytes against --max-used-space as BuildKit does, gives the Engine 10 s, and prunes everything on an answer without a valid list. A store du cannot measure is reported unmeasured instead of 0.
A runner keeps its tmpfs bound in its occupant and the container label runnerd.tmp-tmpfs, which a restart reads; Occupant::outdated compares it with the profile's.
…memory Two mounts of a page each held more than a tiny bound said, and without a min_memory above it sizing could advise a memory the config then refused.
# Conflicts: # docs/adr/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three runtime changes to what a runner container does per job, recorded in ADR 0170.
What changed
observe/capture.rs).sleep 0.2and read page numbers through command substitutions. That is at least one process per running container five times a second, over 100 a second with 20 runners.read -rt 0.2on a pipe it holds both ends of, opened once withexec {tick}<> <(:), so the read never hits end of file and never spins./dev/fd, it pickssleep 0.2once and stays quiet. It does not fail aread -uon every pass.stat,tailandheadstill fork for each kept page.image/job-cleanup.sh).GET /system/df?type=build-cache(API 1.42, 10 s deadline), lists the records.cache/manager.go).dunow reports the store asunmeasured, not 0./tmp(tmp_tmpfson a profile, off by default)./var/tmpgets a quarter and/tmpthe rest, each in whole 64 KiB, so the kernel rounding up to a page never takes the two mounts past the bound.rw,exec,nosuid,nodev,mode=1777throughHostConfig.Tmpfs, which any Docker API version accepts. Docker's tmpfs default isnoexec(mobydaemon/oci_linux.go; a laterexecwins inMergeTmpfsOptions).1Mand needs amin_memoryabove it. That is where sizing stops lowering memory, so applied advice always passes the config check.runnerd.tmp-tmpfs, which a restart reads. A reload that turns it on, resizes it or turns it off replaces idle runners._diagand_workare never mounted on tmpfs.seed.shor BuildKit.cpalready defaults to reflink=auto on coreutils 9.x, and its source is an overlay view, so a clone fails withEXDEV. A persistentdocker-containerbuilder would conflict with the per-job cleanup, the GC policy andsetup-buildx-action. ADR 0170 gives the details.How it was verified
Full gate from CLAUDE.md on the merge with
main(c37f0db): fmt, three clippy runs,cargo test --workspace(2317 passed), doc, boundaries, state, wire-compat, docs-commands, machete, typos, taplo, deny,shellcheck -x image/*.sh, the site build, the web demo browser test, andgit diff --check.Capture: three tests run the real script under bash over a fake
_diag. They check:sleep;All three fail on the old scripts.
Cleanup: three tests run
job-cleanup.shover a temporary root with stand-indocker,curlanddu. They cover which prunes run for each cache listing, including shared-only layer records with unshared cache mounts over half the budget;{},null, records without sizes and non-JSON answers, which all fall back to every prune; the--max-timedeadline; one store walk; and a failedduleaving the reportunmeasured.tmpfs:
1Mminimum,min_memoryrequired, 0 refused;/tmpand/var/tmp,exec, mode, whole-64-KiB sizes that never add up past the bound;min_memoryand the result validates.scrub.shon a real tmpfs/tmpand/var/tmp, checked by hand in anunshare -rmnamespace: it deleted the job's files and left the file from before the marker, both mounts, and mode 1777.Not run: anything against real Docker or Sysbox, including a tmpfs runner and
/system/df?type=build-cacheagainst the image's dockerd. These need a sandbox e2e and rebuilt images.