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 18, in which 8 are exported)
/* sort exporteds by: | */
Function corresponds to Profile.Function Filename string ID uint64 Name string StartLine int64 SystemName string
Line corresponds to Profile.Line 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 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 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. 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. ScaleN multiplies each sample values in a sample by a different amount. SetLabel sets the specified key to the specified value for all samples in the profile. 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. *T : expvar.Var *T : 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 Merge(srcs []*Profile) (*Profile, error) func (*Profile).Normalize(pb *Profile) error
Sample corresponds to Profile.Sample Label map[string][]string Location []*Location NumLabel map[string][]int64 NumUnit map[string][]string 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 78, in which 5 are exported)
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.
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.
Package-Level Variables (total 50, none are exported)