Documentation
¶
Overview ¶
Package procload reports how much of the memory and CPU this process may use it is using now, as a percentage of what the container allows it.
It exists for the managed-script run worker, which admits a new run only while the replica has headroom (#1843). It knows nothing about scripts: it reads the process's own counters and the limits the container set, and says when it cannot know one, so its caller never refuses work on a number it made up.
Memory is the Go runtime's mapped memory less what it has returned to the operating system (runtime/metrics), against the smallest of the cgroup's memory limit and GOMEMLIMIT. CPU is the process's user and system time over a short window (getrusage), against the cgroup's CPU quota or, without one, GOMAXPROCS. The runtime's own /cpu/classes metrics are not used: they are only brought up to date at garbage collection, so between collections they describe a load that has already changed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MemoryLimit ¶ added in v1.135.1
func MemoryLimit() int64
MemoryLimit is the smallest memory limit in force on this process: the container's cgroup limit or GOMEMLIMIT, in bytes. Zero means none is set. It is what a limit stated as a share of the container's memory is a share of (#1861).
func SetSoftLimit ¶ added in v1.136.0
func SetSoftLimit() int64
SetSoftLimit gives the Go runtime a soft memory limit of 90% of the container's memory limit when the process has none, and returns the limit it set. It returns zero, changing nothing, when a soft limit is already in force (GOMEMLIMIT, or an earlier call) or no container limit is found.
Without a soft limit the collector runs at GOGC alone and lets the heap reach about twice the live set, so a process whose live set is half the container's limit is killed by the kernel before it collects (#1871). A managed-script run is allowed to hold a share of this limit by default.
Types ¶
type Sample ¶
Sample is one reading. A percentage whose Known flag is false could not be measured on this platform or under this configuration, and is zero.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler reads the process's load. Safe for concurrent use.