Skip to content

Commit

Permalink
Merge pull request #2789 from andyzhangx/GoMaxProcs
Browse files Browse the repository at this point in the history
chore: set GoMaxProcs as 2
  • Loading branch information
andyzhangx authored Jan 3, 2025
2 parents 0675d88 + f5cfabe commit ec44fac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/azuredisk/azuredisk_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type DriverOptions struct {
RemoveNotReadyTaint bool
MaxConcurrentFormat int64
ConcurrentFormatTimeout int64
GoMaxProcs int64
}

func (o *DriverOptions) AddFlags() *flag.FlagSet {
Expand Down Expand Up @@ -109,6 +110,6 @@ func (o *DriverOptions) AddFlags() *flag.FlagSet {
fs.StringVar(&o.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
fs.Int64Var(&o.MaxConcurrentFormat, "max-concurrent-format", 2, "maximum number of concurrent format exec calls")
fs.Int64Var(&o.ConcurrentFormatTimeout, "concurrent-format-timeout", 300, "maximum time in seconds duration of a format operation before its concurrency token is released")

fs.Int64Var(&o.GoMaxProcs, "max-procs", 2, "maximum number of CPUs that can be executing simultaneously in golang runtime")
return fs
}
4 changes: 4 additions & 0 deletions pkg/azurediskplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net"
"net/http"
"os"
"runtime"
"strings"

"k8s.io/component-base/metrics/legacyregistry"
Expand Down Expand Up @@ -82,6 +83,9 @@ func handlePreStopHook(kubeconfig string) {
}

func handle() {
runtime.GOMAXPROCS(int(driverOptions.GoMaxProcs))
klog.Infof("Sys info: NumCPU: %v MAXPROC: %v", runtime.NumCPU(), runtime.GOMAXPROCS(0))

driver := azuredisk.NewDriver(&driverOptions)
if driver == nil {
klog.Fatalln("Failed to initialize azuredisk CSI Driver")
Expand Down

0 comments on commit ec44fac

Please sign in to comment.