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/compile: byte type conversion optimizations #18575

Open
josselin-c opened this Issue Jan 9, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@josselin-c
Contributor

josselin-c commented Jan 9, 2017

What did you do?

I noticed that rewriting a busy-loop with cast-then-compare (ie BenchmarkU64) instead of compare-then-cast (ie BenchmarkByte) I was getting a noticeable throughput difference.

Here is a benchmark that shows the difference:
https://play.golang.org/p/gZLNPgrVPn

go test -bench .
BenchmarkByte-4         2000000000               0.94 ns/op
BenchmarkU64-4          2000000000               0.84 ns/op

What did you expect to see?

Same benchmark performance.

What did you see instead?

BenchmarkU64 is >10% faster than BenchmarkByte.

Does this issue reproduce with the latest release (go1.7.4)?

Reproduced with 1.8beta2

System details

go version go1.8beta2 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/costanzj/projects/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build406899558=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOROOT/bin/go version: go version go1.8beta2 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.8beta2 X:framepointer
uname -sr: Linux 4.4.0-38-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.1 LTS
Release:	16.04
Codename:	xenial
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu5) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
@randall77

This comment has been minimized.

Contributor

randall77 commented Jan 9, 2017

There's an extraneous MOVBLZX in the first case, that might be the cause.
Shouldn't be too hard to fix.

@randall77 randall77 added this to the Go1.9 milestone Jan 9, 2017

@josharian

This comment has been minimized.

Contributor

josharian commented Jan 9, 2017

Possibly related: #15300.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment