package profile

Import Path
	github.com/google/pprof/profile (on go.dev)

Dependency Relation
	imports 15 packages, and imported by one package

Involved Source Files encode.go filter.go index.go legacy_java_profile.go legacy_profile.go merge.go Package profile provides a representation of profile.proto and methods to encode/decode profiles in this format. proto.go prune.go
Package-Level Type Names (total 8)
/* sort by: | */
Function corresponds to Profile.Function Filename string ID uint64 Name string StartLine int64 SystemName string
Line corresponds to Profile.Line Column int64 Function *Function Line int64
Location corresponds to Profile.Location Address uint64 ID uint64 IsFolded bool Line []Line Mapping *Mapping
Mapping corresponds to Profile.Mapping BuildID string File string HasFilenames bool HasFunctions bool HasInlineFrames bool HasLineNumbers bool ID uint64 Name of the kernel relocation symbol ("_text" or "_stext"), extracted from File. For linux kernel mappings generated by some tools, correct symbolization depends on knowing which of the two possible relocation symbols was used for `Start`. This is given to us as a suffix in `File` (e.g. "[kernel.kallsyms]_stext"). Note, this public field is not persisted in the proto. For the purposes of copying / merging / hashing profiles, it is considered subsumed by `File`. Limit uint64 Offset uint64 Start uint64 Unsymbolizable returns true if a mapping points to a binary for which locations can't be symbolized in principle, at least now. Examples are "[vdso]", "[vsyscall]" and some others, see the code. func ParseProcMaps(rd io.Reader) ([]*Mapping, error)
Profile is an in-memory representation of profile.proto. Comments []string DefaultSampleType string DocURL string DropFrames string DurationNanos int64 Function []*Function KeepFrames string Location []*Location Mapping []*Mapping Period int64 PeriodType *ValueType Sample []*Sample SampleType []*ValueType TimeNanos int64 Aggregate merges the locations in the profile into equivalence classes preserving the request attributes. It also updates the samples to point to the merged locations. CheckValid tests whether the profile is valid. Checks include, but are not limited to: - len(Profile.Sample[n].value) == len(Profile.value_unit) - Sample.id has a corresponding Profile.Location Compact performs garbage collection on a profile to remove any unreferenced fields. This is useful to reduce the size of a profile after samples or locations have been removed. Copy makes a fully independent copy of a profile. FilterSamplesByName filters the samples in a profile and only keeps samples where at least one frame matches focus but none match ignore. Returns true is the corresponding regexp matched at least one sample. FilterSamplesByTag removes all samples from the profile, except those that match focus and do not match the ignore regular expression. FilterTagsByName filters the tags in a profile and only keeps tags that match show and not hide. HasFileLines determines if all locations in this profile have symbolized file and line number information. HasFunctions determines if all locations in this profile have symbolized function information. Normalize normalizes the source profile by multiplying each value in profile by the ratio of the sum of the base profile's values of that sample type to the sum of the source profile's value of that sample type. NumLabelUnits returns a map of numeric label keys to the units associated with those keys and a map of those keys to any units that were encountered but not used. Unit for a given key is the first encountered unit for that key. If multiple units are encountered for values paired with a particular key, then the first unit encountered is used and all other units are returned in sorted order in map of ignored units. If no units are encountered for a particular key, the unit is then inferred based on the key. ParseMemoryMap parses a memory map in the format of /proc/self/maps, and overrides the mappings in the current profile. It renumbers the samples and locations in the profile correspondingly. ParseMemoryMapFromScanner parses a memory map in the format of /proc/self/maps or a variety of legacy format, and overrides the mappings in the current profile. It renumbers the samples and locations in the profile correspondingly. Prune removes all nodes beneath a node matching dropRx, and not matching keepRx. If the root node of a Sample matches, the sample will have an empty stack. PruneFrom removes all nodes beneath the lowest node matching dropRx, not including itself. Please see the example below to understand this method as well as the difference from Prune method. A sample contains Location of [A,B,C,B,D] where D is the top frame and there's no inline. PruneFrom(A) returns [A,B,C,B,D] because there's no node beneath A. Prune(A, nil) returns [B,C,B,D] by removing A itself. PruneFrom(B) returns [B,C,B,D] by removing all nodes beneath the first B when scanning from the bottom. Prune(B, nil) returns [D] because a matching node is found by scanning from the root. RemoveLabel removes all labels associated with the specified key for all samples in the profile. RemoveNumLabel removes all numerical labels associated with the specified key for all samples in the profile. RemoveUninteresting prunes and elides profiles using built-in tables of uninteresting function names. SampleIndexByName returns the appropriate index for a value of sample index. If numeric, it returns the number, otherwise it looks up the text in the profile sample types. Scale multiplies all sample values in a profile by a constant and keeps only samples that have at least one non-zero value. ScaleN multiplies each sample values in a sample by a different amount and keeps only samples that have at least one non-zero value. SetLabel sets the specified key to the specified value for all samples in the profile. SetNumLabel sets the specified key to the specified value for all samples in the profile. "unit" is a slice that describes the units that each corresponding member of "values" is measured in (e.g. bytes or seconds). If there is no relevant unit for a given value, that member of "unit" should be the empty string. "unit" must either have the same length as "value", or be nil. ShowFrom drops all stack frames above the highest matching frame and returns whether a match was found. If showFrom is nil it returns false and does not modify the profile. Example: consider a sample with frames [A, B, C, B], where A is the root. ShowFrom(nil) returns false and has frames [A, B, C, B]. ShowFrom(A) returns true and has frames [A, B, C, B]. ShowFrom(B) returns true and has frames [B, C, B]. ShowFrom(C) returns true and has frames [C, B]. ShowFrom(D) returns false and drops the sample because no frames remain. String dumps a text representation of a profile. Intended mainly for debugging purposes. Write writes the profile as a gzip-compressed marshaled protobuf. WriteUncompressed writes the profile as a marshaled protobuf. *Profile : expvar.Var *Profile : fmt.Stringer func Merge(srcs []*Profile) (*Profile, error) func Parse(r io.Reader) (*Profile, error) func ParseData(data []byte) (*Profile, error) func ParseUncompressed(data []byte) (*Profile, error) func (*Profile).Compact() *Profile func (*Profile).Copy() *Profile func CompatibilizeSampleTypes(ps []*Profile) error func Merge(srcs []*Profile) (*Profile, error) func (*Profile).Normalize(pb *Profile) error
Sample corresponds to Profile.Sample Label is a per-label-key map to values for string labels. In general, having multiple values for the given label key is strongly discouraged - see docs for the sample label field in profile.proto. The main reason this unlikely state is tracked here is to make the decoding->encoding roundtrip not lossy. But we expect that the value slices present in this map are always of length 1. Location []*Location NumLabel is a per-label-key map to values for numeric labels. See a note above on handling multiple values for a label. NumUnit is a per-label-key map to the unit names of corresponding numeric label values. The unit info may be missing even if the label is in NumLabel, see the docs in profile.proto for details. When the value is slice is present and not nil, its length must be equal to the length of the corresponding value slice in NumLabel. Value []int64 DiffBaseSample returns true if a sample belongs to the diff base and false otherwise. HasLabel returns true if a sample has a label with indicated key and value.
TagMatch selects tags for filtering func (*Profile).FilterSamplesByTag(focus, ignore TagMatch) (fm, im bool)
ValueType corresponds to Profile.ValueType // cpu, wall, inuse_space, etc // seconds, nanoseconds, bytes, etc
Package-Level Functions (total 6)
CompatibilizeSampleTypes makes profiles compatible to be compared/merged. It keeps sample types that appear in all profiles only and drops/reorders the sample types as necessary. In the case of sample types order is not the same for given profiles the order is derived from the first profile. Profiles are modified in-place. It returns an error if the sample type's intersection is empty.
Merge merges all the profiles in profs into a single Profile. Returns a new profile independent of the input profiles. The merged profile is compacted to eliminate unused samples, locations, functions and mappings. Profiles must have identical profile sample and period types or the merge will fail. profile.Period of the resulting profile will be the maximum of all profiles, and profile.TimeNanos will be the earliest nonzero one. Merges are associative with the caveat of the first profile having some specialization in how headers are combined. There may be other subtleties now or in the future regarding associativity.
Parse parses a profile and checks for its validity. The input may be a gzip-compressed encoded protobuf or one of many legacy profile formats which may be unsupported in the future.
ParseData parses a profile from a buffer and checks for its validity.
ParseProcMaps parses a memory map in the format of /proc/self/maps. ParseMemoryMap should be called after setting on a profile to associate locations to the corresponding mapping based on their address.
ParseUncompressed parses an uncompressed protobuf into a profile.