Skip to content

chore: Improve performance of make verify#1382

Merged
theunrepentantgeek merged 3 commits intomainfrom
theunrepentantgeek/feature/fast-verify
Jan 27, 2026
Merged

chore: Improve performance of make verify#1382
theunrepentantgeek merged 3 commits intomainfrom
theunrepentantgeek/feature/fast-verify

Conversation

@theunrepentantgeek
Copy link
Member

Description

Currently, make verify reinstalls everything in our toolchain every time - which currently takes ~40s and will take longer when I add in the kube-api-linting plugin to golangci-lint.

This PR changes the behaviour so that make verify will only install tools that are missing, skipping the install step for any tool currently present.

The behaviour of make toolchain is unchanged - it will still force install the specified versions of each tool.

How was this change tested?

Local tests.

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

Release Note

NONE

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves the performance of the make verify target by introducing conditional tool installation. Currently, make verify reinstalls all tools every time, which takes approximately 40 seconds. With this change, tools that are already present will be skipped, significantly reducing verification time.

Changes:

  • Added SKIP_INSTALLED environment variable support to hack/toolchain.sh to enable conditional tool installation
  • Refactored tool installation to use helper functions should-skip and go-install that check for tool presence before installing
  • Modified the verify target in the Makefile to call make toolchain with SKIP_INSTALLED=true

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
hack/toolchain.sh Added skip logic for already-installed tools via new SKIP_INSTALLED flag, should-skip and go-install helper functions; refactored all tool installations to use the new helper
Makefile Modified verify target to set SKIP_INSTALLED=true when calling make toolchain, preserving the original behavior of make toolchain (always reinstall)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# should-skip is a helper function to determine if installation of a tool should be skipped
# $1 is the expected command
should-skip() {
if [ "$SKIP_INSTALLED" == true ] && [ -f "$TOOL_DEST/$1" ]; then
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent use of single brackets with double equals operator. The codebase convention uses double brackets [[ with == for string comparisons (see hack/codegen.sh:81, hack/codegen.sh:103, hack/release/common.sh:98, etc.). Consider changing to: if [[ "$SKIP_INSTALLED" == true ]] && [ -f "$TOOL_DEST/$1" ]; then

Copilot uses AI. Check for mistakes.
# Default SKIP_INSTALLED to false if not set
SKIP_INSTALLED="${SKIP_INSTALLED:=false}"

if [ "$SKIP_INSTALLED" == true ]; then
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent use of single brackets with double equals operator. The codebase convention uses double brackets [[ with == for string comparisons (see hack/codegen.sh:81, hack/codegen.sh:103, hack/release/common.sh:98, etc.). Consider changing to: if [[ "$SKIP_INSTALLED" == true ]]; then

Copilot uses AI. Check for mistakes.
@tallaxes
Copy link
Collaborator

tallaxes commented Jan 26, 2026

which currently takes ~40s

Only the first time, right? The second time (on main, in my codespace) it takes 5s

Also note that the next logical step in tooling is likely to start using go tool capabilities - probably with a separate go.mod file, see e.g. https://github.com/kubernetes-sigs/karpenter/blob/main/go.tools.mod. We don't have to do it now - but would these performance improvements apply / be needed if we decide to do this?

@theunrepentantgeek
Copy link
Member Author

Only the first time, right? The second time (on main, in my codespace) it takes 5s

Testing locally, on my laptop (28 cores, 64GB of memory) it's taking ~40s every time. It may have been even slower, the first time, but it's not quick.

Also note that the next logical step in tooling is likely to start using go tool capabilities - probably with a separate go.mod file, see e.g. https://github.com/kubernetes-sigs/karpenter/blob/main/go.tools.mod. We don't have to do it now - but would these performance improvements apply / be needed if we decide to do this?

Depends on whether go tool does smart caching or not. I'll put that on my TODO list to learn about.

@theunrepentantgeek theunrepentantgeek merged commit 1ad69b8 into main Jan 27, 2026
26 checks passed
@theunrepentantgeek theunrepentantgeek deleted the theunrepentantgeek/feature/fast-verify branch January 27, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants