bpfmaps

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StackCountsMapName  = "stack_counts"
	CustomLabelsMapName = "custom_labels"

	StackTracesMapName = "stack_traces"

	// rbperf maps.
	RubyPIDToRubyInterpreterInfoMapName = "pid_to_interpreter_info"
	RubyVersionSpecificOffsetMapName    = "version_specific_offsets"

	// pyperf maps.
	PythonPIDToInterpreterInfoMapName  = "pid_to_interpreter_info"
	PythonVersionSpecificOffsetMapName = "version_specific_offsets"
	PythonGlibcOffsetsMapName          = "glibc_offsets"
	PythonMuslOffsetsMapName           = "musl_offsets"

	// jvm maps.
	JavaPIDToVMInfoMapName           = "pid_to_vm_info"
	JavaVersionSpecificOffsetMapName = "version_specific_offsets"

	// native runtime info maps
	NativePIDToRuntimeInfoMapName = "pid_to_runtime_info"

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

	// 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 = 30 // How many unwind table shards we have.

	MaxCachedProcesses = 100_000
)
View Source
const (
	RequestUnwindInformation byte = iota
	RequestProcessMappings
	RequestRefreshProcInfo
	RequestRead
)
View Source
const (
	StackDepth = 128 // Always needs to be sync with MAX_STACK_DEPTH + 1 in BPF program. The +1 is because we can have an extra error frame.

)

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

type CombinedStack [tripleStackDepth]profile.StackFrame

type Maps

type Maps struct {
	StackCounts *libbpf.BPFMap

	CustomLabels *libbpf.BPFMap
	// contains filtered or unexported fields
}

func New

func New(
	logger log.Logger,
	reg prometheus.Registerer,
	modules map[bpfprograms.ProfilerModuleType]*libbpf.Module,
	ofp *objectfile.Pool,
	processCache *ProcessCache,
	syncedUnwinderInfo *cache.Cache[int, runtime.UnwinderInfo],
	finder *debuginfo.Finder,
) (*Maps, error)

func (*Maps) AddUnwindTableForProcess

func (m *Maps) AddUnwindTableForProcess(pid int, executableMappings unwind.ExecutableMappings, checkCache, shouldUseFPByDefault 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) AddUnwinderInfo added in v0.31.0

func (m *Maps) AddUnwinderInfo(pid int, unwinderInfo runtime.UnwinderInfo) error

AddUnwinderInfo adds the unwinder information to the relevant BPF maps. It is a lookup table for the BPF program to find the unwinder information for corresponding process' runtime.

Process information is stored in a separate map and needs to be updated separately.

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) ByteOrder added in v0.31.0

func (m *Maps) ByteOrder() binary.ByteOrder

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) GetUnwindFailedReasons added in v0.31.0

func (m *Maps) GetUnwindFailedReasons() (map[int]profiler.UnwindFailedReasons, error)

func (*Maps) InterpreterSymbolTable added in v0.27.0

func (m *Maps) InterpreterSymbolTable() (profile.InterpreterSymbolTable, 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 []profile.StackFrame) 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, shouldUseFPByDefault bool)

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) SetUnwinderData added in v0.31.0

func (m *Maps) SetUnwinderData() error

func (*Maps) UpdateTailCallsMap

func (m *Maps) UpdateTailCallsMap() error

type Metrics added in v0.28.0

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

func NewMetrics added in v0.28.0

func NewMetrics(reg prometheus.Registerer) *Metrics

type ProcessCache added in v0.28.0

type ProcessCache struct {
	*cache.Cache[int, uint64]
}

func NewProcessCache added in v0.28.0

func NewProcessCache(logger log.Logger, reg prometheus.Registerer) *ProcessCache

Jump to

Keyboard shortcuts

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