Skip to content

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

Closed

Description

@prattmic

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.

Activity

  1. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Oct 18, 2021
  2. gopherbot commented on Oct 18, 2021

    @gopherbot
    Contributor

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

  3. prattmic commented on Oct 18, 2021

    @prattmic
    MemberAuthor

    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.

  4. locked and limited conversation to collaborators on Oct 25, 2022
  5. added a commit that references this issue on Sep 19, 2024
    2c66cab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions