perf(ci): disable buildvcs for builds and tests#19201
perf(ci): disable buildvcs for builds and tests#19201
Conversation
|
Skipping CI for Draft Pull Request. |
|
Images are ready for the commit at 0e04bb8. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19201 +/- ##
=======================================
Coverage 49.61% 49.62%
=======================================
Files 2680 2680
Lines 202195 202214 +19
=======================================
+ Hits 100316 100340 +24
+ Misses 94399 94396 -3
+ Partials 7480 7478 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Using
go-mod-with-buildvcs/go-build-with-buildvcsas cache key prefixes while the intent is to disablebuildvcsis confusing; consider renaming these prefixes to reflect the post-change behavior so it’s easier to compare and reason about cache behavior over time. - The change to always run the cache save step with PR-specific keys will increase cache writes and storage churn; if this is intended to be temporary, consider centralizing the feature flag (e.g., a single workflow-level input or environment toggle) so it’s easy to turn off or scope down (e.g., to a subset of workflows or branches) after the experiment.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `go-mod-with-buildvcs` / `go-build-with-buildvcs` as cache key prefixes while the intent is to *disable* `buildvcs` is confusing; consider renaming these prefixes to reflect the post-change behavior so it’s easier to compare and reason about cache behavior over time.
- The change to always run the cache save step with PR-specific keys will increase cache writes and storage churn; if this is intended to be temporary, consider centralizing the feature flag (e.g., a single workflow-level input or environment toggle) so it’s easy to turn off or scope down (e.g., to a subset of workflows or branches) after the experiment.
## Individual Comments
### Comment 1
<location path=".github/actions/cache-go-dependencies/action.yaml" line_range="20-29" />
<code_context>
+ # TEMPORARY: always save with PR-specific keys for cache testing.
</code_context>
<issue_to_address>
**suggestion:** Cache comment mentions PR-specific keys, but the keys themselves are not PR-scoped.
These cache keys:
- `go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}`
- `go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}`
are not PR-scoped (they lack something like `github.ref_name` or `github.event.pull_request.number`), so caches will be shared across branches/PRs with the same hash/job/arch/TAG. Either update the keys to include a PR identifier if the intent is truly PR-specific caches, or adjust the comment to describe the broader sharing behavior accurately.
Suggested implementation:
```
# TEMPORARY: always save with broader cache keys (shared across branches/PRs) for cache testing.
```
If the intention is to truly scope caches per PR instead of sharing them across branches/PRs, you should also modify the `key:` (and optionally `restore-keys:`) fields for:
- `go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}`
- `go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}`
to include a PR identifier such as `${{ github.ref_name }}` or `${{ github.event.pull_request.number }}` where those keys are defined elsewhere in this file.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
3757653 to
2e2661f
Compare
2deb733 to
417ca94
Compare
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Risk: if a non-.go testdata file changes content but not size between commits, the test cache could return a stale result. This is the same limitation Go's test cache has by design (it explicitly avoids hashing file content for performance). Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Note: the full test cache benefit requires stable Go build cache ActionIDs across commits (see companion PR for zversion.go change). Without that, tests still recompile on every commit, negating the mtime fix. This PR provides the mtime stabilization infrastructure; full speedup requires both changes. Risk: if a non-.go testdata file changes content but not size between commits, the test cache could return a stale result. This is Go's own inherent test cache limitation — it explicitly avoids hashing file content (test.go:hashOpen()). Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Note: the full test cache benefit requires stable Go build cache ActionIDs across commits (see companion PR for zversion.go change). Without that, tests still recompile on every commit, negating the mtime fix. This PR provides the mtime stabilization infrastructure; full speedup requires both changes. Risk: if a non-.go testdata file changes content but not size between commits, the test cache could return a stale result. This is Go's own inherent test cache limitation — it explicitly avoids hashing file content (test.go:hashOpen()). Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
417ca94 to
c348542
Compare
c348542 to
78cf1b6
Compare
Go 1.18+ silently enabled -buildvcs=auto, which stamps every binary with VCS metadata (commit, modified status) via debug.ReadBuildInfo(). No code in this repo reads this metadata — version info is injected via -X ldflags instead. The VCS stamping adds unnecessary overhead: Go must query git state for every build/test invocation, and changes to git state (e.g. untracked files) can invalidate build cache entries. Explicitly set -buildvcs=false for both build and test invocations. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
78cf1b6 to
0e04bb8
Compare
|
Superseded by a cleaner PR with just the buildvcs change. |
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go's test cache validates inputs by (path, size, mtime) — not content. git checkout sets all file mtimes to the current time, which differs between CI runs, causing test results to never be cached. Fix: set all tracked file mtimes to a fixed date (2001-01-01) after checkout and cache restore. This makes the test cache hit across runs when file content hasn't changed. Measured impact (from PR #19201): - go unit tests: 35m → 8m (4.5x) - go-postgres: 31m → 36s (52x) - sensor-integration: 26m → 2.5m (11x) - Test cache hit rate: 97.6% (681/698 packages) Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Go 1.18+ silently enabled
-buildvcs=auto, which stamps every binary with VCSmetadata (commit, modified status) via
debug.ReadBuildInfo(). No code in thisrepo reads this metadata — version info is injected via
-Xldflags instead.The VCS stamping adds unnecessary overhead: Go must query git state for every
build/test invocation, and changes to git state (e.g. untracked files) can
invalidate build cache entries.
Fix: explicitly set
-buildvcs=falseingo-tool.sh.Changes
scripts/go-tool.sh: add-buildvcs=falsetoinvoke_go_build()andgo_test().Testing and quality
How I validated my change
-buildvcs=false.