Skip to content

Commit

Permalink
Merge pull request kubernetes#29094 from luxas/gomaxproc
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Remove GOMAXPROCS() calls because they are unnecessary


Now we're setting GOMAXPROCS when every binary starts up, but we don't have to do that anymore, since we've upgraded to Go 1.6

Documentation for it:

> func GOMAXPROCS(n int) int

> GOMAXPROCS sets the maximum number of CPUs that can be executing simultaneously and returns the previous setting. If n < 1, it does not change the current setting. The number of logical CPUs on the local machine can be queried with NumCPU. This call will go away when the scheduler improves. 

A simple program to prove it's unnecessary:

```go
package main
import (
    "fmt"
    "runtime"
)
func main(){
    numCPUBefore := runtime.GOMAXPROCS(runtime.NumCPU())
    numCPUAfter := runtime.GOMAXPROCS(runtime.NumCPU())
    fmt.Println(numCPUBefore, numCPUAfter)
}
```

Output with Go 1.4.2: `1 4`
Output with Go 1.6.2: `4 4`

So I think we should remove calls to GOMAXPROCS now, and it should be pretty straightforward

@thockin @wojtek-t @gmarek @lavalamp @vishh
  • Loading branch information
k8s-merge-robot authored Jul 19, 2016
2 parents 73a3d48 + 88ea80b commit 4466531
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 33 deletions.
2 changes: 0 additions & 2 deletions cmd/genswaggertypedocs/swagger_type_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io"
"os"
"runtime"

kruntime "k8s.io/kubernetes/pkg/runtime"

Expand All @@ -35,7 +34,6 @@ var (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()

if *typeSrc == "" {
Expand Down
2 changes: 0 additions & 2 deletions cmd/hyperkube/hyperkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"io/ioutil"
"os"
"path"
"runtime"

"k8s.io/kubernetes/pkg/util"
utilflag "k8s.io/kubernetes/pkg/util/flag"
Expand Down Expand Up @@ -188,7 +187,6 @@ func (hk *HyperKube) Run(args []string) error {

// RunToExit will run the hyperkube and then call os.Exit with an appropriate exit code.
func (hk *HyperKube) RunToExit(args []string) {
runtime.GOMAXPROCS(runtime.NumCPU())
err := hk.Run(args)
if err != nil {
fmt.Fprint(os.Stderr, err.Error())
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"math/rand"
"os"
"runtime"
"time"

"k8s.io/kubernetes/cmd/kube-apiserver/app"
Expand All @@ -35,7 +34,6 @@ import (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
rand.Seed(time.Now().UTC().UnixNano())

s := options.NewAPIServer()
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package main
import (
"fmt"
"os"
"runtime"

"k8s.io/kubernetes/cmd/kube-controller-manager/app"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
Expand All @@ -40,7 +39,6 @@ func init() {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := options.NewCMServer()
s.AddFlags(pflag.CommandLine)

Expand Down
5 changes: 3 additions & 2 deletions cmd/kube-dns/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"os"

"fmt"
"github.com/spf13/pflag"
"k8s.io/kubernetes/pkg/util/validation"
_ "net/http/pprof"
"strings"

"github.com/spf13/pflag"
"k8s.io/kubernetes/pkg/util/validation"
)

type KubeDNSConfig struct {
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"os"
"runtime"

"k8s.io/kubernetes/cmd/kube-proxy/app"
"k8s.io/kubernetes/cmd/kube-proxy/app/options"
Expand All @@ -36,7 +35,6 @@ func init() {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
config := options.NewProxyConfig()
config.AddFlags(pflag.CommandLine)

Expand Down
2 changes: 0 additions & 2 deletions cmd/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ package main

import (
"os"
"runtime"

"k8s.io/kubernetes/cmd/kubectl/app"
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
if err := app.Run(); err != nil {
os.Exit(1)
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package main
import (
"fmt"
"os"
"runtime"

"k8s.io/kubernetes/cmd/kubelet/app"
"k8s.io/kubernetes/cmd/kubelet/app/options"
Expand All @@ -35,7 +34,6 @@ import (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := options.NewKubeletServer()
s.AddFlags(pflag.CommandLine)

Expand Down
2 changes: 0 additions & 2 deletions cmd/kubemark/hollow-node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"fmt"
"runtime"

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/record"
Expand Down Expand Up @@ -83,7 +82,6 @@ func (c *HollowNodeConfig) createClientFromFile() (*client.Client, error) {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

config := HollowNodeConfig{}
config.addFlags(pflag.CommandLine)
Expand Down
2 changes: 0 additions & 2 deletions contrib/mesos/cmd/k8sm-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"os"
"runtime"

"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/util"
Expand All @@ -36,7 +35,6 @@ func init() {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

s := controllermanager.NewCMServer()
s.AddFlags(pflag.CommandLine)
Expand Down
2 changes: 0 additions & 2 deletions contrib/mesos/cmd/k8sm-executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"os"
"runtime"

"github.com/spf13/pflag"
"k8s.io/kubernetes/contrib/mesos/pkg/executor/service"
Expand All @@ -30,7 +29,6 @@ import (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

s := service.NewKubeletExecutorServer()
s.AddFlags(pflag.CommandLine)
Expand Down
2 changes: 0 additions & 2 deletions contrib/mesos/cmd/k8sm-scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"os"
"runtime"

"github.com/spf13/pflag"
"k8s.io/kubernetes/contrib/mesos/pkg/hyperkube"
Expand All @@ -30,7 +29,6 @@ import (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := service.NewSchedulerServer()
s.AddStandaloneFlags(pflag.CommandLine)

Expand Down
2 changes: 0 additions & 2 deletions contrib/mesos/cmd/km/hyperkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"io/ioutil"
"os"
"path"
"runtime"

"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/version/verflag"
Expand Down Expand Up @@ -177,7 +176,6 @@ func (hk *HyperKube) Run(args []string) error {

// RunToExit will run the hyperkube and then call os.Exit with an appropriate exit code.
func (hk *HyperKube) RunToExit(args []string) {
runtime.GOMAXPROCS(runtime.NumCPU())
err := hk.Run(args)
if err != nil {
fmt.Fprint(os.Stderr, err.Error())
Expand Down
2 changes: 0 additions & 2 deletions federation/cmd/federation-apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"math/rand"
"os"
"runtime"
"time"

"k8s.io/kubernetes/federation/cmd/federation-apiserver/app"
Expand All @@ -35,7 +34,6 @@ import (
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
rand.Seed(time.Now().UTC().UnixNano())

s := genericoptions.NewServerRunOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"os"
"runtime"

"github.com/spf13/pflag"
"k8s.io/kubernetes/federation/cmd/federation-controller-manager/app"
Expand All @@ -35,7 +34,6 @@ func init() {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := options.NewCMServer()
s.AddFlags(pflag.CommandLine)

Expand Down
3 changes: 0 additions & 3 deletions plugin/cmd/kube-scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package main

import (
"runtime"

"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
Expand All @@ -34,7 +32,6 @@ func init() {
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
s := options.NewSchedulerServer()
s.AddFlags(pflag.CommandLine)

Expand Down

0 comments on commit 4466531

Please sign in to comment.