Title: perf(ci): use stable test ldflags for Go test cache by davdhacs · Pull Request #19394 · stackrox/stackrox · GitHub
Open Graph Title: perf(ci): use stable test ldflags for Go test cache by davdhacs · Pull Request #19394 · stackrox/stackrox
X Title: perf(ci): use stable test ldflags for Go test cache by davdhacs · Pull Request #19394 · stackrox/stackrox
Description: Description Enable Go build cache reuse across commits by stabilizing the -X ldflags that Go includes in build ActionIDs. The problem scripts/go-tool.sh injects per-commit version values via -X ldflags: -X MainVersion=4.11.x-317-gabcdef (changes every commit — includes commit count + SHA) -X GitShortSha=abcdef (changes every commit) Go includes -X ldflags in the link ActionID (exec.go:1404: linkflags %q). When ldflags change, Go computes a new ActionID for every package that gets linked, causing cache misses for: Build binaries: the linked binary cache key changes (though Go patches -X values post-link, so the build cost is minimal ~1-2s) Test binaries: the test binary ID changes, causing all test results to miss the cache and re-run from scratch every commit The fix Split ldflags into two sets: Build ldflags: full per-commit version (unchanged from today) Test ldflags: stable base version tag (e.g. 4.11.x from git describe --tags --abbrev=0), GitShortSha skipped This preserves the correct version string in all built binaries while giving test binaries a stable ActionID across commits. -buildvcs=false Go 1.18 (adopted September 2022) silently enabled buildvcs=auto, which stamps vcs.revision, vcs.time, vcs.modified into every binary via the linker. No code in the repository reads this data — version stamping is done independently via the -X ldflags from status.sh. The buildvcs data was never intentionally enabled; it appeared as an unnoticed side effect of the Go 1.18 upgrade. The only time it was previously noticed was July 2024 (PR #11935) when it broke a scanner CI workflow. Adding -buildvcs=false removes this unused overhead. What changes One file: scripts/go-tool.sh Split ldflags into build_ldflags (full version) and test_ldflags (stable base tag) Tests get -X MainVersion=4.11.x instead of -X MainVersion=4.11.x-317-gabcdef Tests skip -X GitShortSha (not needed, changes per commit) -buildvcs=false added to both build and test What is preserved //XDef: annotations — unchanged status.sh — unchanged -X ldflags for builds — unchanged (full git describe version in binaries) version_data.go — unchanged Operator Dockerfile — unchanged Built binary version strings — identical to today Build cache impact Builds already benefit from GOCACHE for compilation (.a files are keyed by source hashes, not ldflags). The -X ldflags only affect linking, and Go patches -X values post-link so there is minimal build cost (~1-2s). The main benefit of this PR is enabling test result caching when combined with PR #19395 (file mtime stabilization). Together they achieve: Job Master warm Combined warm Speedup go unit tests 35m ~8m 4.5x go-postgres 31m ~36s 52x sensor-integration 26m ~2.5m 11x A combined test branch (davdhacs/test-cache-combined) with only these two changes is being tested to provide clean timing data. Partially generated by AI.
Open Graph Description: Description Enable Go build cache reuse across commits by stabilizing the -X ldflags that Go includes in build ActionIDs. The problem scripts/go-tool.sh injects per-commit version values via -X ldf...
X Description: Description Enable Go build cache reuse across commits by stabilizing the -X ldflags that Go includes in build ActionIDs. The problem scripts/go-tool.sh injects per-commit version values via -X ldf...
Opengraph URL: https://github.com/stackrox/stackrox/pull/19394
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d2bc7387-cb10-0996-054b-b3dea3cb10e2 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E016:90895:E949C8:13D90FC:6A4D5F1A |
| html-safe-nonce | 0b5f37bf4d1b9ab395e17e6e6ac9779358d8ba22e514b8c900f3b90ae2008f30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDE2OjkwODk1OkU5NDlDODoxM0Q5MEZDOjZBNEQ1RjFBIiwidmlzaXRvcl9pZCI6IjQ0NDMyMDM4MjA1MTI0MzU5OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 62d69ac3086047a3c746f046256028efac27151cb33dbd8a23f65d7399603f9b |
| hovercard-subject-tag | pull_request:3390041616 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/stackrox/stackrox/pull/19394/files |
| twitter:image | https://avatars.githubusercontent.com/u/105243888?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/105243888?s=400&v=4 |
| og:image:alt | Description Enable Go build cache reuse across commits by stabilizing the -X ldflags that Go includes in build ActionIDs. The problem scripts/go-tool.sh injects per-commit version values via -X ldf... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e6658d7c7808aeed776f841e0839b885fce343c9b96244be612c779298e7661e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/stackrox/stackrox git https://github.com/stackrox/stackrox.git |
| octolytics-dimension-user_id | 40638982 |
| octolytics-dimension-user_login | stackrox |
| octolytics-dimension-repository_id | 434017296 |
| octolytics-dimension-repository_nwo | stackrox/stackrox |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 434017296 |
| octolytics-dimension-repository_network_root_nwo | stackrox/stackrox |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a438513d3a22ffcd713795ed948c3e5525007665 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width