Skip to content

[v11] Makefile: cache go env values#25896

Merged
marcoandredinis merged 1 commit intobranch/v11from
auto-backport/25870-to-branch/v11
May 10, 2023
Merged

[v11] Makefile: cache go env values#25896
marcoandredinis merged 1 commit intobranch/v11from
auto-backport/25870-to-branch/v11

Conversation

@marcoandredinis
Copy link
Copy Markdown
Contributor

Backport #25870 to branch/v11

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/v11 branch from 866033f to ad9e4c3 Compare May 9, 2023 13:59
@github-actions github-actions Bot requested review from camscale and espadolini May 9, 2023 14:00
@marcoandredinis marcoandredinis changed the title Backport #25870 to branch/v11 [v11] 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
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 9, 2023
@marcoandredinis marcoandredinis added this pull request to the merge queue May 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 10, 2023
@marcoandredinis marcoandredinis added this pull request to the merge queue May 10, 2023
Merged via the queue into branch/v11 with commit 9749cdc May 10, 2023
@marcoandredinis marcoandredinis deleted the auto-backport/25870-to-branch/v11 branch May 10, 2023 07:33
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