-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
runtime: cgo performance tracking bug #9704
Comments
It is combined effect of C->Go conversion, write barriers and atomic manipulation of goroutine statuses: 10.45% cgo cgo [.] runtime.cas |
Or maybe it's a sinister plot to encourage people to write Go code. Either way, too late for Go 1.5. |
linux/amd64, linux/arm:
|
Going by BenchmarkCgoCall in misc/cgo/test, on my linux/amd64 system, current tip is about twice as fast as go 1.7. Go 1.7, 1.6 and 1.5 are all about the same and Go 1.4 is slightly slower (I lack the energy to get 1.3 cgo working on this system). So the thing the bug specifically complains about ("decrease of cgocall performance") is probably fixed, but is this fast enough? (It's always hard to know when a bug like this can be closed). |
http://golang.org/cl/30080 ~halved the cgo overhead between 1.7 and tip. As reported this can be closed, but how about we keep it as a cgo performance tracking bug? I don't expect any more improvements for 1.8, but in the future a runtime accounting overhaul could make it cheaper. |
New benchmark result on the same machine:
go version go1
BenchmarkCgo 50000000 31.5 ns/op
go version go1.1.2 linux/amd64
BenchmarkCgo 50000000 42.5 ns/op
go version go1.2.1 linux/amd64
BenchmarkCgo 50000000 48.4 ns/op
go version go1.2.2 linux/amd64
BenchmarkCgo 50000000 47.6 ns/op
go version go1.3 linux/amd64
BenchmarkCgo 50000000 47.6 ns/op
go version go1.3.1 linux/amd64
BenchmarkCgo 50000000 48.8 ns/op
go version go1.3.2 linux/amd64
BenchmarkCgo 50000000 52.9 ns/op
go version go1.3.3 linux/amd64
BenchmarkCgo 50000000 50.5 ns/op
go version go1.4 linux/amd64
BenchmarkCgo 10000000 167 ns/op
go version go1.4.1 linux/amd64
BenchmarkCgo 10000000 169 ns/op
go version go1.4.2 linux/amd64
BenchmarkCgo 10000000 170 ns/op
go version go1.4.3 linux/amd64
BenchmarkCgo 10000000 172 ns/op
go version go1.5 linux/amd64
BenchmarkCgo-4 10000000 162 ns/op
go version go1.5.1 linux/amd64
BenchmarkCgo-4 10000000 159 ns/op
go version go1.5.2 linux/amd64
BenchmarkCgo-4 10000000 169 ns/op
go version go1.5.3 linux/amd64
BenchmarkCgo-4 10000000 169 ns/op
go version go1.5.4 linux/amd64
BenchmarkCgo-4 10000000 170 ns/op
go version go1.6 linux/amd64
BenchmarkCgo-4 10000000 160 ns/op
go version go1.6.1 linux/amd64
BenchmarkCgo-4 10000000 157 ns/op
go version go1.6.2 linux/amd64
BenchmarkCgo-4 10000000 158 ns/op
go version go1.6.3 linux/amd64
BenchmarkCgo-4 10000000 158 ns/op
go version go1.7 linux/amd64
BenchmarkCgo-4 10000000 162 ns/op
go version go1.7.1 linux/amd64
BenchmarkCgo-4 10000000 164 ns/op
go version devel +9984195 Sun Oct 2 19:38:37 2016 +0000 linux/amd64
BenchmarkCgo-4 20000000 62.1 ns/op
|
@minux, what benchmark were you running? |
@aclements I think @minux was running the Go program at the top of the bug that just calls into a C function returning an int. |
Note that in addition to serial CGo slowness (i.e. ~ 60ns for 1 call) making several Cgo calls in sequence in presence of other goroutines can bring more slowdown: #19574 (comment). |
Now that https://golang.org/cl/171758 is merged for 1.13 fixing #6980, is that expected to help here as well?
|
FWIW, from a very quick test, using tip does not seem to be significantly faster than 1.12.5. Also, I don't know if this is already tracked elsewhere or perhaps not a meaningful result, but this quick test seems to show go1.10 improving, but go1.12 slowing down again.
This is running the benchmark from #9704 (comment) via
|
I confirm what @thepudds reports - there is improvement with go1.10, but slowdown back with go1.12, and things are not getting faster with tip:
All measurements were done on unloaded machine with CPU frequency fixed and CPU idle states except C1 disabled (see http://navytux.spb.ru/~kirr/neo.html#measurements-stability for details)
|
Running this stupid microbenchmark on linux/amd64, with different version of Go.
http://play.golang.org/p/5U0i26sA8U
Why? Go 1.4 is much worse than any of the previous releases.
And Go tip is even worse than Go 1.4. This might be understandable,
but I wonder why Go 1.4 is that much slower than 1.3.3?
The text was updated successfully, but these errors were encountered: