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/compile: performance of embedded interfaces #14677

Open
OneOfOne opened this issue Mar 6, 2016 · 3 comments
Open

cmd/compile: performance of embedded interfaces #14677

OneOfOne opened this issue Mar 6, 2016 · 3 comments
Milestone

Comments

@OneOfOne
Copy link
Contributor

@OneOfOne OneOfOne commented Mar 6, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +6bd63ca 2016-03-06 16:12:33 +0000 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
➜ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oneofone/code/go"
GORACE=""
GOROOT="/usr/src/go"
GOTOOLDIR="/usr/src/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build035989829=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    (Use play.golang.org to provide a runnable example, if possible.)
    http://play.golang.org/p/paUFpqwntQ
  2. What did you expect to see?
    embedded interfaces being as fast as assigning them to a field.

struct { sort.Interface } vs struct { a sort.Interface }

  1. What did you see instead?
BenchmarkEmbeded-8           100          22515496 ns/op          802944 B/op          6 allocs/op
BenchmarkEmbededPtr-8         50          22651711 ns/op          802896 B/op          6 allocs/op
BenchmarkField-8             100          16229781 ns/op          802875 B/op          4 allocs/op
@minux
Copy link
Member

@minux minux commented Mar 7, 2016

@OneOfOne
Copy link
Contributor Author

@OneOfOne OneOfOne commented Mar 7, 2016

@minux and there's no way during one of the ssa phases to treat an embedded interface as a field?

@OneOfOne
Copy link
Contributor Author

@OneOfOne OneOfOne commented Mar 7, 2016

BTW, embedded structs don't suffer from that http://play.golang.org/p/Gbu20Yr0wj

BenchmarkEmbeded-8           100          16429062 ns/op          802927 B/op          5 allocs/op
BenchmarkEmbededPtr-8        100          16391271 ns/op          802881 B/op          5 allocs/op
BenchmarkField-8             100          16268886 ns/op          802878 B/op          4 allocs/op
@ianlancetaylor ianlancetaylor changed the title performance of embedded interfaces. cmd/compile: performance of embedded interfaces Mar 7, 2016
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
@minux @OneOfOne @ianlancetaylor and others
You can’t perform that action at this time.