runtime - what is the GOMAXPROCS default value -
is guaranteed gomaxprocs set 1 when environment variable of same name not set?
this code shows value:
package main import ( "runtime" "fmt" ) func getgomaxprocs() int { return runtime.gomaxprocs(0) } func main() { fmt.printf("gomaxprocs %d\n", getgomaxprocs()) }
and running this:
$ gomaxprocs= go run max.go gomaxprocs 1
shows 1 in case, looking confirmation here.
no, there's no guarantee default is; though known implementations use value '1'. if code, in absence of environment variable, requires specific default value should set in code. additionally:
gomaxprocs sets maximum number of cpus can executing simultaneously , returns previous setting. if n < 1, not change current setting. number of logical cpus on local machine can queried numcpu. this call go away when scheduler improves.
(emphasis mine)
Comments
Post a Comment