Help us shape the future of Go! Take the 2026 Go Developer Survey

bpfmaps

package
v0.25.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DebugPIDsMapName   = "debug_pids"
	StackCountsMapName = "stack_counts"

	StackTracesMapName            = "stack_traces"
	HeapMapName                   = "heap"
	InterpreterStackTracesMapName = "interpreter_stack_traces"
	SymbolIndexStorageMapName     = "symbol_index_storage"
	SymbolTableMapName            = "symbol_table"

	// 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"
	DWARFStackTracesMapName = "dwarf_stack_traces"
	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

func (*Maps) AddUnwindTableForProcess

func (m *Maps) AddUnwindTableForProcess(pid int, interp *runtime.Interpreter, 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) 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) ReadInterpreterStack

func (m *Maps) ReadInterpreterStack(interpreterStackID int32, stack []uint64) (map[uint32]*profile.Function, error)

ReadInterpreterStack fills in the stack with the interpreter frame ids.

func (*Maps) ReadKernelStack

func (m *Maps) ReadKernelStack(kernelStackID int32, stack *bpfprograms.CombinedStack) error

ReadKernelStack reads the kernel stack trace from the stacktraces ebpf map 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) ReadUserStack

func (m *Maps) ReadUserStack(userStackID int32, stack *bpfprograms.CombinedStack) error

ReadUserStack reads the user stack trace from the stacktraces ebpf map into the given buffer.

func (*Maps) ReadUserStackWithDwarf

func (m *Maps) ReadUserStackWithDwarf(userStackID int32, stack *bpfprograms.CombinedStack) error

ReadUserStackWithDwarf reads the DWARF walked user stack traces into the given buffer.

func (*Maps) RefreshProcessInfo

func (m *Maps) RefreshProcessInfo(pid int, interp *runtime.Interpreter)

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

TODO(javierhonduco): Add all the supported Ruby versions.

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