Less cgo overhead in Go 1.8


One spare afternoon a few months ago I read through the cgo calling code in the Go runtime. There were two defers that could be merged into one, so I did.

Combined with Austin's improvements to defer's overall performance (CL 29656), the 146ns call to an empty C function in Go 1.7 is now a 56ns call in Go 1.8:

name       old time/op  new time/op  delta
CgoNoop-8   146ns ± 1%    56ns ± 6%  -61.57%  (p=0.000 n=25+30)
This is a good reminder to me of the important of making time for idle rummaging around in code. For the past six months I have done very little of it, as the piles of well-defined work I have seemed too important. But looking back over what came of that work, this idle afternoon is probably the most impactful thing I have done recently.golang.org/cl/30080

[email protected]