News for hackers. Stuff that matters.
Re:On Go, Portability, and System Interfaces by pcwalton on Wednesday September 23, 2015 @12:19PM (#10265962)
> Stack switching doesn't take more than a few machine instructions.

In Rust we found that stack switching was really slow, even when fully optimized to that scheme. CPUs really don't like it. We thought "it was only a few instructions; how bad can it be"; turns out that any function call overhead can quickly add up to 2x or more overall performance penalties in some programs.

See the performance numbers in this thread for cgo (using the same technique) [1]. According to the first benchmark, calling the function via cgo is 16x slower. You're at 161ns for a no-op function call.

Consider that the cost of a syscall can be below 100ns [2]. The overhead can add up quite a bit!

[1]: https://groups.google.com/forum/#!topic/golang-nuts/RTtMsgZi...

[2]: http://forum.osdev.org/viewtopic.php?p=209429&sid=9bcec5b684...

There are no comments on this comment yet.