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

cmd/go: -race adds significant overhead when running tests #61941

Closed
mdwhatcott opened this issue Aug 10, 2023 · 2 comments
Closed

cmd/go: -race adds significant overhead when running tests #61941

mdwhatcott opened this issue Aug 10, 2023 · 2 comments

Comments

@mdwhatcott
Copy link

mdwhatcott commented Aug 10, 2023

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

$ go version
go version go1.21.0 darwin/arm64

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='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mike/Library/Caches/go-build'
GOENV='/Users/mike/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mike/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mike'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/mike/src/github.com/mdwhatcott/version/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/nb/jlnxml655036q62h1nvpk7g00000gp/T/go-build3258536926=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Ran go test -race. Noticed that the test run took a full second longer with the race detector compared with go test.

What did you expect to see?

I expected tests run with and without the race detector to complete in roughly the same amount of time.

What did you see instead?

With Go 1.21:

$ time go test -count=1
PASS
ok  	github.com/mdwhatcott/version	0.089s
go test -count=1  0.18s user 0.25s system 170% cpu 0.252 total

$ time go test -count=1 -race
PASS
ok  	github.com/mdwhatcott/version	1.157s
go test -count=1 -race  0.21s user 0.25s system 31% cpu 1.438 total

With Go 1.20.7

$ time go test -count=1      
PASS
ok  	github.com/mdwhatcott/version	0.094s
go test -count=1  0.19s user 0.24s system 171% cpu 0.248 total

$ time go test -count=1 -race
PASS
ok  	github.com/mdwhatcott/version	0.116s
go test -count=1 -race  0.21s user 0.26s system 156% cpu 0.303 total
@mdwhatcott
Copy link
Author

FWIW, I have not observed any additional overhead in Go 1.21 when running go build -race, just when running go test -race.

@seankhliao
Copy link
Member

Duplicate of #61852

@seankhliao seankhliao marked this as a duplicate of #61852 Aug 10, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants