mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #18362 from runcom/tunable-SetMaxThreads
daemon_unix: set golang runtime max threads
This commit is contained in:
commit
4f37e14e9c
3 changed files with 28 additions and 0 deletions
|
@ -679,6 +679,10 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
|||
}
|
||||
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")
|
||||
if err := idtools.MkdirAllAs(daemonRepo, 0700, rootUID, rootGID); err != nil && !os.IsExist(err) {
|
||||
return nil, err
|
||||
|
|
|
@ -4,10 +4,12 @@ package daemon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
@ -462,6 +464,23 @@ func checkSystem() error {
|
|||
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
|
||||
func configureKernelSecuritySupport(config *Config, driverName string) error {
|
||||
if config.EnableSelinuxSupport {
|
||||
|
|
|
@ -115,6 +115,11 @@ func configureKernelSecuritySupport(config *Config, driverName string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// configureMaxThreads sets the Go runtime max threads threshold
|
||||
func configureMaxThreads(config *Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isBridgeNetworkDisabled(config *Config) bool {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue