Skip to content

[v12] Makefile: cache go env values#25895

Merged
marcoandredinis merged 1 commit intobranch/v12from
auto-backport/25870-to-branch/v12
May 9, 2023
Merged

[v12] Makefile: cache go env values#25895
marcoandredinis merged 1 commit intobranch/v12from
auto-backport/25870-to-branch/v12

Conversation

@marcoandredinis
Copy link
Copy Markdown
Contributor

Backport #25870 to branch/v12

Spawning shells is expensive for Makefile targets.
We use the `OS` and `ARCH` variables in a lot of places.
They come from spawning a subshell and then executing `go env GOOS` or
`go env GOARCH`.

So, everytime we need them, we spawn a subshells.
Just parsing the Makefile adds quite some time, even if the target
itself is fast.

This PR caches those values, so that we only need to spawn a subshell
once per execution.

Tests show that running `make print-version` is now much faster:
Using linux: drop from 56s to 0.240s
Using MacOS M1: drop from 291ms to 119ms
YMMV
@marcoandredinis marcoandredinis force-pushed the auto-backport/25870-to-branch/v12 branch from 147f163 to 45a65e2 Compare May 9, 2023 13:59
@github-actions github-actions Bot requested review from camscale and espadolini May 9, 2023 13:59
@marcoandredinis marcoandredinis changed the title Backport #25870 to branch/v12 [v12] Makefile: cache go env values May 9, 2023
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from camscale May 9, 2023 14:48
@marcoandredinis marcoandredinis added this pull request to the merge queue May 9, 2023
Merged via the queue into branch/v12 with commit a97708f May 9, 2023
@marcoandredinis marcoandredinis deleted the auto-backport/25870-to-branch/v12 branch May 9, 2023 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants