golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.14k stars 17.69k forks source link

runtime: TestPingPongHog fail randomly on linux/arm64 #20494

Closed williamweixiao closed 7 years ago

williamweixiao commented 7 years ago

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

go version devel +2d20ded Sat May 20 00:45:56 2017 +0000 linux/arm64

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

GOARCH="arm64" GOBIN="" GOEXE="" GOHOSTARCH="arm64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/weixia01/go" GORACE="" GOROOT="/home/weixia01/workspace/llt/golang/golang" GOTOOLDIR="/home/weixia01/workspace/llt/golang/golang/pkg/tool/linux_arm64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build257642744=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"

What did you do?

$cd src/runtime $go test -run="TestPingPongHog"

What did you expect to see?

PASS

What did you see instead?

--- FAIL: TestPingPongHog (0.15s) proc_test.go:434: want hogCount/lightCount in [0.5, 2]; got 23000000/11097000 = 2.072632242948545 FAIL exit status 1

williamweixiao commented 7 years ago

I'm not sure whether the required range [0.5, 2] is reasonable. I would appreciate it if someone can shed some light on the range.

mvdan commented 7 years ago

How often does it fail? Does -race affect the frequency? I guess you used something like go test -run=TestPingPongHog -count 1000 to try many times and get a few failures?

williamweixiao commented 7 years ago

The failure rate is about: 458/1000 (-count 1000) The "-race" is only supported on amd64 and I can't use it on arm64.

williamweixiao commented 7 years ago

I find there are failures even for amd64 but the rate is very small: 24/1000. The "-race" will improve the failure rate to: 100%. So it seems that arm64 just amplify the failure probability.

williamweixiao commented 7 years ago

/cc @ianlancetaylor @bradfitz any comments on the failure rate?

ianlancetaylor commented 7 years ago

I just ran the test 1000 times on amd64 and saw 39 failures. The smallest ratio I saw was 0.4875967574815627 and the largest was 2.5314388371713212.

@aclements wrote the test so I will let him decide what to do.

aclements commented 7 years ago

I think we can just expand the range a bit. There's was nothing special about the 2X. If this test weren't working, I would expect the gap to be closer to 1000X.

gopherbot commented 7 years ago

CL https://golang.org/cl/44859 mentions this issue.