bpfmaps

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StackCountsMapName = "stack_counts"

	StackTracesMapName = "stack_traces"

	// rbperf maps.
	RubyPIDToRubyThreadMapName       = "pid_to_rb_thread"
	RubyVersionSpecificOffsetMapName = "version_specific_offsets"

	// pyperf maps.
	PythonPIDToInterpreterInfoMapName  = "pid_to_interpreter_info"
	PythonVersionSpecificOffsetMapName = "version_specific_offsets"

	UnwindInfoChunksMapName = "unwind_info_chunks"
	UnwindTablesMapName     = "unwind_tables"
	ProcessInfoMapName      = "process_info"
	ProgramsMapName         = "programs"
	PerCPUStatsMapName      = "percpu_stats"

	// With the current compact rows, the max items we can store in the kernels
	// we have tested is 262k per map, which we rounded it down to 250k.
	MaxUnwindShards = 50 // How many unwind table shards we have.

)
View Source
const (
	RequestUnwindInformation = 1 << 63
	RequestProcessMappings   = 1 << 62
	RequestRefreshProcInfo   = 1 << 61
)

Variables

View Source
var (
	ErrMissing                   = errors.New("missing stack trace")
	ErrUnwindFailed              = errors.New("stack ID is 0, probably stack unwinding failed")
	ErrUnrecoverable             = errors.New("unrecoverable error")
	ErrTooManyExecutableMappings = errors.New("too many executable mappings")
	ErrNeedMoreProfilingRounds   = errors.New("not enough profiling rounds with this unwind info")
)

Functions

This section is empty.

Types

type Maps

type Maps struct {
	StackCounts *libbpf.BPFMap
	// contains filtered or unexported fields
}

func New

func New(logger log.Logger, reg prometheus.Registerer, byteOrder binary.ByteOrder, arch elf.Machine, modules map[ProfilerModuleType]*libbpf.Module) (*Maps, error)

func (*Maps) AddInterpreter

func (m *Maps) AddInterpreter(pid int, interpreter runtime.Interpreter) error

AddInterpreter adds the interpreter information to the relevant BPF maps. It is a lookup table for the BPF program to find the interpreter information for corresponding PID. Process information is stored in a separate map and needs to be updated separately.

func (*Maps) AddUnwindTableForProcess

func (m *Maps) AddUnwindTableForProcess(pid int, executableMappings unwind.ExecutableMappings, checkCache bool) error

1. Find executable sections 2. For each section, generate compact table 3. Add table to maps 4. Add map metadata to process

func (*Maps) AdjustMapSizes

func (m *Maps) AdjustMapSizes(debugEnabled bool, unwindTableShards, eventsBufferSize uint32) error

AdjustMapSizes updates the amount of unwind shards.

Note: It must be called before `BPFLoadObject()`.

func (*Maps) Close

func (m *Maps) Close() error

Close closes all the resources associated with the maps.

func (*Maps) Create

func (m *Maps) Create() error

func (*Maps) FinalizeProfileLoop

func (m *Maps) FinalizeProfileLoop() error

func (*Maps) InterpreterSymbolTable added in v0.27.0

func (m *Maps) InterpreterSymbolTable() (map[uint32]*profile.Function, error)

PERF: This code presents (at least) presents two possible performance opportunities that we should measure.

- Preallocating the lookup table. - Batch the BPF map calls to read and update them.

func (*Maps) PersistUnwindTable

func (m *Maps) PersistUnwindTable() error

PersistUnwindTable calls persistUnwindTable but holding the mutex to ensure that shared state is mutated safely.

Never use this function from addUnwindTableForProcess, as it holds this same mutex.

func (*Maps) ReadStack added in v0.27.0

func (m *Maps) ReadStack(stackID uint64, stack []uint64) error

ReadStack reads the walked stacktrace into the given buffer.

func (*Maps) ReadStackCount

func (m *Maps) ReadStackCount(keyBytes []byte) (uint64, error)

ReadStackCount reads the value of the given key from the counts ebpf map.

func (*Maps) RefreshProcessInfo

func (m *Maps) RefreshProcessInfo(pid int)

RefreshProcessInfo updates the process information such as mappings and unwind information if the executable mappings have changed.

func (*Maps) ReuseMaps

func (m *Maps) ReuseMaps() error

func (*Maps) SetDebugPIDs

func (m *Maps) SetDebugPIDs(pids []int) error

func (*Maps) SetInterpreterData

func (m *Maps) SetInterpreterData() error

func (*Maps) UpdateTailCallsMap

func (m *Maps) UpdateTailCallsMap() error

type ProfilerModuleType

type ProfilerModuleType int
const (
	NativeModule ProfilerModuleType = iota
	RbperfModule
	PyperfModule
)

Jump to

Keyboard shortcuts

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