package pgo
import "cmd/compile/internal/pgo"
Index ¶
- func DirectCallee(fn ir.Node) *ir.Func
- func NodeLineOffset(n ir.Node, fn *ir.Func) int
- func WeightInPercentage(value int64, total int64) float64
- type CallSiteInfo
- type IREdge
- type IRGraph
- type IRNode
- type NodeMapKey
- type Profile
- func New(profileFile string) (*Profile, error)
- func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64)
- func (p *Profile) VisitIR(fn *ir.Func)
- type Weights
Functions ¶
func DirectCallee ¶
DirectCallee takes a function-typed expression and returns the underlying function that it refers to if statically known. Otherwise, it returns nil.
Equivalent to inline.inlCallee without calling CanInline on closures.
func NodeLineOffset ¶
NodeLineOffset returns the line offset of n in fn.
func WeightInPercentage ¶
WeightInPercentage converts profile weights to a percentage.
Types ¶
type CallSiteInfo ¶
type CallSiteInfo struct { LineOffset int // Line offset from function start line. Caller *ir.Func Callee *ir.Func }
CallSiteInfo captures call-site information and its caller/callee.
type IREdge ¶
type IREdge struct { // Source and destination of the edge in IRNode. Src, Dst *IRNode Weight int64 CallSiteOffset int // Line offset from function start line. }
IREdge represents a call edge in the IRGraph with source, destination, weight, callsite, and line number information.
type IRGraph ¶
IRGraph is a call graph with nodes pointing to IRs of functions and edges carrying weights and callsite information.
Nodes for indirect calls may have missing IR (IRNode.AST == nil) if the node is not visible from this package (e.g., not in the transitive deps). Keeping these nodes allows determining the hottest edge from a call even if that callee is not available.
TODO(prattmic): Consider merging this data structure with Graph. This is effectively a copy of Graph aggregated to line number and pointing to IR.
type IRNode ¶
type IRNode struct { // Pointer to the IR of the Function represented by this node. AST *ir.Func // Linker symbol name of the Function represented by this node. // Populated only if AST == nil. LinkerSymbolName string // Set of out-edges in the callgraph. The map uniquely identifies each // edge based on the callsite and callee, for fast lookup. OutEdges map[NodeMapKey]*IREdge }
IRNode represents a node (function) in the IRGraph.
func (*IRNode) Name ¶
Name returns the symbol name of this function.
type NodeMapKey ¶
type NodeMapKey struct { CallerName string CalleeName string CallSiteOffset int // Line offset from function start line. }
NodeMapKey represents a hash key to identify unique call-edges in profile and in IR. Used for deduplication of call edges found in profile.
TODO(prattmic): rename to something more descriptive.
type Profile ¶
type Profile struct { // Aggregated NodeWeights and EdgeWeights across the profile. This // helps us determine the percentage threshold for hot/cold // partitioning. TotalNodeWeight int64 TotalEdgeWeight int64 // NodeMap contains all unique call-edges in the profile and their // aggregated weight. NodeMap map[NodeMapKey]*Weights // WeightedCG represents the IRGraph built from profile, which we will // update as part of inlining. WeightedCG *IRGraph }
Profile contains the processed PGO profile and weighted call graph used for PGO optimizations.
func New ¶
New generates a profile-graph from the profile.
func (*Profile) PrintWeightedCallGraphDOT ¶
PrintWeightedCallGraphDOT prints IRGraph in DOT format.
func (*Profile) VisitIR ¶
VisitIR traverses the body of each ir.Func and use NodeMap to determine if we need to add an edge from ir.Func and any node in the ir.Func body.
type Weights ¶
Weights capture both node weight and edge weight.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd/compile/internal/pgo/internal | |
cmd/compile/internal/pgo/internal/graph | Package graph represents a pprof profile as a directed graph. |
- Version
- v1.21.6
- Published
- Jan 4, 2024
- Platform
- js/wasm
- Imports
- 8 packages
- Last checked
- 1 minute ago –
Tools for package owners.