Documentation ¶
Index ¶
- Constants
- Variables
- type CombinedStack
- type Maps
- func (m *Maps) AddUnwindTableForProcess(pid int, executableMappings unwind.ExecutableMappings, ...) error
- func (m *Maps) AddUnwinderInfo(pid int, unwinderInfo runtime.UnwinderInfo) error
- func (m *Maps) AdjustMapSizes(debugEnabled bool, unwindTableShards, eventsBufferSize uint32) error
- func (m *Maps) ByteOrder() binary.ByteOrder
- func (m *Maps) Close() error
- func (m *Maps) Create() error
- func (m *Maps) FinalizeProfileLoop() error
- func (m *Maps) GetUnwindFailedReasons() (map[int]profiler.UnwindFailedReasons, error)
- func (m *Maps) InterpreterSymbolTable() (profile.InterpreterSymbolTable, error)
- func (m *Maps) PersistUnwindTable() error
- func (m *Maps) ReadStack(stackID uint64, stack []profile.StackFrame) error
- func (m *Maps) ReadStackCount(keyBytes []byte) (uint64, error)
- func (m *Maps) RefreshProcessInfo(pid int, shouldUseFPByDefault bool)
- func (m *Maps) ReuseMaps() error
- func (m *Maps) SetDebugPIDs(pids []int) error
- func (m *Maps) SetUnwinderData() error
- func (m *Maps) UpdateTailCallsMap() error
- type Metrics
- type ProcessCache
Constants ¶
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 )
const ( RequestUnwindInformation byte = iota RequestProcessMappings RequestRefreshProcInfo RequestRead )
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 ¶
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 ¶
AdjustMapSizes updates the amount of unwind shards.
Note: It must be called before `BPFLoadObject()`.
func (*Maps) FinalizeProfileLoop ¶
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 ¶
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 ¶
ReadStackCount reads the value of the given key from the counts ebpf map.
func (*Maps) RefreshProcessInfo ¶
RefreshProcessInfo updates the process information such as mappings and unwind information if the executable mappings have changed.
func (*Maps) SetDebugPIDs ¶
func (*Maps) SetUnwinderData ¶ added in v0.31.0
func (*Maps) UpdateTailCallsMap ¶
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
func NewProcessCache ¶ added in v0.28.0
func NewProcessCache(logger log.Logger, reg prometheus.Registerer) *ProcessCache