all: Use Linux container CPU quota (fixes #9357, fixes #9435) (#9436)

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.
This commit is contained in:
Thomas
2024-02-26 12:23:14 +00:00
committed by GitHub
parent 2d968d46b7
commit aa559bf496
21 changed files with 34 additions and 12 deletions
+1
View File
@@ -16,6 +16,7 @@ import (
"path/filepath"
"github.com/syncthing/syncthing/lib/sha256"
_ "go.uber.org/automaxprocs"
)
func main() {
+2 -2
View File
@@ -23,11 +23,11 @@ import (
"path/filepath"
"github.com/alecthomas/kong"
raven "github.com/getsentry/raven-go"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/syncthing/syncthing/lib/sha256"
"github.com/syncthing/syncthing/lib/ur"
raven "github.com/getsentry/raven-go"
_ "go.uber.org/automaxprocs"
)
const maxRequestSize = 1 << 20 // 1 MiB
+1
View File
@@ -18,6 +18,7 @@ import (
"github.com/syncthing/syncthing/lib/beacon"
"github.com/syncthing/syncthing/lib/discover"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)
var (
+1
View File
@@ -24,6 +24,7 @@ import (
"github.com/syncthing/syncthing/lib/tlsutil"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/thejerf/suture/v4"
_ "go.uber.org/automaxprocs"
)
const (
+2
View File
@@ -14,6 +14,8 @@ import (
"net/http"
"os"
"time"
_ "go.uber.org/automaxprocs"
)
type event struct {
+1
View File
@@ -15,6 +15,7 @@ import (
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/scanner"
_ "go.uber.org/automaxprocs"
)
func main() {
+1
View File
@@ -20,6 +20,7 @@ import (
"github.com/syncthing/syncthing/lib/discover"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)
var timeout = 5 * time.Second
+1
View File
@@ -14,6 +14,7 @@ import (
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/ignore"
_ "go.uber.org/automaxprocs"
)
func main() {
+2
View File
@@ -15,6 +15,8 @@ import (
"os"
"path/filepath"
"time"
_ "go.uber.org/automaxprocs"
)
func main() {
+3 -3
View File
@@ -21,18 +21,18 @@ import (
"time"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/syncthing/syncthing/lib/httpcache"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/oschwald/geoip2-golang"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto"
"github.com/syncthing/syncthing/lib/assets"
"github.com/syncthing/syncthing/lib/httpcache"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
"github.com/syncthing/syncthing/lib/relay/client"
"github.com/syncthing/syncthing/lib/sync"
"github.com/syncthing/syncthing/lib/tlsutil"
_ "go.uber.org/automaxprocs"
)
type location struct {
+6 -7
View File
@@ -20,18 +20,17 @@ import (
"time"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/nat"
"github.com/syncthing/syncthing/lib/osutil"
_ "github.com/syncthing/syncthing/lib/pmp"
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/relay/protocol"
"github.com/syncthing/syncthing/lib/tlsutil"
"golang.org/x/time/rate"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/nat"
_ "github.com/syncthing/syncthing/lib/pmp"
_ "github.com/syncthing/syncthing/lib/upnp"
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
"golang.org/x/time/rate"
)
var (
+1
View File
@@ -17,6 +17,7 @@ import (
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/relay/client"
"github.com/syncthing/syncthing/lib/relay/protocol"
_ "go.uber.org/automaxprocs"
)
func main() {
+1
View File
@@ -14,6 +14,7 @@ import (
"github.com/syncthing/syncthing/lib/signature"
"github.com/syncthing/syncthing/lib/upgrade"
_ "go.uber.org/automaxprocs"
)
func main() {
+1
View File
@@ -21,6 +21,7 @@ import (
"github.com/alecthomas/kong"
"github.com/syncthing/syncthing/lib/httpcache"
"github.com/syncthing/syncthing/lib/upgrade"
_ "go.uber.org/automaxprocs"
)
type cli struct {
+1
View File
@@ -27,6 +27,7 @@ import (
"time"
"github.com/syncthing/syncthing/lib/protocol"
_ "go.uber.org/automaxprocs"
)
type result struct {
+1
View File
@@ -14,6 +14,7 @@ import (
"time"
"github.com/syncthing/syncthing/lib/sha256"
_ "go.uber.org/automaxprocs"
)
func main() {
+1
View File
@@ -32,6 +32,7 @@ import (
"github.com/alecthomas/kong"
"github.com/thejerf/suture/v4"
"github.com/willabides/kongplete"
_ "go.uber.org/automaxprocs"
"github.com/syncthing/syncthing/cmd/syncthing/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
+1
View File
@@ -13,6 +13,7 @@ import (
"github.com/alecthomas/kong"
"github.com/syncthing/syncthing/cmd/ursrv/aggregate"
"github.com/syncthing/syncthing/cmd/ursrv/serve"
_ "go.uber.org/automaxprocs"
)
type CLI struct {