Skip to content

Commit a4a6a0c

Browse files
committed
chore: use Linux container CPU quota
Go is not cgroup aware and by default will set GOMAXPROCS to the number of available threads, regardless of whether it is within the allocated quota. This behaviour causes high amount of CPU throttling and degraded application performance. Fixes: AnalogJ#584
1 parent 5e33c33 commit a4a6a0c

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

collector/cmd/collector-metrics/collector-metrics.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
utils "github.com/analogj/go-util/utils"
1818
"github.com/fatih/color"
1919
"github.com/urfave/cli/v2"
20+
_ "go.uber.org/automaxprocs"
2021
)
2122

2223
var goos string
@@ -37,8 +38,8 @@ func main() {
3738
}
3839

3940
//we're going to load the config file manually, since we need to validate it.
40-
err = config.ReadConfig(configFilePath) // Find and read the config file
41-
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
41+
err = config.ReadConfig(configFilePath) // Find and read the config file
42+
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
4243
//ignore "could not find config file"
4344
} else if err != nil {
4445
os.Exit(1)

collector/cmd/collector-selftest/collector-selftest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
utils "github.com/analogj/go-util/utils"
1414
"github.com/fatih/color"
1515
"github.com/urfave/cli/v2"
16+
_ "go.uber.org/automaxprocs"
1617
)
1718

1819
var goos string

webapp/backend/cmd/scrutiny/scrutiny.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
utils "github.com/analogj/go-util/utils"
1717
"github.com/fatih/color"
1818
"github.com/urfave/cli/v2"
19+
_ "go.uber.org/automaxprocs"
1920
)
2021

2122
var goos string
@@ -36,8 +37,8 @@ func main() {
3637
}
3738

3839
//we're going to load the config file manually, since we need to validate it.
39-
err = config.ReadConfig(configFilePath) // Find and read the config file
40-
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
40+
err = config.ReadConfig(configFilePath) // Find and read the config file
41+
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
4142
//ignore "could not find config file"
4243
} else if err != nil {
4344
log.Print(color.HiRedString("CONFIG ERROR: %v", err))

webapp/backend/pkg/models/testdata/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/analogj/scrutiny/webapp/backend/pkg/models/collector"
15+
_ "go.uber.org/automaxprocs"
1516
)
1617

1718
func main() {

0 commit comments

Comments
 (0)