Friday, March 26, 2021

Go programs only using one CPU core

Hi,
it seems to me like Go (from the lang/go port) does not utilize more
than one CPU core on OpenBSD. Let's take this program, which may be run
with `go run main.go`:

package main
func main() {
go work()
work()
}
func work() {
for i := 1; ; {
i *= 1
}
}

The `go` directive starts a new goroutine, which I would expect to be
put into it's own process here. However, using htop(1) I can see, that
only one of my two cores gets load. Running the same program on Linux,
two cores are utilized.

Can someone explain to me why this is happening? Is there any way to
make the program use both cores of my CPU?

Best Regards,
Richard Ulmer

No comments:

Post a Comment