Skip to content
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

testing: high start up cost with high -count and no tests #49050

Closed
prattmic opened this issue Oct 18, 2021 · 2 comments
Closed

testing: high start up cost with high -count and no tests #49050

prattmic opened this issue Oct 18, 2021 · 2 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Performance

Comments

@prattmic
Copy link
Member

What version of Go are you using (go version)?

$ go version
go version devel +b7a85e0003 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/mpratt/.cache/go-build"
GOENV="/usr/local/google/home/mpratt/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/local/google/home/mpratt/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/google/home/mpratt/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/google-golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel +b7a85e0003"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/mpratt/src/scratch/go_bench/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1003331103=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Run a benchmark many, many times. (The intention here is to run benchmarks for hours)

https://play.golang.org/p/tKSzmTOK_-m

go test -bench=. -count=10000000

What did you expect to see?

Benchmarks start running immediately.

What did you see instead?

Nothing seems to happen for ~30s before the benchmarks start running. The issue appears to be that runTests runs its count loop 10000000 times, even though there are no tests to run.

One quick fix may be for runTests to exit immediately if len(tests) == 0, though I've distilled this issue down from my initial problem of a long time waiting for benchmarks to start in a package that has tests which I skip with -run=none. It would be nice to fix that case too. For that, perhaps the first pass through runTests records if it ran any tests. If not, the next iteration immediately breaks.

@prattmic prattmic added Performance NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Oct 18, 2021
@gopherbot
Copy link

Change https://golang.org/cl/356669 mentions this issue: testing: skip extra -count iterations if there are no tests

@prattmic
Copy link
Member Author

prattmic commented Oct 18, 2021

Note that my CL would break tests like https://play.golang.org/p/mGVn27Zl2lq when run like go test -count=2 -run=TestDouble/real_test.

I don't think that is a valid use of the testing package, but could certainly be convinced otherwise.

@golang golang locked and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Performance
Projects
None yet
Development

No branches or pull requests

2 participants