Documentation
¶
Overview ¶
Package gcmon pkg/gcmon/gcmon.go c1-util-debug
A small sampler over the standard runtime/metrics package. It keeps a fixed ring of samples so garbage collector behavior can be read off a live process, and it behaves the same under Go and TinyGo because it only uses metric names. A metric the runtime does not know is reported as absent.
Index ¶
Constants ¶
const DefaultSamples = 360
DefaultSamples is the default ring length, about 30 minutes at Interval.
const Interval = 5 * time.Second
Interval is the time between samples.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure(samples int)
Configure sets the ring length of the default sampler from the visor config. Zero keeps DefaultSamples. It has no effect once the sampler has started.
func DefaultHandler ¶
DefaultHandler serves the process wide sampler.
Types ¶
type Pauses ¶
type Pauses struct {
Count uint64 `json:"count"`
P50S float64 `json:"p50_s"`
P99S float64 `json:"p99_s"`
MaxS float64 `json:"max_s"`
}
Pauses summarizes a pause histogram. Values are bucket upper bounds, so they round up to the histogram resolution.
type Sample ¶
type Sample struct {
At time.Time
Have uint32
Live uint64
Goal uint64
Limit uint64
Cycles uint64
CPUPause float64
CPUGC float64
CPUTotal float64
Objects uint64
Free uint64
Released uint64
MemTotal uint64
Goroutines uint64
RSS uint64
Threads uint64
}
Sample is one reading. Have is a bitmask of the metrics that were present, bit i for the i-th name in metricNames, plus bitRSS and bitThreads.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler holds the ring. The zero value is not usable, use New.
func Default ¶
func Default() *Sampler
Default returns the process wide sampler, starting it on first use. Its ring length comes from Configure.
func (*Sampler) Sample ¶
func (s *Sampler) Sample()
Sample takes one reading and appends it to the ring.
func (*Sampler) Start ¶
func (s *Sampler) Start()
Start samples now and then every Interval until Stop is called.
type State ¶
type State struct {
Compiler string `json:"compiler"`
GoVersion string `json:"go_version"`
GOMAXPROCS int `json:"gomaxprocs"`
NumCPU int `json:"num_cpu"`
Goroutines *uint64 `json:"goroutines,omitempty"`
Threads *uint64 `json:"threads,omitempty"`
RSSBytes *uint64 `json:"rss_bytes,omitempty"`
HeapLiveBytes *uint64 `json:"heap_live_bytes,omitempty"`
HeapGoalBytes *uint64 `json:"heap_goal_bytes,omitempty"`
GoMemLimitBytes *uint64 `json:"gomemlimit_bytes,omitempty"`
HeapObjectsBytes *uint64 `json:"heap_objects_bytes,omitempty"`
HeapFreeBytes *uint64 `json:"heap_free_bytes,omitempty"`
HeapReleasedBytes *uint64 `json:"heap_released_bytes,omitempty"`
MemoryTotalBytes *uint64 `json:"memory_total_bytes,omitempty"`
GCCycles *uint64 `json:"gc_cycles,omitempty"`
CPUTotalS *float64 `json:"cpu_total_seconds,omitempty"`
CPUGCS *float64 `json:"cpu_gc_seconds,omitempty"`
CPUGCPauseS *float64 `json:"cpu_gc_pause_seconds,omitempty"`
// LiveLimitRatio is live heap over the memory limit, omitted when no
// limit is set.
LiveLimitRatio *float64 `json:"live_limit_ratio,omitempty"`
// PausesTotal covers the whole run.
PausesTotal *Pauses `json:"pauses_total,omitempty"`
Last1m *Window `json:"last_1m,omitempty"`
Last5m *Window `json:"last_5m,omitempty"`
SamplerIntervalS float64 `json:"sampler_interval_s"`
SamplerSamples int `json:"sampler_samples"`
SamplerCapacity int `json:"sampler_capacity"`
}
State is the runtime section of the visor state snapshot. A pointer field is omitted when the runtime did not report that metric.
type TraceLine ¶
type TraceLine struct {
Time time.Time `json:"time"`
CyclesDelta uint64 `json:"cycles_delta"`
PauseSDelta float64 `json:"pause_seconds_delta"`
LiveBytes uint64 `json:"live_bytes"`
GoalBytes uint64 `json:"goal_bytes"`
ObjectsBytes uint64 `json:"heap_objects_bytes"`
RSSBytes uint64 `json:"rss_bytes"`
Goroutines uint64 `json:"goroutines"`
}
TraceLine is one row of the trace, with deltas against the previous sample.
type Window ¶
type Window struct {
// CoveredS is the span actually covered, less than the window when the
// sampler is younger than it.
CoveredS float64 `json:"covered_s"`
PauseShare *float64 `json:"pause_share,omitempty"`
// GCShare is the fraction of CPU time spent in the collector in total.
CollectionsPerMin *float64 `json:"collections_per_min,omitempty"`
PauseS *float64 `json:"pause_seconds,omitempty"`
Pauses *Pauses `json:"pauses,omitempty"`
}
Window is the derived figures over the most recent stretch of samples.