Documentation ¶
Index ¶
- Constants
- Variables
- func AlignmentFaultsEventAttr() unix.PerfEventAttr
- func AvailableEvents() (map[string][]string, error)
- func AvailablePMUs() (map[string]int, error)
- func AvailableSubsystems() ([]string, error)
- func AvailableTracers() ([]string, error)
- func BPUEventAttr(op, result int) unix.PerfEventAttr
- func BenchmarkTracepoints(b *testing.B, f func(b *testing.B), options BenchOpt, tracepoints ...string)
- func BusCyclesEventAttr() unix.PerfEventAttr
- func CPUClockEventAttr() unix.PerfEventAttr
- func CPUCyclesEventAttr() unix.PerfEventAttr
- func CPUInstructionsEventAttr() unix.PerfEventAttr
- func CPUMigrationsEventAttr() unix.PerfEventAttr
- func CPURefCyclesEventAttr() unix.PerfEventAttr
- func CPUTaskClockEventAttr() unix.PerfEventAttr
- func CacheMissEventAttr() unix.PerfEventAttr
- func CacheRefEventAttr() unix.PerfEventAttr
- func ContextSwitchesEventAttr() unix.PerfEventAttr
- func CurrentTracer() (string, error)
- func DataTLBEventAttr(op, result int) unix.PerfEventAttr
- func DebugFSMount() (string, error)
- func EmulationFaultsEventAttr() unix.PerfEventAttr
- func EventAttrString(eventAttr *unix.PerfEventAttr) string
- func GetFSMount(mountType string) ([]string, error)
- func GetTracepointConfig(subsystem, event string) (uint64, error)
- func InstructionTLBEventAttr(op, result int) unix.PerfEventAttr
- func L1DataEventAttr(op, result int) unix.PerfEventAttr
- func L1InstructionsEventAttr(op, result int) unix.PerfEventAttr
- func LLCacheEventAttr(op, result int) unix.PerfEventAttr
- func LockThread(core int) (func(), error)
- func MSRPaths() ([]string, error)
- func MajorPageFaultsEventAttr() unix.PerfEventAttr
- func MaxOpenFiles() (uint64, error)
- func MinorPageFaultsEventAttr() unix.PerfEventAttr
- func NodeCacheEventAttr(op, result int) unix.PerfEventAttr
- func PageFaultsEventAttr() unix.PerfEventAttr
- func RunBenchmarks(b *testing.B, f func(b *testing.B), options BenchOpt, ...)
- func StalledBackendCyclesEventAttr() unix.PerfEventAttr
- func StalledFrontendCyclesEventAttr() unix.PerfEventAttr
- func StartCPUCycles() (func(), int, error)
- func TraceFSMount() (string, error)
- func TracepointEventAttr(subsystem, event string) (*unix.PerfEventAttr, error)
- type BPFProfiler
- type BenchOpt
- type CacheProfile
- type CacheProfiler
- type CacheProfilerType
- type GroupProfileValue
- type GroupProfiler
- type HardwareProfile
- type HardwareProfiler
- type HardwareProfilerType
- type MSR
- type ProfileValue
- func AlignmentFaults(f func() error) (*ProfileValue, error)
- func BPU(op, result int, f func() error) (*ProfileValue, error)
- func BusCycles(f func() error) (*ProfileValue, error)
- func CPUClock(f func() error) (*ProfileValue, error)
- func CPUCycles(f func() error) (*ProfileValue, error)
- func CPUInstructions(f func() error) (*ProfileValue, error)
- func CPUMigrations(f func() error) (*ProfileValue, error)
- func CPURefCycles(f func() error) (*ProfileValue, error)
- func CPUTaskClock(f func() error) (*ProfileValue, error)
- func CacheMiss(f func() error) (*ProfileValue, error)
- func CacheRef(f func() error) (*ProfileValue, error)
- func ContextSwitches(f func() error) (*ProfileValue, error)
- func DataTLB(op, result int, f func() error) (*ProfileValue, error)
- func EmulationFaults(f func() error) (*ProfileValue, error)
- func InstructionTLB(op, result int, f func() error) (*ProfileValue, error)
- func L1Data(op, result int, f func() error) (*ProfileValue, error)
- func L1Instructions(op, result int, f func() error) (*ProfileValue, error)
- func LLCache(op, result int, f func() error) (*ProfileValue, error)
- func MajorPageFaults(f func() error) (*ProfileValue, error)
- func MinorPageFaults(f func() error) (*ProfileValue, error)
- func NodeCache(op, result int, f func() error) (*ProfileValue, error)
- func PageFaults(f func() error) (*ProfileValue, error)
- func StalledBackendCycles(f func() error) (*ProfileValue, error)
- func StalledFrontendCycles(f func() error) (*ProfileValue, error)
- func StopCPUCycles(cb func(), fd int) (*ProfileValue, error)
- type Profiler
- func NewAlignFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewBPUProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewBranchInstrProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewBranchMissesProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewBusCyclesProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCPUClockProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCPUCycleProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCPUMigrationsProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCacheMissesProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCacheRefProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewCtxSwitchesProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewDataTLBProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewEmulationFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewInstrProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewInstrTLBProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewL1DataProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewL1InstrProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewLLCacheProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewMajorFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewMinorFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewNodeCacheProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)
- func NewPageFaultProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewProfiler(profilerType uint32, config uint64, pid, cpu int, opts ...int) (Profiler, error)
- func NewRefCPUCyclesProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewStalledCyclesBackProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewStalledCyclesFrontProfiler(pid, cpu int, opts ...int) (Profiler, error)
- func NewTaskClockProfiler(pid, cpu int, opts ...int) (Profiler, error)
- type SoftwareProfile
- type SoftwareProfiler
- type SoftwareProfilerType
Constants ¶
const ( // AllCacheProfilers is used to try to configure all cache profilers. AllCacheProfilers CacheProfilerType = 0 L1DataReadHitProfiler CacheProfilerType = 1 << iota L1DataReadMissProfiler CacheProfilerType = 1 << iota L1DataWriteHitProfiler CacheProfilerType = 1 << iota L1InstrReadMissProfiler CacheProfilerType = 1 << iota L1InstrReadHitProfiler CacheProfilerType = 1 << iota LLReadHitProfiler CacheProfilerType = 1 << iota LLReadMissProfiler CacheProfilerType = 1 << iota LLWriteHitProfiler CacheProfilerType = 1 << iota LLWriteMissProfiler CacheProfilerType = 1 << iota DataTLBReadHitProfiler CacheProfilerType = 1 << iota DataTLBReadMissProfiler CacheProfilerType = 1 << iota DataTLBWriteHitProfiler CacheProfilerType = 1 << iota DataTLBWriteMissProfiler CacheProfilerType = 1 << iota InstrTLBReadHitProfiler CacheProfilerType = 1 << iota InstrTLBReadMissProfiler CacheProfilerType = 1 << iota BPUReadHitProfiler CacheProfilerType = 1 << iota BPUReadMissProfiler CacheProfilerType = 1 << iota NodeCacheReadHitProfiler CacheProfilerType = 1 << iota NodeCacheReadMissProfiler CacheProfilerType = 1 << iota NodeCacheWriteHitProfiler CacheProfilerType = 1 << iota NodeCacheWriteMissProfiler CacheProfilerType = 1 << iota // L1DataReadHit is a constant... L1DataReadHit = (unix.PERF_COUNT_HW_CACHE_L1D) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // L1DataReadMiss is a constant... L1DataReadMiss = (unix.PERF_COUNT_HW_CACHE_L1D) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // L1DataWriteHit is a constant... L1DataWriteHit = (unix.PERF_COUNT_HW_CACHE_L1D) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // L1InstrReadMiss is a constant... L1InstrReadMiss = (unix.PERF_COUNT_HW_CACHE_L1I) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // L1InstrReadHit is a constant... L1InstrReadHit = (unix.PERF_COUNT_HW_CACHE_L1I) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // LLReadHit is a constant... LLReadHit = (unix.PERF_COUNT_HW_CACHE_LL) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // LLReadMiss is a constant... LLReadMiss = (unix.PERF_COUNT_HW_CACHE_LL) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // LLWriteHit is a constant... LLWriteHit = (unix.PERF_COUNT_HW_CACHE_LL) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // LLWriteMiss is a constant... LLWriteMiss = (unix.PERF_COUNT_HW_CACHE_LL) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // DataTLBReadHit is a constant... DataTLBReadHit = (unix.PERF_COUNT_HW_CACHE_DTLB) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // DataTLBReadMiss is a constant... DataTLBReadMiss = (unix.PERF_COUNT_HW_CACHE_DTLB) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // DataTLBWriteHit is a constant... DataTLBWriteHit = (unix.PERF_COUNT_HW_CACHE_DTLB) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // DataTLBWriteMiss is a constant... DataTLBWriteMiss = (unix.PERF_COUNT_HW_CACHE_DTLB) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // InstrTLBReadHit is a constant... InstrTLBReadHit = (unix.PERF_COUNT_HW_CACHE_ITLB) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // InstrTLBReadMiss is a constant... InstrTLBReadMiss = (unix.PERF_COUNT_HW_CACHE_ITLB) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // BPUReadHit is a constant... BPUReadHit = (unix.PERF_COUNT_HW_CACHE_BPU) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // BPUReadMiss is a constant... BPUReadMiss = (unix.PERF_COUNT_HW_CACHE_BPU) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // NodeCacheReadHit is a constant... NodeCacheReadHit = (unix.PERF_COUNT_HW_CACHE_NODE) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // NodeCacheReadMiss is a constant... NodeCacheReadMiss = (unix.PERF_COUNT_HW_CACHE_NODE) | (unix.PERF_COUNT_HW_CACHE_OP_READ << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) // NodeCacheWriteHit is a constant... NodeCacheWriteHit = (unix.PERF_COUNT_HW_CACHE_NODE) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) // NodeCacheWriteMiss is a constant... NodeCacheWriteMiss = (unix.PERF_COUNT_HW_CACHE_NODE) | (unix.PERF_COUNT_HW_CACHE_OP_WRITE << 8) | (unix.PERF_COUNT_HW_CACHE_RESULT_MISS << 16) )
const ( // DebugFS is the filesystem type for debugfs. DebugFS = "debugfs" // TraceFS is the filesystem type for tracefs. TraceFS = "tracefs" // ProcMounts is the mount point for file systems in procfs. ProcMounts = "/proc/mounts" // PerfMaxStack is the mount point for the max perf event size. PerfMaxStack = "/proc/sys/kernel/perf_event_max_stack" // PerfMaxContexts is a sysfs mount that contains the max perf contexts. PerfMaxContexts = "/proc/sys/kernel/perf_event_max_contexts_per_stack" // SyscallsDir is a constant of the default tracing event syscalls directory. SyscallsDir = "/sys/kernel/debug/tracing/events/syscalls/" // TracingDir is a constant of the default tracing directory. TracingDir = "/sys/kernel/debug/tracing" )
const ( // PERF_SAMPLE_IDENTIFIER is not defined in x/sys/unix. PERF_SAMPLE_IDENTIFIER = 1 << 16 // PERF_IOC_FLAG_GROUP is not defined in x/sys/unix. PERF_IOC_FLAG_GROUP = 1 << 0 )
const (
// MSRBaseDir is the base dir for MSRs.
MSRBaseDir = "/dev/cpu"
)
const (
// PERF_TYPE_TRACEPOINT is a kernel tracepoint.
PERF_TYPE_TRACEPOINT = 2
)
const (
PMUEventBaseDir = "/sys/bus/event_source/devices"
)
Variables ¶
var ( // ErrNoProfiler is returned when no profiler is available for profiling. ErrNoProfiler = fmt.Errorf("No profiler available") // ProfileValuePool is a sync.Pool of ProfileValue structs. ProfileValuePool = sync.Pool{ New: func() interface{} { return &ProfileValue{} }, } )
var ErrNoLeader = fmt.Errorf("No leader defined")
ErrNoLeader is returned when a leader of a GroupProfiler is not defined.
var ( // ErrNoMount is when there is no such mount. ErrNoMount = fmt.Errorf("no such mount") )
var ( // EventAttrSize is the size of a PerfEventAttr EventAttrSize = uint32(unsafe.Sizeof(unix.PerfEventAttr{})) )
Functions ¶
func AlignmentFaultsEventAttr ¶
func AlignmentFaultsEventAttr() unix.PerfEventAttr
AlignmentFaultsEventAttr returns a unix.PerfEventAttr configured for AlignmentFaults.
func AvailableEvents ¶
AvailableEvents returns a mapping of available subsystems and their corresponding list of available events.
func AvailablePMUs ¶
AvailablePMUs returns a mapping of available PMUs from /sys/bus/event_sources/devices to the PMU event type (number).
func AvailableSubsystems ¶
AvailableSubsystems returns a slice of available subsystems.
func AvailableTracers ¶
AvailableTracers returns the list of available tracers.
func BPUEventAttr ¶
func BPUEventAttr(op, result int) unix.PerfEventAttr
BPUEventAttr returns a unix.PerfEventAttr configured for BPU events.
func BenchmarkTracepoints ¶
func BenchmarkTracepoints( b *testing.B, f func(b *testing.B), options BenchOpt, tracepoints ...string, )
BenchmarkTracepoints runs benchmark and counts the
func BusCyclesEventAttr ¶
func BusCyclesEventAttr() unix.PerfEventAttr
BusCyclesEventAttr returns a unix.PerfEventAttr configured for BusCycles.
func CPUClockEventAttr ¶
func CPUClockEventAttr() unix.PerfEventAttr
CPUClockEventAttr returns a unix.PerfEventAttr configured for CPUClock.
func CPUCyclesEventAttr ¶
func CPUCyclesEventAttr() unix.PerfEventAttr
CPUCyclesEventAttr returns a unix.PerfEventAtsadtr configured for CPUCyclesad.
func CPUInstructionsEventAttr ¶
func CPUInstructionsEventAttr() unix.PerfEventAttr
CPUInstructionsEventAttr returns a unix.PerfEventAttr configured for CPUInstructions.
func CPUMigrationsEventAttr ¶
func CPUMigrationsEventAttr() unix.PerfEventAttr
CPUMigrationsEventAttr returns a unix.PerfEventAttr configured for CPUMigrations.
func CPURefCyclesEventAttr ¶
func CPURefCyclesEventAttr() unix.PerfEventAttr
CPURefCyclesEventAttr returns a unix.PerfEventAttr configured for CPURefCycles.
func CPUTaskClockEventAttr ¶
func CPUTaskClockEventAttr() unix.PerfEventAttr
CPUTaskClockEventAttr returns a unix.PerfEventAttr configured for CPUTaskClock.
func CacheMissEventAttr ¶
func CacheMissEventAttr() unix.PerfEventAttr
CacheMissEventAttr returns a unix.PerfEventAttr configured for CacheMisses.
func CacheRefEventAttr ¶
func CacheRefEventAttr() unix.PerfEventAttr
CacheRefEventAttr returns a unix.PerfEventAttr configured for CacheRef.
func ContextSwitchesEventAttr ¶
func ContextSwitchesEventAttr() unix.PerfEventAttr
ContextSwitchesEventAttr returns a unix.PerfEventAttr configured for ContextSwitches.
func DataTLBEventAttr ¶
func DataTLBEventAttr(op, result int) unix.PerfEventAttr
DataTLBEventAttr returns a unix.PerfEventAttr configured for DataTLB.
func DebugFSMount ¶
DebugFSMount returns the first found mount point of a debugfs file system.
func EmulationFaultsEventAttr ¶
func EmulationFaultsEventAttr() unix.PerfEventAttr
EmulationFaultsEventAttr returns a unix.PerfEventAttr configured for EmulationFaults.
func EventAttrString ¶
func EventAttrString(eventAttr *unix.PerfEventAttr) string
EventAttrString returns a short string representation of a unix.PerfEventAttr.
func GetFSMount ¶
GetFSMount is a helper function to get a mount file system type.
func GetTracepointConfig ¶
GetTracepointConfig is used to get the configuration for a trace event.
func InstructionTLBEventAttr ¶
func InstructionTLBEventAttr(op, result int) unix.PerfEventAttr
InstructionTLBEventAttr returns a unix.PerfEventAttr configured for InstructionTLB.
func L1DataEventAttr ¶
func L1DataEventAttr(op, result int) unix.PerfEventAttr
L1DataEventAttr returns a unix.PerfEventAttr configured for L1Data.
func L1InstructionsEventAttr ¶
func L1InstructionsEventAttr(op, result int) unix.PerfEventAttr
L1InstructionsEventAttr returns a unix.PerfEventAttr configured for L1Instructions.
func LLCacheEventAttr ¶
func LLCacheEventAttr(op, result int) unix.PerfEventAttr
LLCacheEventAttr returns a unix.PerfEventAttr configured for LLCache.
func LockThread ¶
LockThread locks an goroutine to an OS thread and then sets the affinity of the thread to a processor core.
func MajorPageFaultsEventAttr ¶
func MajorPageFaultsEventAttr() unix.PerfEventAttr
MajorPageFaultsEventAttr returns a unix.PerfEventAttr configured for MajorPageFaults.
func MaxOpenFiles ¶
MaxOpenFiles returns the RLIMIT_NOFILE from getrlimit.
func MinorPageFaultsEventAttr ¶
func MinorPageFaultsEventAttr() unix.PerfEventAttr
MinorPageFaultsEventAttr returns a unix.PerfEventAttr configured for MinorPageFaults.
func NodeCacheEventAttr ¶
func NodeCacheEventAttr(op, result int) unix.PerfEventAttr
NodeCacheEventAttr returns a unix.PerfEventAttr configured for NUMA cache operations.
func PageFaultsEventAttr ¶
func PageFaultsEventAttr() unix.PerfEventAttr
PageFaultsEventAttr returns a unix.PerfEventAttr configured for PageFaults.
func RunBenchmarks ¶
func RunBenchmarks( b *testing.B, f func(b *testing.B), options BenchOpt, eventAttrs ...unix.PerfEventAttr, )
RunBenchmarks runs a series of benchmarks for a set of PerfEventAttrs.
func StalledBackendCyclesEventAttr ¶
func StalledBackendCyclesEventAttr() unix.PerfEventAttr
StalledBackendCyclesEventAttr returns a unix.PerfEventAttr configured for StalledBackendCycles.
func StalledFrontendCyclesEventAttr ¶
func StalledFrontendCyclesEventAttr() unix.PerfEventAttr
StalledFrontendCyclesEventAttr returns a unix.PerfEventAttr configured for StalledFrontendCycles.
func TraceFSMount ¶
TraceFSMount returns the first found mount point of a tracefs file system.
func TracepointEventAttr ¶
func TracepointEventAttr(subsystem, event string) (*unix.PerfEventAttr, error)
TracepointEventAttr is used to return an PerfEventAttr for a trace event.
Types ¶
type BPFProfiler ¶
BPFProfiler is a Profiler that allows attaching a Berkeley Packet Filter (BPF) program to an existing kprobe tracepoint event. You need CAP_SYS_ADMIN privileges to use this interface. See: https://lwn.net/Articles/683504/
func ProfileTracepoint ¶
func ProfileTracepoint(subsystem, event string, pid, cpu int, opts ...int) (BPFProfiler, error)
ProfileTracepoint is used to profile a kernel tracepoint event for a specific PID. Events can be listed with `perf list` for Tracepoint Events or in the /sys/kernel/debug/tracing/events directory with the kind being the directory and the event being the subdirectory.
type CacheProfile ¶
type CacheProfile struct { L1DataReadHit *uint64 `json:"l1_data_read_hit,omitempty"` L1DataReadMiss *uint64 `json:"l1_data_read_miss,omitempty"` L1DataWriteHit *uint64 `json:"l1_data_write_hit,omitempty"` L1InstrReadMiss *uint64 `json:"l1_instr_read_miss,omitempty"` LastLevelReadHit *uint64 `json:"last_level_read_hit,omitempty"` LastLevelReadMiss *uint64 `json:"last_level_read_miss,omitempty"` LastLevelWriteHit *uint64 `json:"last_level_write_hit,omitempty"` LastLevelWriteMiss *uint64 `json:"last_level_write_miss,omitempty"` DataTLBReadHit *uint64 `json:"data_tlb_read_hit,omitempty"` DataTLBReadMiss *uint64 `json:"data_tlb_read_miss,omitempty"` DataTLBWriteHit *uint64 `json:"data_tlb_write_hit,omitempty"` DataTLBWriteMiss *uint64 `json:"data_tlb_write_miss,omitempty"` InstrTLBReadHit *uint64 `json:"instr_tlb_read_hit,omitempty"` InstrTLBReadMiss *uint64 `json:"instr_tlb_read_miss,omitempty"` BPUReadHit *uint64 `json:"bpu_read_hit,omitempty"` BPUReadMiss *uint64 `json:"bpu_read_miss,omitempty"` NodeReadHit *uint64 `json:"node_read_hit,omitempty"` NodeReadMiss *uint64 `json:"node_read_miss,omitempty"` NodeWriteHit *uint64 `json:"node_write_hit,omitempty"` NodeWriteMiss *uint64 `json:"node_write_miss,omitempty"` TimeEnabled *uint64 `json:"time_enabled,omitempty"` TimeRunning *uint64 `json:"time_running,omitempty"` }
CacheProfile is returned by a CacheProfiler.
func (*CacheProfile) Reset ¶
func (p *CacheProfile) Reset()
Reset sets all values to defaults and will nil any pointers.
type CacheProfiler ¶
type CacheProfiler interface { Start() error Reset() error Stop() error Close() error Profile(*CacheProfile) error HasProfilers() bool }
CacheProfiler is a cache profiler.
func NewCacheProfiler ¶
func NewCacheProfiler(pid, cpu int, profilerSet CacheProfilerType, opts ...int) (CacheProfiler, error)
NewCacheProfiler returns a new cache profiler.
type CacheProfilerType ¶
type CacheProfilerType int
type GroupProfileValue ¶
type GroupProfileValue struct { Events uint64 TimeEnabled uint64 TimeRunning uint64 Values []uint64 }
GroupProfileValue is returned from a GroupProfiler.
type GroupProfiler ¶
type GroupProfiler interface { Start() error Reset() error Stop() error Close() error HasProfilers() bool Profile(*GroupProfileValue) error }
GroupProfiler is used to setup a group profiler.
func NewGroupProfiler ¶
func NewGroupProfiler(pid, cpu, opts int, eventAttrs ...unix.PerfEventAttr) (GroupProfiler, error)
NewGroupProfiler returns a GroupProfiler.
type HardwareProfile ¶
type HardwareProfile struct { CPUCycles *uint64 `json:"cpu_cycles,omitempty"` Instructions *uint64 `json:"instructions,omitempty"` CacheRefs *uint64 `json:"cache_refs,omitempty"` CacheMisses *uint64 `json:"cache_misses,omitempty"` BranchInstr *uint64 `json:"branch_instr,omitempty"` BranchMisses *uint64 `json:"branch_misses,omitempty"` BusCycles *uint64 `json:"bus_cycles,omitempty"` StalledCyclesFrontend *uint64 `json:"stalled_cycles_frontend,omitempty"` StalledCyclesBackend *uint64 `json:"stalled_cycles_backend,omitempty"` RefCPUCycles *uint64 `json:"ref_cpu_cycles,omitempty"` TimeEnabled *uint64 `json:"time_enabled,omitempty"` TimeRunning *uint64 `json:"time_running,omitempty"` }
HardwareProfile is returned by a HardwareProfiler. Depending on kernel configuration some fields may return nil.
func (*HardwareProfile) Reset ¶
func (p *HardwareProfile) Reset()
Reset sets all values to defaults and will nil any pointers.
type HardwareProfiler ¶
type HardwareProfiler interface { Start() error Reset() error Stop() error Close() error Profile(*HardwareProfile) error HasProfilers() bool }
HardwareProfiler is a hardware profiler.
func NewHardwareProfiler ¶
func NewHardwareProfiler(pid, cpu int, profilerSet HardwareProfilerType, opts ...int) (HardwareProfiler, error)
NewHardwareProfiler returns a new hardware profiler.
type HardwareProfilerType ¶
type HardwareProfilerType int
const ( AllHardwareProfilers HardwareProfilerType = 0 CpuCyclesProfiler HardwareProfilerType = 1 << iota CpuInstrProfiler HardwareProfilerType = 1 << iota CacheRefProfiler HardwareProfilerType = 1 << iota CacheMissesProfiler HardwareProfilerType = 1 << iota BranchInstrProfiler HardwareProfilerType = 1 << iota BranchMissesProfiler HardwareProfilerType = 1 << iota BusCyclesProfiler HardwareProfilerType = 1 << iota StalledCyclesBackendProfiler HardwareProfilerType = 1 << iota StalledCyclesFrontendProfiler HardwareProfilerType = 1 << iota RefCpuCyclesProfiler HardwareProfilerType = 1 << iota )
type MSR ¶
type MSR struct {
// contains filtered or unexported fields
}
MSR represents a Model Specific Register
type ProfileValue ¶
ProfileValue is a value returned by a profiler.
func AlignmentFaults ¶
func AlignmentFaults(f func() error) (*ProfileValue, error)
AlignmentFaults is used to profile a function and return the number of alignment faults. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func BPU ¶
func BPU(op, result int, f func() error) (*ProfileValue, error)
BPU is used to profile a function for the Branch Predictor Unit. Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func BusCycles ¶
func BusCycles(f func() error) (*ProfileValue, error)
BusCycles is used to profile a function and return the number of bus cycles. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPUClock ¶
func CPUClock(f func() error) (*ProfileValue, error)
CPUClock is used to profile a function and return the CPU clock timer. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPUCycles ¶
func CPUCycles(f func() error) (*ProfileValue, error)
CPUCycles is used to profile a function and return the number of CPU cycles. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPUInstructions ¶
func CPUInstructions(f func() error) (*ProfileValue, error)
CPUInstructions is used to profile a function and return the number of CPU instructions. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPUMigrations ¶
func CPUMigrations(f func() error) (*ProfileValue, error)
CPUMigrations is used to profile a function and return the number of times the thread has been migrated to a new CPU. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPURefCycles ¶
func CPURefCycles(f func() error) (*ProfileValue, error)
CPURefCycles is used to profile a function and return the number of CPU references cycles which are not affected by frequency scaling. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CPUTaskClock ¶
func CPUTaskClock(f func() error) (*ProfileValue, error)
CPUTaskClock is used to profile a function and return the CPU clock timer for the running task. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CacheMiss ¶
func CacheMiss(f func() error) (*ProfileValue, error)
CacheMiss is used to profile a function and return the number of cache misses. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func CacheRef ¶
func CacheRef(f func() error) (*ProfileValue, error)
CacheRef is used to profile a function and return the number of cache references. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func ContextSwitches ¶
func ContextSwitches(f func() error) (*ProfileValue, error)
ContextSwitches is used to profile a function and return the number of context switches. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func DataTLB ¶
func DataTLB(op, result int, f func() error) (*ProfileValue, error)
DataTLB is used to profile the data TLB. Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func EmulationFaults ¶
func EmulationFaults(f func() error) (*ProfileValue, error)
EmulationFaults is used to profile a function and return the number of emulation faults. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func InstructionTLB ¶
func InstructionTLB(op, result int, f func() error) (*ProfileValue, error)
InstructionTLB is used to profile the instruction TLB. Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func L1Data ¶
func L1Data(op, result int, f func() error) (*ProfileValue, error)
L1Data is used to profile a function and the L1 data cache faults. Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func L1Instructions ¶
func L1Instructions(op, result int, f func() error) (*ProfileValue, error)
L1Instructions is used to profile a function for the instruction level L1 cache. Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func LLCache ¶
func LLCache(op, result int, f func() error) (*ProfileValue, error)
LLCache is used to profile a function and return the number of emulation PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func MajorPageFaults ¶
func MajorPageFaults(f func() error) (*ProfileValue, error)
MajorPageFaults is used to profile a function and return the number of major page faults. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func MinorPageFaults ¶
func MinorPageFaults(f func() error) (*ProfileValue, error)
MinorPageFaults is used to profile a function and return the number of minor page faults. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func NodeCache ¶
func NodeCache(op, result int, f func() error) (*ProfileValue, error)
NodeCache is used to profile a function for NUMA operations. Use Use PERF_COUNT_HW_CACHE_OP_READ, PERF_COUNT_HW_CACHE_OP_WRITE, or PERF_COUNT_HW_CACHE_OP_PREFETCH for the opt and PERF_COUNT_HW_CACHE_RESULT_ACCESS or PERF_COUNT_HW_CACHE_RESULT_MISS for the result. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func PageFaults ¶
func PageFaults(f func() error) (*ProfileValue, error)
PageFaults is used to profile a function and return the number of page faults. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func StalledBackendCycles ¶
func StalledBackendCycles(f func() error) (*ProfileValue, error)
StalledBackendCycles is used to profile a function and return the number of stalled backend cycles. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func StalledFrontendCycles ¶
func StalledFrontendCycles(f func() error) (*ProfileValue, error)
StalledFrontendCycles is used to profile a function and return the number of stalled frontend cycles. Note that it will call runtime.LockOSThread to ensure accurate profilng.
func StopCPUCycles ¶
func StopCPUCycles(cb func(), fd int) (*ProfileValue, error)
Stops the CPU Cycels
type Profiler ¶
type Profiler interface { Start() error Reset() error Stop() error Close() error Profile(*ProfileValue) error }
Profiler is a profiler.
func NewAlignFaultsProfiler ¶
NewAlignFaultsProfiler returns a Profiler that profiles the number of alignment faults.
func NewBPUProfiler ¶
NewBPUProfiler returns a Profiler that profiles the BPU (branch prediction unit).
func NewBranchInstrProfiler ¶
NewBranchInstrProfiler returns a Profiler that profiles branch instructions.
func NewBranchMissesProfiler ¶
NewBranchMissesProfiler returns a Profiler that profiles branch misses.
func NewBusCyclesProfiler ¶
NewBusCyclesProfiler returns a Profiler that profiles bus cycles.
func NewCPUClockProfiler ¶
NewCPUClockProfiler returns a Profiler that profiles CPU clock speed.
func NewCPUCycleProfiler ¶
NewCPUCycleProfiler returns a Profiler that profiles CPU cycles.
func NewCPUMigrationsProfiler ¶
NewCPUMigrationsProfiler returns a Profiler that profiles the number of times the process has migrated to a new CPU.
func NewCacheMissesProfiler ¶
NewCacheMissesProfiler returns a Profiler that profiles cache misses.
func NewCacheRefProfiler ¶
NewCacheRefProfiler returns a Profiler that profiles cache references.
func NewCtxSwitchesProfiler ¶
NewCtxSwitchesProfiler returns a Profiler that profiles the number of context switches.
func NewDataTLBProfiler ¶
NewDataTLBProfiler returns a Profiler that profiles the data TLB.
func NewEmulationFaultsProfiler ¶
NewEmulationFaultsProfiler returns a Profiler that profiles the number of alignment faults.
func NewInstrProfiler ¶
NewInstrProfiler returns a Profiler that profiles CPU instructions.
func NewInstrTLBProfiler ¶
NewInstrTLBProfiler returns a Profiler that profiles the instruction TLB.
func NewL1DataProfiler ¶
NewL1DataProfiler returns a Profiler that profiles L1 cache data.
func NewL1InstrProfiler ¶
NewL1InstrProfiler returns a Profiler that profiles L1 instruction data.
func NewLLCacheProfiler ¶
NewLLCacheProfiler returns a Profiler that profiles last level cache.
func NewMajorFaultsProfiler ¶
NewMajorFaultsProfiler returns a Profiler that profiles the number of major page faults.
func NewMinorFaultsProfiler ¶
NewMinorFaultsProfiler returns a Profiler that profiles the number of minor page faults.
func NewNodeCacheProfiler ¶
NewNodeCacheProfiler returns a Profiler that profiles the node cache accesses.
func NewPageFaultProfiler ¶
NewPageFaultProfiler returns a Profiler that profiles the number of page faults.
func NewProfiler ¶
NewProfiler creates a new hardware profiler. It does not support grouping.
func NewRefCPUCyclesProfiler ¶
NewRefCPUCyclesProfiler returns a Profiler that profiles CPU cycles, it is not affected by frequency scaling.
func NewStalledCyclesBackProfiler ¶
NewStalledCyclesBackProfiler returns a Profiler that profiles stalled backend cycles.
func NewStalledCyclesFrontProfiler ¶
NewStalledCyclesFrontProfiler returns a Profiler that profiles stalled frontend cycles.
type SoftwareProfile ¶
type SoftwareProfile struct { CPUClock *uint64 `json:"cpu_clock,omitempty"` TaskClock *uint64 `json:"task_clock,omitempty"` PageFaults *uint64 `json:"page_faults,omitempty"` ContextSwitches *uint64 `json:"context_switches,omitempty"` CPUMigrations *uint64 `json:"cpu_migrations,omitempty"` MinorPageFaults *uint64 `json:"minor_page_faults,omitempty"` MajorPageFaults *uint64 `json:"major_page_faults,omitempty"` AlignmentFaults *uint64 `json:"alignment_faults,omitempty"` EmulationFaults *uint64 `json:"emulation_faults,omitempty"` TimeEnabled *uint64 `json:"time_enabled,omitempty"` TimeRunning *uint64 `json:"time_running,omitempty"` }
SoftwareProfile is returned by a SoftwareProfiler.
func (*SoftwareProfile) Reset ¶
func (p *SoftwareProfile) Reset()
Reset sets all values to defaults and will nil any pointers.
type SoftwareProfiler ¶
type SoftwareProfiler interface { Start() error Reset() error Stop() error Close() error Profile(*SoftwareProfile) error HasProfilers() bool }
SoftwareProfiler is a software profiler.
func NewSoftwareProfiler ¶
func NewSoftwareProfiler(pid, cpu int, profilerSet SoftwareProfilerType, opts ...int) (SoftwareProfiler, error)
NewSoftwareProfiler returns a new software profiler.
type SoftwareProfilerType ¶
type SoftwareProfilerType int
const ( AllSoftwareProfilers SoftwareProfilerType = 0 CpuClockProfiler SoftwareProfilerType = 1 << iota TaskClockProfiler SoftwareProfilerType = 1 << iota PageFaultProfiler SoftwareProfilerType = 1 << iota ContextSwitchProfiler SoftwareProfilerType = 1 << iota CpuMigrationProfiler SoftwareProfilerType = 1 << iota MinorFaultProfiler SoftwareProfilerType = 1 << iota MajorFaultProfiler SoftwareProfilerType = 1 << iota AlignFaultProfiler SoftwareProfilerType = 1 << iota EmuFaultProfiler SoftwareProfilerType = 1 << iota )