monitor

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseNoopMemMonitor

func UseNoopMemMonitor()

UseNoopMemMonitor creates a noop implementation of mem-monitor if we want to fully disable it with minimal penalty

Types

type MemMonitor

type MemMonitor interface {
	// Increment adds the mem used by the given MemAccountable to the internal counter
	// Call this when initializing a new instance of that MemAccountable
	Increment(Sizeable)
	// Decrement subtracts the mem used by the given MemAccountable from the internal counter
	// Call this when the last ref to that MemAccountable is given up
	Decrement(Sizeable)
	// Fence blocks while mem usage accounted by MemManager is above the watermark
	// Multiple goroutines can call and be blocked by Fence
	Fence()
	// Breached returns true if mem usage is currently above the watermark and hasn't gone below recoveryWatermark yet
	Breached() bool
}

MemMonitor watches memory usages and provides alarms when usage breaches watermark Users of the monitor should call Fence() to stall operations while alarms are breached Fence blocks till accounted memory usage falls below the recovery watermark which is lower than the actual threshold to enable some breathing room It is safe to call methods on MemMonitor from multiple goroutines

func GetMemMonitor

func GetMemMonitor() MemMonitor

GetMemMonitor returns a ready mem monitor - Call ConfigureMemMonitor before this otherwise this method will panic

type Sizeable

type Sizeable interface {
	SizeOf() uint64
}

Sizeable struct is one that wishes to enable mem accounting for itself

Jump to

Keyboard shortcuts

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