-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
enhancementNew features or improvements of some kind, as opposed to a problem (bug)New features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validatedNew issues needed to be validated
Milestone
Description
We currently set GOMAXPROCS to the available number of CPU cores if nothing is explicitly configured by the user:
syncthing/cmd/syncthing/main.go
Lines 654 to 656 in 35e1536
| if os.Getenv("GOMAXPROCS") == "" { | |
| runtime.GOMAXPROCS(runtime.NumCPU()) | |
| } |
This doesn't play very nice with CPU quotas. See golang/go#33803
A possible solution might be https://github.com/uber-go/automaxprocs
if os.Getenv("GOMAXPROCS") == "" {
maxprocs.Set(maxprocs.Logger(log.Printf))
} We can even get away with a simple import, because automaxprocs honors GOMAXPROCS by default:
import _ "go.uber.org/automaxprocs"A blog post which covers this topic: https://www.riverphillips.dev/blog/go-cfs/
Metadata
Metadata
Assignees
Labels
enhancementNew features or improvements of some kind, as opposed to a problem (bug)New features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validatedNew issues needed to be validated