runtime

package
v0.0.0-...-a939f45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package runtime defines limits for the Go runtime

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumVCPU

func NumVCPU() int

NumVCPU returns the number of virtualizes CPUs available to the process. It should be used instead of runtime.NumCPU() in virtualized environments like K8s to ensure that processes don't attempt to over-subscribe CPUs. For example, on a 16 vCPU machine in a docker container allocated 8 vCPUs, runtime.NumCPU() will return 16 but NumVCPU() will return 8.

func SetGoMemLimit

func SetGoMemLimit(isContainerized bool) (int64, error)

SetGoMemLimit configures Go memory soft limit based on cgroups. The soft limit is set to 90% of the cgroup memory hard limit. The function is noop if

  • GOMEMLIMIT is set already
  • There is no cgroup limit

Read more about Go memory limit in https://tip.golang.org/doc/gc-guide#Memory_limit

func SetMaxProcs

func SetMaxProcs() bool

SetMaxProcs sets the GOMAXPROCS for the go runtime to a sane value

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL