Golang Gets Cheaper Context Switching
Written by Michael Larabel in Programming on 1 June 2019 at 08:25 AM EDT. 15 Comments
PROGRAMMING --
As good news considering how much longer it takes to perform a full context switch on Intel CPUs due to various vulnerability mitigations, the Go programming language run-time now has the ability for performing cheaper context switches.

Landing in GCC 10 Git with the Golang code is a less involved context switching implementation for Linux x86_64 systems with the libgo run-time library.

Google's Ian Lance Taylor explained in the commit improving libgo, "Currently, goroutine switches are implemented with libc getcontext/setcontext functions, which saves/restores the machine register states and also the signal context. This does more than what we need, and performs an expensive syscall. This CL implements a simplified version of getcontext/setcontext, in assembly, that only saves/restores the necessary part, i.e. the callee-save registers, and the PC, SP. A simplified version of makecontext, written in C, is also added. Currently this is only implemented on Linux/AMD64."


As we've shown in numerous benchmarks recently and even more so after MDS/Zombieload mitigations, context switching can take multiple times longer compared to the pre/un-mitigated state on Intel CPUs in 2019.
About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 10,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter or contacted via MichaelLarabel.com.

Related Programming News
Popular News This Week