Skip to content

Commit

Permalink
chore: use Linux container CPU quota
Browse files Browse the repository at this point in the history
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
  • Loading branch information
uhthomas committed Feb 26, 2024
1 parent 5e33c33 commit a4a6a0c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions collector/cmd/collector-metrics/collector-metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
utils "github.com/analogj/go-util/utils"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
_ "go.uber.org/automaxprocs"
)

var goos string
Expand All @@ -37,8 +38,8 @@ func main() {
}

//we're going to load the config file manually, since we need to validate it.
err = config.ReadConfig(configFilePath) // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
err = config.ReadConfig(configFilePath) // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
//ignore "could not find config file"
} else if err != nil {
os.Exit(1)
Expand Down
1 change: 1 addition & 0 deletions collector/cmd/collector-selftest/collector-selftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
utils "github.com/analogj/go-util/utils"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
_ "go.uber.org/automaxprocs"
)

var goos string
Expand Down
5 changes: 3 additions & 2 deletions webapp/backend/cmd/scrutiny/scrutiny.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
utils "github.com/analogj/go-util/utils"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
_ "go.uber.org/automaxprocs"
)

var goos string
Expand All @@ -36,8 +37,8 @@ func main() {
}

//we're going to load the config file manually, since we need to validate it.
err = config.ReadConfig(configFilePath) // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
err = config.ReadConfig(configFilePath) // Find and read the config file
if _, ok := err.(errors.ConfigFileMissingError); ok { // Handle errors reading the config file
//ignore "could not find config file"
} else if err != nil {
log.Print(color.HiRedString("CONFIG ERROR: %v", err))
Expand Down
1 change: 1 addition & 0 deletions webapp/backend/pkg/models/testdata/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/analogj/scrutiny/webapp/backend/pkg/models/collector"
_ "go.uber.org/automaxprocs"
)

func main() {
Expand Down

0 comments on commit a4a6a0c

Please sign in to comment.