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

test/bench/go1: benchmark Mandelbrot200 is reduced to zero with gollvm #56483

Open
alexanius opened this issue Oct 29, 2022 · 3 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@alexanius
Copy link

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

$ go version
go version go1.18 gollvm LLVM 15.0.0git 20221028 (experimental) 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="/home/alex/.cache/go-build"
GOENV="/home/alex/.config/go/env"
GOEXE=""
GOEXPERIMENT="fieldtrack,regabiwrappers"
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/alex/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/alex/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/alex/test/gollvm/install"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/alex/test/gollvm/install/tools"
GOVCS=""
GOVERSION="go1.18 gollvm LLVM 15.0.0git 20221028 (experimental)"
GCCGO="/home/alex/test/gollvm/install/bin/llvm-goc"
GOAMD64="v1"
AR="ar"
CC="/usr/bin/cc"
CXX="/usr/bin/c++"
CGO_ENABLED="1"
GOMOD="/home/alex/test/go/test/bench/go1/go.mod"
GOWORK=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build712666364=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

$ cd test/bench/go1

$ go test -bench=. -count=10 -gccgoflags="-O3" -c -o go1_gollvm.out

$ ./go1_gollvm.out -test.bench "Mandelbrot200"
goos: linux
goarch: amd64
pkg: test/bench/go1
cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
BenchmarkMandelbrot200-4        1000000000               0.0000004 ns/op
PASS

What did you expect to see?

Nonzero result

What did you see instead?

The output above.

The problem is that the function mandelbrot has no size effects and llvm eliminates its call. To fix the problem we need to check the result of mandelbrot in the caller function.

@gopherbot
Copy link

Change https://go.dev/cl/446435 mentions this issue: go1: test the result of Mandelbrot200 benchmark

@seankhliao seankhliao changed the title go1/gollvm: benchmark Mandelbrot200 is reduced to zero test/bench/go1: benchmark Mandelbrot200 is reduced to zero with gollvm Nov 1, 2022
@seankhliao seankhliao added this to the gollvm milestone Nov 1, 2022
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 1, 2022
@seankhliao
Copy link
Member

cc @thanm maybe?

@thanm
Copy link
Contributor

thanm commented Nov 1, 2022

Yeah, it is a known issue, I've put together patches in the past to work around it. I'll send a CL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants