3 ms·
Yup, here's what I normally use for these situations (posted it in disqus too at end of article): // Initialize to use all available CPU cores func init() {
by dingdingdang 12y ago
Yup, here's what I normally use for these situations (posted it in disqus too at end of article):
// Initialize to use all available CPU cores
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
- malkia 12y agoMaybe GOMAXPROCS exists so that the number of hw threads that might be spawn by the go application can be controlled in a more system-agnostic way. Without such env varianle, on Windows (for example) you can control this with CPU affinity (and possibly other better ways), but not sure about Linux/OSX/etc. So this kind of deals with it upfront.