pgo

Imports

Imports #

"errors"
"fmt"
"internal/profile"
"io"
"sort"
"bufio"
"fmt"
"io"
"bufio"
"fmt"
"io"
"strings"
"strconv"

Constants & Variables

serializationHeader const #

const serializationHeader = "GO PREPROFILE V1\n"

Structs

NamedCallEdge struct #

NamedCallEdge identifies a call edge by linker symbol names and call site offset.

type NamedCallEdge struct {
CallerName string
CalleeName string
CallSiteOffset int
}

NamedEdgeMap struct #

NamedEdgeMap contains all unique call edges in the profile and their edge weight.

type NamedEdgeMap struct {
Weight map[NamedCallEdge]int64
ByWeight []NamedCallEdge
}

Profile struct #

Profile contains the processed data from the PGO profile.

type Profile struct {
TotalWeight int64
NamedEdgeMap NamedEdgeMap
}

Functions

FromPProf function #

FromPProf parses Profile from a pprof profile.

func FromPProf(r io.Reader) (*Profile, error)

FromSerialized function #

FromSerialized parses a profile from serialization output of Profile.WriteTo.

func FromSerialized(r io.Reader) (*Profile, error)

IsSerialized function #

IsSerialized returns true if r is a serialized Profile. IsSerialized only peeks at r, so seeking back after calling is not necessary.

func IsSerialized(r *bufio.Reader) (bool, error)

WeightInPercentage function #

WeightInPercentage converts profile weights to a percentage.

func WeightInPercentage(value int64, total int64) float64

WriteTo method #

WriteTo writes a serialized representation of Profile to w. FromSerialized can parse the format back to Profile. WriteTo implements io.WriterTo.Write.

func (d *Profile) WriteTo(w io.Writer) (int64, error)

createNamedEdgeMap function #

createNamedEdgeMap builds a map of callsite-callee edge weights from the profile-graph. Caller should ignore the profile if totalWeight == 0.

func createNamedEdgeMap(g *profile.Graph) (edgeMap NamedEdgeMap, totalWeight int64, err error)

emptyProfile function #

func emptyProfile() *Profile

postProcessNamedEdgeMap function #

func postProcessNamedEdgeMap(weight map[NamedCallEdge]int64, weightVal int64) (edgeMap NamedEdgeMap, totalWeight int64, err error)

sortByWeight function #

func sortByWeight(edges []NamedCallEdge, weight map[NamedCallEdge]int64)

Generated with Arrow