2 ms·
Why do people keep repeating this myth, when thread pinning is literally a one-liner? > LockOSThread wires the calling goroutine to its current operating syste
by majewsky 7y ago
Why do people keep repeating this myth, when thread pinning is literally a one-liner?
> LockOSThread wires the calling goroutine to its current operating system thread. The calling goroutine will always execute in that thread, and no other goroutine will execute in it, until the calling goroutine has made as many calls to UnlockOSThread as to LockOSThread. [...] A goroutine should call LockOSThread before calling OS services or non-Go library functions that depend on per-thread state.
Source: https://golang.org/pkg/runtime/#LockOSThread https://golang.org/pkg/runtime/#LockOSThread
- viraptor 7y agoIt's usually enough, but not always. For example namespaces and new threads don't handle this well, even if you do LockOSThread https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix https://www.weave.works/blog/linux-namespaces-and-go-don-t-m...
- rantanplan 7y agoThat has been fixed quite a while ago, in Go 1.10