profile

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SchemaName = "parca"
	// The columns are sorted by their name in the schema too.
	ColumnDuration   = "duration"
	ColumnLabels     = "labels"
	ColumnName       = "name"
	ColumnPeriod     = "period"
	ColumnPeriodType = "period_type"
	ColumnPeriodUnit = "period_unit"
	ColumnSampleType = "sample_type"
	ColumnSampleUnit = "sample_unit"
	ColumnStacktrace = "stacktrace"
	ColumnTimestamp  = "timestamp"
	ColumnTimeNanos  = "time_nanos"
	ColumnValue      = "value"
)
View Source
const (
	MaxVal9 = maxUint64 >> (1 + iota*7)
	MaxVal8
	MaxVal7
	MaxVal6
	MaxVal5
	MaxVal4
	MaxVal3
	MaxVal2
	MaxVal1
)

MaxValN is the maximum varint-encoded integer that fits in N bytes.

View Source
const (
	ColumnLabelsPrefix = ColumnLabels + "."
)

Variables

View Source
var LocationsField = arrow.Field{
	Name: "locations",
	Type: arrow.ListOf(arrow.StructOf([]arrow.Field{{
		Name: "address",
		Type: arrow.PrimitiveTypes.Uint64,
	}, {
		Name: "mapping_start",
		Type: arrow.PrimitiveTypes.Uint64,
	}, {
		Name: "mapping_limit",
		Type: arrow.PrimitiveTypes.Uint64,
	}, {
		Name: "mapping_offset",
		Type: arrow.PrimitiveTypes.Uint64,
	}, {
		Name: "mapping_file",
		Type: &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Uint32, ValueType: arrow.BinaryTypes.Binary},
	}, {
		Name: "mapping_build_id",
		Type: &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Uint32, ValueType: arrow.BinaryTypes.Binary},
	}, {
		Name: "lines",
		Type: arrow.ListOf(arrow.StructOf([]arrow.Field{{
			Name: "line",
			Type: arrow.PrimitiveTypes.Int64,
		}, {
			Name: "function_name",
			Type: &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Uint32, ValueType: arrow.BinaryTypes.Binary},
		}, {
			Name: "function_system_name",
			Type: &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Uint32, ValueType: arrow.BinaryTypes.Binary},
		}, {
			Name: "function_filename",
			Type: &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Uint32, ValueType: arrow.BinaryTypes.Binary},
		}, {
			Name: "function_start_line",
			Type: arrow.PrimitiveTypes.Int64,
		}}...)),
	}}...)),
}

Functions

func ArrowSamplesField added in v0.19.0

func ArrowSamplesField(profileLabelFields []arrow.Field) []arrow.Field

func ArrowSchema added in v0.19.0

func ArrowSchema(profileLabelFields []arrow.Field) *arrow.Schema

func DecodeFunctionName added in v0.24.0

func DecodeFunctionName(data []byte) ([]byte, error)

DecodeFunctionName is a fork of DecodeInto that only tries to find a function name and returns it. It returns "" if no function name is found.

func EncodeArrowLocation added in v0.22.0

func EncodeArrowLocation(
	address uint64,
	hasMapping bool,
	mappingStart uint64,
	mappingLimit uint64,
	mappingOffset uint64,
	mappingFile []byte,
	buildID []byte,
	linesStartOffset int,
	linesEndOffset int,
	_ *array.List,
	_ *array.Struct,
	lineNumber *array.Int64,
	lineFunctionName *array.Dictionary,
	lineFunctionNameDict *array.Binary,
	lineFunctionSystemName *array.Dictionary,
	lineFunctionSystemNameDict *array.Binary,
	lineFunctionFilename *array.RunEndEncoded,
	lineFunctionFilenameDict *array.Dictionary,
	lineFunctionFilenameDictValues *array.Binary,
	lineFunctionStartLine *array.Int64,
) []byte

func EncodeOtelLocation added in v0.22.0

func EncodeOtelLocation(
	attributeTable []*pprofextended.KeyValueAndUnit,
	l *pprofextended.Location,
	m *pprofextended.Mapping,
	funcs []*pprofextended.Function,
	stringTable []string,
) []byte

