mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon_unix: set golang runtime max threads
SetMaxThreads from runtime/debug in Golang is called to set max threads value to 90% of /proc/sys/kernel/threads-max Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
d069e8e7b7
commit
140a74347d
3 changed files with 28 additions and 0 deletions
|
@ -678,6 +678,10 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
||||||
}
|
}
|
||||||
logrus.Debugf("Using default logging driver %s", config.LogConfig.Type)
|
logrus.Debugf("Using default logging driver %s", config.LogConfig.Type)
|
||||||
|
|
||||||
|
if err := configureMaxThreads(config); err != nil {
|
||||||
|
logrus.Warnf("Failed to configure golang's threads limit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
daemonRepo := filepath.Join(config.Root, "containers")
|
daemonRepo := filepath.Join(config.Root, "containers")
|
||||||
if err := idtools.MkdirAllAs(daemonRepo, 0700, rootUID, rootGID); err != nil && !os.IsExist(err) {
|
if err := idtools.MkdirAllAs(daemonRepo, 0700, rootUID, rootGID); err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -4,10 +4,12 @@ package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -462,6 +464,23 @@ func checkSystem() error {
|
||||||
return checkKernel()
|
return checkKernel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configureMaxThreads sets the Go runtime max threads threshold
|
||||||
|
// which is 90% of the kernel setting from /proc/sys/kernel/threads-max
|
||||||
|
func configureMaxThreads(config *Config) error {
|
||||||
|
mt, err := ioutil.ReadFile("/proc/sys/kernel/threads-max")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mtint, err := strconv.Atoi(strings.TrimSpace(string(mt)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
maxThreads := (mtint / 100) * 90
|
||||||
|
debug.SetMaxThreads(maxThreads)
|
||||||
|
logrus.Debugf("Golang's threads limit set to %d", maxThreads)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// configureKernelSecuritySupport configures and validate security support for the kernel
|
// configureKernelSecuritySupport configures and validate security support for the kernel
|
||||||
func configureKernelSecuritySupport(config *Config, driverName string) error {
|
func configureKernelSecuritySupport(config *Config, driverName string) error {
|
||||||
if config.EnableSelinuxSupport {
|
if config.EnableSelinuxSupport {
|
||||||
|
|
|
@ -115,6 +115,11 @@ func configureKernelSecuritySupport(config *Config, driverName string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configureMaxThreads sets the Go runtime max threads threshold
|
||||||
|
func configureMaxThreads(config *Config) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func isBridgeNetworkDisabled(config *Config) bool {
|
func isBridgeNetworkDisabled(config *Config) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue