talos/pkg/startup/maxprocs.go
Andrey Smirnov 8c3ac4c42b
chore: limit GOMAXPROCS for Talos services
Fixes #5971

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-08-24 15:42:49 +04:00

22 lines
499 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package startup
import (
"log"
"runtime"
)
// LimitMaxProcs limits the GOMAXPROCS to the number specified.
func LimitMaxProcs(maxProcs int) {
curProcs := runtime.GOMAXPROCS(0)
if curProcs > maxProcs {
runtime.GOMAXPROCS(maxProcs)
log.Printf("limited GOMAXPROCS to %d", maxProcs)
}
}