-
Notifications
You must be signed in to change notification settings - Fork 17.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go build/test: 400% perf regression with Go 1.20 when triggering via os/exec in Docker container #59146
Comments
Can you narrow down where the time is being spent? Is it before the |
@bcmills We confirmed the extra time spent came from the For instance, changing the example above to also time func main() {
startCommand := time.Now()
cmd := exec.Command("go", "test")
fmt.Printf("exec.Command() took %v\n", time.Since(startCommand))
startRun := time.Now()
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
fmt.Printf("cmd.Run() took %v\n", time.Since(startRun))
} Using the dockerfile in the post ( $ docker run test-runner-minimal:1.20.2
exec.Command() took 427.488µs
cmd.Run() took 7.874369137s
$ docker run test-runner-minimal:1.20.2
exec.Command() took 104.56µs
cmd.Run() took 5.086919508s Using the exact same setup, but using $ docker run test-runner-minimal:1.19.7
exec.Command() took 123.863µs
cmd.Run() took 1.095058008s
$ docker run test-runner-minimal:1.19.7
exec.Command() took 106.118µs
cmd.Run() took 1.143650535s Like mentioned above, to get similar time results with FROM golang:1.20.2-alpine3.17
RUN adduser --disabled-password appuser
COPY . .
RUN chown -R appuser:appuser app
USER appuser
WORKDIR app
RUN go build -o main
CMD ["./main"] We get similar results to Go 1.19: $ docker run test-runner-minimal:1.20.2-permissions
exec.Command() took 145.058µs
cmd.Run() took 990.321249ms
$ docker run test-runner-minimal:1.20.2-permissions
exec.Command() took 82.266µs
cmd.Run() took 1.13887994s We did a similar print-based profiling in our test runner, and all the timings look similar to 1.19, except the It's also worth mentioning that we could reproduce this problem in non- |
|
I modified the example program to generate some traces (let us know if there's a better way to see this) and according to the blocking profile, it seems the delay is due to the time spent in Full trace file: trace_fast_19.out.zip Full trace file: trace_slow_20.out.zip |
Ok, so that's pretty solid evidence that the CPU time is not being spent in |
There are no tests in the example repo, so AIUI the only process where time could be spend is the go tool itself. |
I can't actually reproduce this. That is, even if I add this to the I modified the test program to run I'm not sure how to avoid that. I tried adding But I'm afraid this issue is WAI. |
Actually, this works: FROM golang:1.20.2-alpine3.17
RUN adduser --disabled-password appuser
USER appuser
RUN go build -v std
ADD --chown=appuser:appuser . .
WORKDIR app
RUN go build -v -o main
CMD ["./main"] This
You can probably take it from there :) |
@Merovius Thanks a lot for taking a look at this. Those conclusions make perfect sense. In our original case, we also had a In our case, we are also doing some other calls to |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes, afaik 1.20.2 is the latest release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
(The issue came up in a more complex production scenario, I'm describing the minimal setup to reproduce that we could boil it down to.)
I have this small program that executes
go test
and prints the time it took:I run it in a Docker container with the following Dockerfile
Full runnable example here: https://github.com/junedev/testrunner-issue-repro
What did you expect to see?
This exact same setup with Go 1.19 (
golang:1.19.7-alpine3.17
) reports that the program took ~0.7s. We expected similar performance for Go 1.20.What did you see instead?
With the Go 1.20 image, the program consistently reports that it took >3s to run.
We are seeing this performance issue on various local machines, as well as on our production infrastructure.
Some other things we found out so far:
golang:1.20.2
) and setting CGO_ENABLED.ls
orgo version
do not seem to be affected by this issue.go test
is indeed executed just fine. It is just very slow.RUN chown -R appuser:appuser app
. We nevertheless wanted to report the issue in case there is some underlying issue that needs fixing and as reference for others who run into this.(Some background info how we ran into this: On Exercism, students can learn Go and other languages for free and we run tests on the code they submit and show the results on the website. We have a 10s timeout for running the tests. With Go 1.19 it took around 4s. After the update to 1.20 our students started complaining that they see timeouts all the time and we saw the tests now took ~20s to run.)
The text was updated successfully, but these errors were encountered: