perf

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 10 Imported by: 16

README

Perf

GoDoc

This package is a go library for interacting with the perf subsystem in Linux. It allows you to do things like see how many CPU instructions a function takes, profile a process for various hardware events, and other interesting things. The library is by no means finalized and should be considered pre-alpha at best.

Use Cases

A majority of the utility methods in this package should only be used for testing and/or debugging performance issues. Due to the nature of the go runtime profiling on the goroutine level is extremely tricky, with the exception of a long running worker goroutine locked to an OS thread. Eventually this library could be used to implement many of the features of perf but in accessible via Go directly.

Caveats

  • Some utility functions will call runtime.LockOSThread for you, they will also unlock the thread after profiling. Note using these utility functions will incur significant overhead.
  • Perf profiling groups are not implemented properly, I need to spend more time digging through the perf code.
  • Overflow handling is not implemented.

Setup

Most likely you will need to tweak some system settings unless you are running as root. From man perf_event_open:

   perf_event related configuration files
       Files in /proc/sys/kernel/

           /proc/sys/kernel/perf_event_paranoid
                  The perf_event_paranoid file can be set to restrict access to the performance counters.

                  2   allow only user-space measurements (default since Linux 4.6).
                  1   allow both kernel and user measurements (default before Linux 4.6).
                  0   allow access to CPU-specific data but not raw tracepoint samples.
                  -1  no restrictions.

                  The existence of the perf_event_paranoid file is the official method for determining if a kernel supports perf_event_open().                                                                                                

           /proc/sys/kernel/perf_event_max_sample_rate
                  This sets the maximum sample rate.  Setting this too high can allow users to sample at a rate that impacts overall machine performance and potentially lock up the machine.  The default value is 100000  (samples  per     
                  second).

           /proc/sys/kernel/perf_event_max_stack
                  This file sets the maximum depth of stack frame entries reported when generating a call trace.

           /proc/sys/kernel/perf_event_mlock_kb
                  Maximum number of pages an unprivileged user can mlock(2).  The default is 516 (kB).

Example

Say you wanted to see how many CPU instructions a particular function took:

package main

import (
	"fmt"
	"log"
	"github.com/hodgesds/perf-utils"
)

func foo() error {
	var total int
	for i:=0;i<1000;i++ {
		total++
	}
	return nil
}

func main() {
	profileValue, err := perf.CPUInstructions(foo)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("CPU instructions: %+v\n", profileValue)
}

Misc

Originally I set out to use go generate to build Go structs that were compatible with perf, I found a really good article on how to do so. Eventually, after digging through some of the /x/sys/unix code I found pretty much what I was needed. However, I think if you are interested in interacting with the kernel it is a worthwhile read.

Documentation

Index

Constants

View Source
const (
	// 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)

	// 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)
)
View Source
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
	PerfMaxStack = "/proc/sys/kernel/perf_event_max_stack"

	// PerfMaxContexts ...
	PerfMaxContexts = "/proc/sys/kernel/perf_event_max_contexts_per_stack"

	// SyscallsDir ...
	SyscallsDir = "/sys/kernel/debug/tracing/events/syscalls/"

	// TracingDir ...
	TracingDir = "/sys/kernel/debug/tracing"
)
View Source
const (
	// PERF_SAMPLE_IDENTIFIER is not defined in x/sys/unix.
	PERF_SAMPLE_IDENTIFIER = 1 << 16
)
View Source
const (
	// PERF_TYPE_TRACEPOINT is a kernel tracepoint.
	PERF_TYPE_TRACEPOINT = 2
)

Variables

View Source
var (
	// ErrNoMount is when there is no such mount.
	ErrNoMount = fmt.Errorf("no such mount")
)
View Source
var (
	// EventAttrSize is the size of a PerfEventAttr
	EventAttrSize = uint32(unsafe.Sizeof(unix.PerfEventAttr{}))
)

Functions

func AvailableEvents added in v0.0.2

func AvailableEvents() (map[string][]string, error)

AvailableEvents returns the list of available events.

func AvailableTracers added in v0.0.2

func AvailableTracers() ([]string, error)

AvailableTracers returns the list of available tracers.

func CurrentTracer added in v0.0.2

func CurrentTracer() (string, error)

CurrentTracer returns the current tracer.

func DebugFSMount

func DebugFSMount() (string, error)

DebugFSMount returns the first found mount point of a debugfs file system.

func GetFSMount

func GetFSMount(mountType string) ([]string, error)

GetFSMount is a helper function to get a mount file system type.

func TraceFSMount

func TraceFSMount() (string, error)

TraceFSMount returns the first found mount point of a tracefs file system.

Types

type BPFProfiler added in v0.0.3

type BPFProfiler interface {
	Profiler
	AttachBPF(int) error
}

BPFProfiler is a Profiler that This 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 added in v0.0.3

func ProfileTracepoint(kind, event string, pid, cpu int, opts ...int) (BPFProfiler, error)

ProfileTracepoint is used to profile a kernel tracepoint event. 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 used

type CacheProfiler

type CacheProfiler interface {
	Start() error
	Reset() error
	Stop() error
	Close() error
	Profile() (*CacheProfile, error)
}

CacheProfiler is a cache profiler.

func NewCacheProfiler

func NewCacheProfiler(pid, cpu int, opts ...int) CacheProfiler

NewCacheProfiler returns a new cache profiler.

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 the current profile of a process.

type HardwareProfiler

type HardwareProfiler interface {
	Start() error
	Reset() error
	Stop() error
	Close() error
	Profile() (*HardwareProfile, error)
}

HardwareProfiler is a hardware profiler.

func NewHardwareProfiler

func NewHardwareProfiler(pid, cpu int, opts ...int) HardwareProfiler

NewHardwareProfiler returns a new hardware profiler.

type ProfileValue

type ProfileValue struct {
	Value       uint64
	TimeEnabled uint64
	TimeRunning uint64
}

ProfileValue ...

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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.

type Profiler

type Profiler interface {
	Start() error
	Reset() error
	Stop() error
	Close() error
	Profile() (*ProfileValue, error)
}

Profiler is a profiler.

func NewAlignFaultsProfiler

func NewAlignFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewAlignFaultsProfiler returns a Profiler that profiles the number of alignment faults.

func NewBPUProfiler

func NewBPUProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewBPUProfiler returns a Profiler that profiles the BPU (branch prediction unit).

func NewBranchInstrProfiler

func NewBranchInstrProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewBranchInstrProfiler returns a Profiler that profiles branch instructions

func NewBranchMissesProfiler

func NewBranchMissesProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewBranchMissesProfiler returns a Profiler that profiles branch misses.

func NewBusCyclesProfiler

func NewBusCyclesProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewBusCyclesProfiler returns a Profiler that profiles bus cycles.

func NewCPUClockProfiler

func NewCPUClockProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCPUClockProfiler returns a Profiler that profiles CPU clock speed.

func NewCPUCycleProfiler

func NewCPUCycleProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCPUCycleProfiler returns a Profiler that profiles CPU cycles.

func NewCPUMigrationsProfiler

func NewCPUMigrationsProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCPUMigrationsProfiler returns a Profiler that profiles the number of times the process has migrated to a new CPU.

func NewCacheMissesProfiler

func NewCacheMissesProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCacheMissesProfiler returns a Profiler that profiles cache misses.

func NewCacheRefProfiler

func NewCacheRefProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCacheRefProfiler returns a Profiler that profiles cache references.

func NewCtxSwitchesProfiler

func NewCtxSwitchesProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewCtxSwitchesProfiler returns a Profiler that profiles the number of context switches.

func NewDataTLBProfiler

func NewDataTLBProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewDataTLBProfiler returns a Profiler that profiles the data TLB.

func NewEmulationFaultsProfiler

func NewEmulationFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewEmulationFaultsProfiler returns a Profiler that profiles the number of alignment faults.

func NewInstrProfiler

func NewInstrProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewInstrProfiler returns a Profiler that profiles CPU instructions.

func NewInstrTLBProfiler

func NewInstrTLBProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewInstrTLBProfiler returns a Profiler that profiles the instruction TLB.

func NewL1DataProfiler

func NewL1DataProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewL1DataProfiler returns a Profiler that profiles L1 cache data.

func NewL1InstrProfiler

func NewL1InstrProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewL1InstrProfiler returns a Profiler that profiles L1 instruction data.

func NewLLCacheProfiler

func NewLLCacheProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewLLCacheProfiler returns a Profiler that profiles last level cache.

func NewMajorFaultsProfiler

func NewMajorFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewMajorFaultsProfiler returns a Profiler that profiles the number of major page faults.

func NewMinorFaultsProfiler

func NewMinorFaultsProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewMinorFaultsProfiler returns a Profiler that profiles the number of minor page faults.

func NewNodeCacheProfiler

func NewNodeCacheProfiler(pid, cpu, op, result int, opts ...int) (Profiler, error)

NewNodeCacheProfiler returns a Profiler that profiles the node cache accesses.

func NewPageFaultProfiler

func NewPageFaultProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewPageFaultProfiler returns a Profiler that profiles the number of page faults.

func NewProfiler

func NewProfiler(profilerType uint32, config uint64, pid, cpu int, opts ...int) (Profiler, error)

NewProfiler creates a new hardware profiler. It does not support grouping.

func NewRefCPUCyclesProfiler

func NewRefCPUCyclesProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewRefCPUCyclesProfiler returns a Profiler that profiles CPU cycles, it is not affected by frequency scaling.

func NewStalledCyclesBackProfiler

func NewStalledCyclesBackProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewStalledCyclesBackProfiler returns a Profiler that profiles stalled backend cycles.

func NewStalledCyclesFrontProfiler

func NewStalledCyclesFrontProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewStalledCyclesFrontProfiler returns a Profiler that profiles stalled frontend cycles.

func NewTaskClockProfiler

func NewTaskClockProfiler(pid, cpu int, opts ...int) (Profiler, error)

NewTaskClockProfiler returns a Profiler that profiles clock count of the running task.

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 ...

type SoftwareProfiler

type SoftwareProfiler interface {
	Start() error
	Reset() error
	Stop() error
	Close() error
	Profile() (*SoftwareProfile, error)
}

SoftwareProfiler is a software profiler.

func NewSoftwareProfiler

func NewSoftwareProfiler(pid, cpu int, opts ...int) SoftwareProfiler

NewSoftwareProfiler returns a new software profiler.

Jump to

Keyboard shortcuts

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