perf(covgate): instrument the build-cache pre-warm#36
Merged
Conversation
The pre-warm compiled non-instrumented test binaries, but covgate's coverage runs compile instrumented ones (-coverpkg). Storing both sets roughly doubled the saved build cache downstream (~2.2GB -> ~4.3GB), reintroducing cache-quota eviction, and the warm output was only partly reused by the instrumented coverage runs. Split the warm into two passes that match what covgate actually builds: - cover paths (the measured packages): `go test -run=^$ -cover <pkgs>`, instrumenting each package for itself just as covgate's per-package -coverpkg does, so the instrumented objects are reused, not rebuilt. - plain paths (the ./tests/... dirs): `go test -run=^$ <dirs>`, since covgate compiles integration test packages as plain deps. This should let the cache hold ~one artifact set instead of two and let covgate reuse the pre-warmed instrumented objects. Gate, logging, and "Total time" semantics are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Make covgate's build-cache pre-warm instrumented, matching what the coverage runs actually compile. Two passes instead of one plain pass:
go test -run=^$ -cover <pkgs>—-coverdefaults to instrumenting each package for itself, matching covgate's per-package-coverpkg=<pkg>../tests/...dirs):go test -run=^$ <dirs>— covgate compiles integration test packages as plain deps, so these stay non-instrumented.Why
The pre-warm compiled non-instrumented test binaries; covgate's coverage runs compile instrumented ones. The saved build cache therefore stored both artifact sets — in production (backend) the
gobuild-testcache roughly doubled (~2.2 GB → ~4.3 GB), which pushed the repo back over the 10 GB Actions cache quota (re-triggering LRU eviction → colder restores → high run-to-run variance), and the warm output was only partly reused by the instrumented runs.Instrumenting the warm pass so it produces the same objects covgate consumes should let the cache hold ~one artifact set and let covgate reuse the pre-warmed instrumented objects instead of rebuilding them.
Prototype — what to measure
This is a prototype; the proof is a backend CI run once this is released and bumped:
gobuild-testcache size should fall back toward ~2.2 GB (the headline metric — resolves the quota regression).If the cache doesn't shrink meaningfully, revert — the plain pre-warm is simpler.
Tests / validation
PrewarmBuildtests updated to the two-arg form (empty/empty → nil; build error in either pass propagates).collectWarmPathssplit tested: cover = measured pkgs, plain = de-duplicated./tests/...dirs.func([]string, []string) error.go build,go vet,go test, repo lint, and the covgate self-gate (covgate 100%, gocover 93.8%) all pass; no.covgatefloors lowered.Gate (
parallelism > 1 && len(pkgs) > 1), the pre-warm duration logging (v0.2.1), and "Total time" semantics are unchanged.🤖 Generated with Claude Code