func EncodePprofLocation added in v0.22.0

func EncodePprofLocation(
	l *pprofpb.Location,
	m *pprofpb.Mapping,
	funcs []*pprofpb.Function,
	stringTable []string,
) []byte

func LocationsArrowSchema added in v0.19.0

func LocationsArrowSchema() *arrow.Schema

func Schema added in v0.19.0

func Schema() (*dynparquet.Schema, error)

func SchemaDefinition added in v0.19.0

func SchemaDefinition() *schemapb.Schema

func UvarintSize added in v0.22.0

func UvarintSize(x uint64) int

UvarintSize returns the number of bytes necessary to encode a given uint. Unfortunately the standard lib does not provide this function, so we create it here.

Types

type DecodeResult added in v0.22.0

type DecodeResult struct {
	WroteLines bool
	BuildID    []byte
	Addr       uint64
	Mapping    Mapping
}

func DecodeInto added in v0.22.0

func DecodeInto(lw LocationsWriter, data []byte) (DecodeResult, error)

type Demangler added in v0.22.0

type Demangler interface {
	Demangle(name []byte) string
}

type ExecutableInfo added in v0.22.0

type ExecutableInfo struct {
	ElfType          elf.Type
	TextProgHdrIndex int16
	ProgHeaders      []ProgHeader
}

func ExecutableInfoFromELF added in v0.22.0

func ExecutableInfoFromELF(f *elf.File) (ExecutableInfo, error)

func (ExecutableInfo) FindProgramHeader added in v0.22.0

func (ei ExecutableInfo) FindProgramHeader(m Mapping, addr uint64) (*ProgHeader, error)

FindProgramHeader returns the program segment that matches the current mapping and the given address, or an error if it cannot find a unique program header.

type Label added in v0.12.0

type Label struct {
	Name  string
	Value string
}

type LabelColumn added in v0.19.0

type LabelColumn struct {
	Col  *array.Uint32
	Dict *array.Binary
}

type Location added in v0.12.0

type Location struct {
	ID       string
	Address  uint64
	IsFolded bool
	Mapping  *pb.Mapping
	Lines    []LocationLine
}

type LocationLine added in v0.12.0

type LocationLine struct {
	Line     int64
	Function *pb.Function
}

type LocationsWriter added in v0.19.0

type LocationsWriter struct {
	RecordBuilder      *array.RecordBuilder
	LabelBuildersMap   map[string]*array.BinaryDictionaryBuilder
	LabelBuilders      []*array.BinaryDictionaryBuilder
	LocationsList      *array.ListBuilder
	Locations          *array.StructBuilder
	Addresses          *array.Uint64Builder
	MappingStart       *array.Uint64Builder
	MappingLimit       *array.Uint64Builder
	MappingOffset      *array.Uint64Builder
	MappingFile        *array.BinaryDictionaryBuilder
	MappingBuildID     *array.BinaryDictionaryBuilder
	Lines              *array.ListBuilder
	Line               *array.StructBuilder
	LineNumber         *array.Int64Builder
	FunctionName       *array.BinaryDictionaryBuilder
	FunctionSystemName *array.BinaryDictionaryBuilder
	FunctionFilename   *array.BinaryDictionaryBuilder
	FunctionStartLine  *array.Int64Builder
	Value              *array.Int64Builder
	Diff               *array.Int64Builder
}

func NewLocationsWriter added in v0.19.0

func NewLocationsWriter(pool memory.Allocator) LocationsWriter

type Mapping added in v0.22.0

type Mapping struct {
	StartAddr uint64
	EndAddr   uint64
	Offset    uint64
	File      string
}

type Meta added in v0.12.0

type Meta struct {
	Name       string
	PeriodType ValueType
	SampleType ValueType
	Timestamp  int64
	TimeNanos  int64
	Duration   int64
	Period     int64
}

func MetaFromPprof added in v0.8.0

func MetaFromPprof(p *pprofproto.Profile, name string, sampleIndex int) Meta

type NormalizedProfile added in v0.12.0

type NormalizedProfile struct {
	Samples []*NormalizedSample
	Meta    Meta
}

type NormalizedSample added in v0.12.0

