collector

package
v0.0.0-...-3f388d4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PERF_SAMPLE_IDENTIFIER is not defined in x/sys/unix.
	PERF_SAMPLE_IDENTIFIER = 1 << 16
)

Variables

View Source
var PerfBitMap = map[string]uint64{
	"PerfBitDisabled":               unix.PerfBitDisabled,
	"PerfBitInherit":                unix.PerfBitInherit,
	"PerfBitPinned":                 unix.PerfBitPinned,
	"PerfBitExclusive":              unix.PerfBitExclusive,
	"PerfBitExcludeUser":            unix.PerfBitExcludeUser,
	"PerfBitExcludeKernel":          unix.PerfBitExcludeKernel,
	"PerfBitExcludeHv":              unix.PerfBitExcludeHv,
	"PerfBitExcludeIdle":            unix.PerfBitExcludeIdle,
	"PerfBitMmap":                   unix.PerfBitMmap,
	"PerfBitComm":                   unix.PerfBitComm,
	"PerfBitFreq":                   unix.PerfBitFreq,
	"PerfBitInheritStat":            unix.PerfBitInheritStat,
	"PerfBitEnableOnExec":           unix.PerfBitEnableOnExec,
	"PerfBitTask":                   unix.PerfBitTask,
	"PerfBitWatermark":              unix.PerfBitWatermark,
	"PerfBitPreciseIPBit1":          unix.PerfBitPreciseIPBit1,
	"PerfBitPreciseIPBit2":          unix.PerfBitPreciseIPBit2,
	"PerfBitMmapData":               unix.PerfBitMmapData,
	"PerfBitSampleIDAll":            unix.PerfBitSampleIDAll,
	"PerfBitExcludeHost":            unix.PerfBitExcludeHost,
	"PerfBitExcludeGuest":           unix.PerfBitExcludeGuest,
	"PerfBitExcludeCallchainKernel": unix.PerfBitExcludeCallchainKernel,
	"PerfBitExcludeCallchainUser":   unix.PerfBitExcludeCallchainUser,
	"PerfBitMmap2":                  unix.PerfBitMmap2,
	"PerfBitCommExec":               unix.PerfBitCommExec,
	"PerfBitUseClockID":             unix.PerfBitUseClockID,
	"PerfBitContextSwitch":          unix.PerfBitContextSwitch,
}
View Source
var PerfConfigMap = map[string]uint64{
	"PERF_COUNT_HW_CPU_CYCLES":              unix.PERF_COUNT_HW_CPU_CYCLES,
	"PERF_COUNT_HW_INSTRUCTIONS":            unix.PERF_COUNT_HW_INSTRUCTIONS,
	"PERF_COUNT_HW_CACHE_REFERENCES":        unix.PERF_COUNT_HW_CACHE_REFERENCES,
	"PERF_COUNT_HW_CACHE_MISSES":            unix.PERF_COUNT_HW_CACHE_MISSES,
	"PERF_COUNT_HW_BRANCH_INSTRUCTIONS":     unix.PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
	"PERF_COUNT_HW_BRANCH_MISSES":           unix.PERF_COUNT_HW_BRANCH_MISSES,
	"PERF_COUNT_HW_BUS_CYCLES":              unix.PERF_COUNT_HW_BUS_CYCLES,
	"PERF_COUNT_HW_STALLED_CYCLES_FRONTEND": unix.PERF_COUNT_HW_STALLED_CYCLES_FRONTEND,
	"PERF_COUNT_HW_STALLED_CYCLES_BACKEND":  unix.PERF_COUNT_HW_STALLED_CYCLES_BACKEND,
	"PERF_COUNT_HW_REF_CPU_CYCLES":          unix.PERF_COUNT_HW_REF_CPU_CYCLES,
	"PERF_COUNT_HW_MAX":                     unix.PERF_COUNT_HW_MAX,
	"PERF_COUNT_HW_CACHE_L1D":               unix.PERF_COUNT_HW_CACHE_L1D,
	"PERF_COUNT_HW_CACHE_L1I":               unix.PERF_COUNT_HW_CACHE_L1I,
	"PERF_COUNT_HW_CACHE_LL":                unix.PERF_COUNT_HW_CACHE_LL,
	"PERF_COUNT_HW_CACHE_DTLB":              unix.PERF_COUNT_HW_CACHE_DTLB,
	"PERF_COUNT_HW_CACHE_ITLB":              unix.PERF_COUNT_HW_CACHE_ITLB,
	"PERF_COUNT_HW_CACHE_BPU":               unix.PERF_COUNT_HW_CACHE_BPU,
	"PERF_COUNT_HW_CACHE_NODE":              unix.PERF_COUNT_HW_CACHE_NODE,
	"PERF_COUNT_HW_CACHE_MAX":               unix.PERF_COUNT_HW_CACHE_MAX,
	"PERF_COUNT_HW_CACHE_OP_READ":           unix.PERF_COUNT_HW_CACHE_OP_READ,
	"PERF_COUNT_HW_CACHE_OP_WRITE":          unix.PERF_COUNT_HW_CACHE_OP_WRITE,
	"PERF_COUNT_HW_CACHE_OP_PREFETCH":       unix.PERF_COUNT_HW_CACHE_OP_PREFETCH,
	"PERF_COUNT_HW_CACHE_OP_MAX":            unix.PERF_COUNT_HW_CACHE_OP_MAX,
	"PERF_COUNT_HW_CACHE_RESULT_ACCESS":     unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS,
	"PERF_COUNT_HW_CACHE_RESULT_MISS":       unix.PERF_COUNT_HW_CACHE_RESULT_MISS,
	"PERF_COUNT_HW_CACHE_RESULT_MAX":        unix.PERF_COUNT_HW_CACHE_RESULT_MAX,
	"PERF_COUNT_SW_CPU_CLOCK":               unix.PERF_COUNT_SW_CPU_CLOCK,
	"PERF_COUNT_SW_TASK_CLOCK":              unix.PERF_COUNT_SW_TASK_CLOCK,
	"PERF_COUNT_SW_PAGE_FAULTS":             unix.PERF_COUNT_SW_PAGE_FAULTS,
	"PERF_COUNT_SW_CONTEXT_SWITCHES":        unix.PERF_COUNT_SW_CONTEXT_SWITCHES,
	"PERF_COUNT_SW_CPU_MIGRATIONS":          unix.PERF_COUNT_SW_CPU_MIGRATIONS,
	"PERF_COUNT_SW_PAGE_FAULTS_MIN":         unix.PERF_COUNT_SW_PAGE_FAULTS_MIN,
	"PERF_COUNT_SW_PAGE_FAULTS_MAJ":         unix.PERF_COUNT_SW_PAGE_FAULTS_MAJ,
	"PERF_COUNT_SW_ALIGNMENT_FAULTS":        unix.PERF_COUNT_SW_ALIGNMENT_FAULTS,
	"PERF_COUNT_SW_EMULATION_FAULTS":        unix.PERF_COUNT_SW_EMULATION_FAULTS,
	"PERF_COUNT_SW_DUMMY":                   unix.PERF_COUNT_SW_DUMMY,
	"PERF_COUNT_SW_BPF_OUTPUT":              unix.PERF_COUNT_SW_BPF_OUTPUT,
	"PERF_COUNT_SW_MAX":                     unix.PERF_COUNT_SW_MAX,
}
View Source
var PerfFlagMap = map[string]uint64{
	"PERF_FLAG_FD_CLOEXEC":  unix.PERF_FLAG_FD_CLOEXEC,
	"PERF_FLAG_FD_NO_GROUP": unix.PERF_FLAG_FD_NO_GROUP,
	"PERF_FLAG_FD_OUTPUT":   unix.PERF_FLAG_FD_OUTPUT,
	"PERF_FLAG_PID_CGROUP":  unix.PERF_FLAG_PID_CGROUP,
}
View Source
var PerfReadFormatMap = map[string]uint64{
	"PERF_FORMAT_TOTAL_TIME_ENABLED": unix.PERF_FORMAT_TOTAL_TIME_ENABLED,
	"PERF_FORMAT_TOTAL_TIME_RUNNING": unix.PERF_FORMAT_TOTAL_TIME_RUNNING,
	"PERF_FORMAT_ID":                 unix.PERF_FORMAT_ID,
	"PERF_FORMAT_GROUP":              unix.PERF_FORMAT_GROUP,
}
View Source
var PerfTypeMap = map[string]uint64{
	"PERF_TYPE_HARDWARE":   unix.PERF_TYPE_HARDWARE,
	"PERF_TYPE_SOFTWARE":   unix.PERF_TYPE_SOFTWARE,
	"PERF_TYPE_TRACEPOINT": unix.PERF_TYPE_TRACEPOINT,
	"PERF_TYPE_HW_CACHE":   unix.PERF_TYPE_HW_CACHE,
	"PERF_TYPE_RAW":        unix.PERF_TYPE_RAW,
	"PERF_TYPE_BREAKPOINT": unix.PERF_TYPE_BREAKPOINT,
}

