I have Go code that I am testing on my Macbook (Intel Core i5 processor with two physical cores).
Go runtime.NumCPU()gives 4 because it considers "virtual kernels"
I don’t know much about virtual kernels in this context, but my tests show that multiprocessing is only 2 times faster when I configure my code using
runtime.GOMAXPROCS(runtime.NumCPU())
I get the same performance if I use 2 cores instead of 4. I would publish the code, but I think it is largely irrelevant to my questions, namely:
1) is this normal?
2) why, if so, do multiple virtual cores benefit a machine like my macbook?
Update:
In case this matters, in my code there are the same number of procedures as what you install runtime.GOMAXPROCS(), the tasks are completely parallel, do not have interdependencies or general state. it works as its own compiled binary.
source
share