type NormalizedSample struct {
	StacktraceID string
	Value        int64
	DiffValue    int64
	Label        map[string]string
	NumLabel     map[string]int64
}

type NumLabel added in v0.12.0

type NumLabel struct {
	Name  string
	Value int64
}

type OldProfile added in v0.19.0

type OldProfile struct {
	Meta    Meta
	Samples []*SymbolizedSample
}

type Profile added in v0.9.0

type Profile struct {
	Samples []arrow.RecordBatch
	Meta    Meta
}

type ProgHeader added in v0.22.0

type ProgHeader struct {
	Off   uint64
	Vaddr uint64
	Memsz uint64
}

A ProgHeader represents a single ELF program header.

type Reader added in v0.19.0

type Reader struct {
	Profile       Profile
	RecordReaders []*RecordReader
}

func NewReader added in v0.19.0

func NewReader(p Profile) Reader

type RecordReader added in v0.19.0

type RecordReader struct {
	Record arrow.RecordBatch

	LabelFields  []arrow.Field
	LabelColumns []LabelColumn

	Locations                     *array.List
	Location                      *array.Struct
	Address                       *array.Uint64
	Timestamp                     *array.Int64
	Period                        *array.Int64
	MappingStart                  *array.Uint64
	MappingLimit                  *array.Uint64
	MappingOffset                 *array.Uint64
	MappingFileIndices            *array.Uint32
	MappingFileDict               *array.Binary
	MappingBuildIDIndices         *array.Uint32
	MappingBuildIDDict            *array.Binary
	Lines                         *array.List
	Line                          *array.Struct
	LineNumber                    *array.Int64
	LineFunctionNameIndices       *array.Uint32
	LineFunctionNameDict          *array.Binary
	LineFunctionSystemNameIndices *array.Uint32
	LineFunctionSystemNameDict    *array.Binary
	LineFunctionFilenameIndices   *array.Uint32
	LineFunctionFilenameDict      *array.Binary
	LineFunctionStartLine         *array.Int64

	Value *array.Int64
	Diff  *array.Int64
}

func NewRecordReader added in v0.19.0

func NewRecordReader(ar arrow.RecordBatch) *RecordReader

type SymbolizationInfo added in v0.22.0

type SymbolizationInfo struct {
	Addr    uint64
	BuildID []byte
	Mapping Mapping
}

func DecodeSymbolizationInfo added in v0.22.0

func DecodeSymbolizationInfo(data []byte) (SymbolizationInfo, uint64)

type SymbolizedSample added in v0.12.0

type SymbolizedSample struct {
	Locations []*Location
	Value     int64
	DiffValue int64
	Label     map[string]string
	NumLabel  map[string]int64
}

type ValueType

type ValueType struct {
	Type string
	Unit string
}

type Writer added in v0.19.0

type Writer struct {
	RecordBuilder      *array.RecordBuilder
	LabelBuildersMap   map[string]*array.BinaryDictionaryBuilder
	LabelBuilders      []*array.BinaryDictionaryBuilder
	LocationsList      *array.ListBuilder
	Locations          *array.StructBuilder
	Addresses          *array.Uint64Builder
	MappingStart       *array.Uint64Builder
	MappingLimit       *array.Uint64Builder
	MappingOffset      *array.Uint64Builder
	MappingFile        *array.BinaryDictionaryBuilder
	MappingBuildID     *array.BinaryDictionaryBuilder
	Lines              *array.ListBuilder
	Line               *array.StructBuilder
	LineNumber         *array.Int64Builder
	FunctionName       *array.BinaryDictionaryBuilder
	FunctionSystemName *array.BinaryDictionaryBuilder
	FunctionFilename   *array.BinaryDictionaryBuilder
	FunctionStartLine  *array.Int64Builder
	Value              *array.Int64Builder
	Diff               *array.Int64Builder
	TimeNanos          *array.Int64Builder
	Period             *array.Int64Builder
}

func NewWriter added in v0.19.0

func NewWriter(pool memory.Allocator, labelNames []string) Writer

func (*Writer) Release added in v0.21.0

func (w *Writer) Release()

Jump to

Keyboard shortcuts

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