Functions

func ResolvePerfBits

func ResolvePerfBits(bitstr string) (uint64, error)

func ResolvePerfConfig

func ResolvePerfConfig(configstr string) (uint64, error)

func ResolvePerfFlag

func ResolvePerfFlag(flagstr string) (uint64, error)

func ResolvePerfReadFormat

func ResolvePerfReadFormat(formatstr string) (uint64, error)

func ResolvePerfType

func ResolvePerfType(typestr string) (uint64, error)

Types

type CpuEvents

type CpuEvents struct {
	CpuModel    string           `yaml:"cpu_model"`
	EventGroups []PerfEventGroup `yaml:"event_groups"`
}

type EventConfig

type EventConfig struct {
	Key       EventKey
	Type      uint64
	TypeStr   string
	Config    uint64
	ConfigStr string
	Config1   uint64
	Config2   uint64
}

type EventKey

type EventKey struct {
	Name  string
	CpuId uint64
}

type PerfCollector

type PerfCollector struct {
	// contains filtered or unexported fields
}

func New

func New() *PerfCollector

New create new PerfCollector

func (*PerfCollector) Collect

func (c *PerfCollector) Collect(out map[string]interface{}) error

Collect collect metric

func (*PerfCollector) Init

func (c *PerfCollector) Init(m map[string]interface{}) error

Init perf

func (*PerfCollector) Stop

func (c *PerfCollector) Stop() error

type PerfEvent

type PerfEvent struct {
	Name      string `yaml:"name"`
	Type      uint64 `yaml:"type"`
	TypeStr   string `yaml:"type_str"`
	Config    uint64 `yaml:"config"`
	ConfigStr string `yaml:"config_str"`
	Config1   uint64 `yaml:"config1"`
	Config2   uint64 `yaml:"config2"`
}

type PerfEventConf

type PerfEventConf struct {
	CpuEvents []CpuEvents `yaml:"cpu_events"`
}

type PerfEventGroup

type PerfEventGroup struct {
	Name   string      `yaml:"name"`
	Enable bool        `yaml:"enable"`
	CpuIds []int       `yaml:"cpuids"`
	Events []PerfEvent `yaml:"events"`
}

type PreValue

type PreValue struct {
	LastTimestamp int64
	Value         uint64
}

type ProfileResultSet

type ProfileResultSet struct {
	Num         uint64
	TimeEnabled uint64
	TimeRunning uint64
	Values      []ProfileValue
}

type ProfileValue

type ProfileValue struct {
	Value uint64
	Id    uint64
}

type Profiler

type Profiler struct {
	// contains filtered or unexported fields
}

func NewProfiler

func NewProfiler() *Profiler

func (*Profiler) AddEvent

func (p *Profiler) AddEvent(profilerType uint32,
	config, config1, config2 uint64,
	pid, cpu int) error

func (*Profiler) Close

func (p *Profiler) Close() error

Close is used to close the perf context.

func (*Profiler) Read

func (p *Profiler) Read(val *ProfileResultSet) error

Profile returns the current Profile.

func (*Profiler) Reset

func (p *Profiler) Reset() error

Reset is used to reset the counters of the profiler.

func (*Profiler) Start

func (p *Profiler) Start() error

Start is used to Start the profiler.

func (*Profiler) Stop

func (p *Profiler) Stop() error

Stop is used to stop the profiler.

type ReadableProfiler

type ReadableProfiler struct {
	Name  string
	CpuId int
	// contains filtered or unexported fields
}

func NewReadableProfiler

func NewReadableProfiler(name string, cpuid int) *ReadableProfiler

func (*ReadableProfiler) AddEvent

func (p *ReadableProfiler) AddEvent(config EventConfig) error

func (*ReadableProfiler) Close

func (p *ReadableProfiler) Close() error

func (*ReadableProfiler) HasEvent

func (p *ReadableProfiler) HasEvent() bool

func (*ReadableProfiler) Read

func (p *ReadableProfiler) Read(result *ReadableResultSet) error

func (*ReadableProfiler) Reset

func (p *ReadableProfiler) Reset() error

func (*ReadableProfiler) Start

func (p *ReadableProfiler) Start() error

func (*ReadableProfiler) Stop

func (p *ReadableProfiler) Stop() error

type ReadableResultSet

type ReadableResultSet struct {
	TimeEnabled uint64
	TimeRunning uint64
	ResultMap   map[EventKey]uint64
}

Jump to

Keyboard shortcuts

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