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

encoding/binary: PutUint* in benchmark optimized out #36160

Closed
shawndx opened this issue Dec 16, 2019 · 3 comments
Closed

encoding/binary: PutUint* in benchmark optimized out #36160

shawndx opened this issue Dec 16, 2019 · 3 comments

Comments

@shawndx
Copy link
Contributor

shawndx commented Dec 16, 2019

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

$ go version
go version devel +a15b5d3092 Wed Dec 11 22:01:13 2019 +0000 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/xiaji01/.cache/go-build"
GOENV="/home/xiaji01/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/xiaji01/.go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/xiaji01/src/bench/go.x86"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/xiaji01/src/bench/go.x86/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/xiaji01/src/bench/go.x86/src/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build896412687=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go test -run=none -bench=PutUint encoding/binary
goos: linux
goarch: amd64
pkg: encoding/binary
BenchmarkPutUint16-40 1000000000 0.558 ns/op 3585.32 MB/s
BenchmarkPutUint32-40 1000000000 0.727 ns/op 5503.20 MB/s
BenchmarkPutUint64-40 1000000000 0.865 ns/op 9251.43 MB/s
BenchmarkLittleEndianPutUint16-40 1000000000 0.580 ns/op 3446.18 MB/s
BenchmarkLittleEndianPutUint32-40 1000000000 0.612 ns/op 6537.16 MB/s
BenchmarkLittleEndianPutUint64-40 1000000000 0.611 ns/op 13090.27 MB/s
PASS
ok encoding/binary 4.468s

What did you expect to see?

encoding/binary.bigEndian.PutUint[16,32,64] and encoding/binary.littleEndian.PutUint[16,32,64] get executed and profiled.

What did you see instead?

They are optimized out by compile optimization.

@randall77
Copy link
Contributor

There isn't anything getting optimized out. That's the set of benchmarks that have been implemented.
The benchmarks are not generated automatically. Look in encoding/binary/binary_test.go.
Feel free to mail a CL that adds big endian versions.

@randall77
Copy link
Contributor

Never mind, those benchmarks are there. They are the ones without LittleEndian in the names.
What did you want to see exactly, again?

@shawndx
Copy link
Contributor Author

shawndx commented Dec 17, 2019

Thanks @randall77, my bad, double checked SSA output and the code is not optimized out.

@golang golang locked and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants