Documentation ¶
Overview ¶
Package automaxprocs automatically sets GOMAXPROCS to match the Linux container CPU quota, if any.
Example ¶
package main // Importing automaxprocs automatically adjusts GOMAXPROCS. import ( "fmt" "github.com/ovesh/automaxprocs/internal/cgroups" _ "go.uber.org/automaxprocs" ) // To render a whole-file example, we need a package-level declaration. var _ = "" func main() {} func getCurrentCPUAllocation() error { allCGroups, err := cgroups.NewCGroupsForCurrentProcess() if err != nil { return err } fmt.Printf("all allCGroups: %+v\n", allCGroups) quota, defined, err := allCGroups.CPUQuota() if !defined || err != nil { return err } fmt.Println("quota:", quota) return nil }
Output:
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
cgroups
Package cgroups provides utilities to access Linux control group (CGroups) parameters (CPU quota, for example) for a given process.
|
Package cgroups provides utilities to access Linux control group (CGroups) parameters (CPU quota, for example) for a given process. |
Package maxprocs lets Go programs easily configure runtime.GOMAXPROCS to match the configured Linux CPU quota.
|
Package maxprocs lets Go programs easily configure runtime.GOMAXPROCS to match the configured Linux CPU quota. |
Click to show internal directories.
Click to hide internal directories.