March 2020
Intermediate to advanced
406 pages
8h 39m
English
GOMAXPROCS is a variable that can be tuned to allow us to control the number of threads that our operating system will allocate to our goroutines within our Go binary. By default, GOMAXPROCS is equal to the number of cores available to the application. This is dynamically configurable via the runtime package. It is important to note that as of Go 1.10, GOMAXPROCS will have no upper bound limit.
If we have a function that is CPU-intensive and parallelized (such as goroutine sorting strings), we will see some serious improvements if we adjust the number of GOMAXPROCS we have. In the following code example, we are going to test building the standard library with a different number set for GOMAXPROCS:
#!/bin/bashfor i in 1 2 3 4
Read now
Unlock full access