On Wed, Mar 23, 2016 at 8:14 PM, Adam Strzelecki wrote:

minux wrote:
The overhead of cgo calls are definitely not because of switching stacks,
because it's just switching a few registers. If switching stack is the main
bottleneck, then switching goroutinea will see similar slowness.
I think such switch isn't a really a problem when it happens once per few
milliseconds to switch coroutine, but can be a problem when occurs one
every cgo call in some tight loop of Go code calling external API.
I did an experiment with Go tip:
$ go run issue9704.go -test.bench=1
testing: warning: no tests to run
BenchmarkCgo-4 10000000 144 ns/op

Then I modified cgocall to remove all scheduler interactions,

$ go run issue9704.go -test.bench=1
testing: warning: no tests to run
BenchmarkCgo-4 100000000 15.8 ns/op

It's definitely more heavyweight than a direct call, but ~90% of the cgo
call overhead
comes from scheduler interaction, rather than from stack switch overhead.

You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 13 | next ›
Discussion Overview
groupgolang-dev @
postedMar 23, '16 at 9:32p
activeMar 24, '16 at 8:34a



site design / logo © 2021 Grokbase