Skip to content

Don't shell out to go list when not needed#9776

Merged
espadolini merged 1 commit intomasterfrom
espadolini/faster-makefile
Jan 13, 2022
Merged

Don't shell out to go list when not needed#9776
espadolini merged 1 commit intomasterfrom
espadolini/faster-makefile

Conversation

@espadolini
Copy link
Copy Markdown
Contributor

@espadolini espadolini commented Jan 13, 2022

This replaces all the := assignments to target-local variables that are only used once with = assignments; as the = assignments are not expanded until needed, this prevents useless calls to go list or find that happen just as part of the makefile parsing.

The time for a make full-ent with a hot cache goes from 39.5 seconds to 3.6 seconds on my laptop; likewise, the time for make print-version goes from 2.8 seconds to 0.2 seconds on this machine (16" 2021 M1 Max MacBook Pro running macOS 12.1, go 1.17.6, rust 1.57.0).

This reverts the change in #9432 that selectively disabled the test targets when running the makefile as part of make grpc - the only reason that change was made was for performance, which this PR improves.

@Tener
Copy link
Copy Markdown
Contributor

Tener commented Jan 13, 2022

This is awesome! I can confirm the timings, but I guess this is expected given I have exact same machine 😄 Going by https://stackoverflow.com/questions/448910/what-is-the-difference-between-the-gnu-makefile-variable-assignments-a switching from := to = isn't necessarily safe, specifically in case variables are changing values.

But here it looks fine: there should be no difference in the results the executables return, and the single variable referenced (ADDFLAGS) is defined from the start and doesn't change value.

Comment thread build.assets/Makefile
docker run \
$(DOCKERFLAGS) -e CLANG_FORMAT=/usr/bin/clang-format-10 -t $(DEVBOX) \
make -C /go/src/github.com/gravitational/teleport DISABLE_TEST_TARGETS=1 devbox-grpc
make -C /go/src/github.com/gravitational/teleport devbox-grpc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change looks unrelated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This reverts the change I made in #9432 because I thought that the performance problems were caused by some quirks in the docker vfs bindmounts, so I was only excluding the test targets for the inner part of make grpc; with the change in the makefile, this isn't necessary anymore.

I'll note this in the PR description.

@webvictim
Copy link
Copy Markdown
Contributor

Works fine for me and is also much faster, both natively on an Intel Mac and in a Linux VM. Nice!

@espadolini espadolini enabled auto-merge (squash) January 13, 2022 14:49
@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Jan 13, 2022

So awesome, thanks @espadolini!!

@espadolini espadolini merged commit c7797fc into master Jan 13, 2022
@espadolini espadolini deleted the espadolini/faster-makefile branch January 13, 2022 16:00
@zmb3 zmb3 mentioned this pull request Jan 6, 2026
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.

6 participants