Golang Gets Cheaper Context Switching
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.
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.
15 Comments