Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  How does GoLang know how many CPUs to use?

When running lscpu command on Linux, it will list the CPU info on the machine. Take one example where there is one CPU with 2 cores and each core has two threads which indicates there are 4 cores available.Now let's see how many cores GoLang program would identify.From output, NumCPU and GOMAXPROCS both output 4 which is expected. How does go runtime get this info, does it get it through similar command like lscpu or /proc/cpuinfo? Let's dig more in GoLang's source code.In runtime/debug.go, it tells that this value is from the global variable ncpu which is set when process starts and...

6,862 0       CPU GOLANG NCPU