Skip to content

Commit 69f72c8

Browse files
author
Raj Barik
committed
Update Expr and Func with frequency
1 parent 86fe6c6 commit 69f72c8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/cmd/compile/internal/ir/expr.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,20 @@ const (
153153
CallUseStmt // results not used - call is a statement
154154
)
155155

156+
// EdgeFrequency stores edge profile information for CallExpr where RawCount captures the raw sampled execution count and percent denotes the percentage of counts spent in this edge vs. the total edge samples collected.
157+
type EdgeFrequency struct {
158+
RawCount int64
159+
Percent float64
160+
}
161+
156162
// A CallExpr is a function call X(Args).
157163
type CallExpr struct {
158164
miniExpr
159165
origNode
160166
X Node
161167
Args Nodes
162-
KeepAlive []*Name // vars to be kept alive until call returns
168+
KeepAlive []*Name // vars to be kept alive until call returns
169+
EdgeFreq map[*Func]EdgeFrequency // Frequency of callee targets
163170
IsDDD bool
164171
Use CallUse
165172
NoInline bool

src/cmd/compile/internal/ir/func.go

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import (
1111
"cmd/internal/src"
1212
)
1313

14+
// NodeFrequency stores profile data of an ir.Func where RawCount stores the number of samples and percent captures fraction samples spend in this function versus all samples collected.
15+
type NodeFrequency struct {
16+
RawCount int64
17+
Percent float64
18+
}
19+
1420
// A Func corresponds to a single function in a Go program
1521
// (and vice versa: each function is denoted by exactly one *Func).
1622
//
@@ -96,6 +102,8 @@ type Func struct {
96102
LSym *obj.LSym // Linker object in this function's native ABI (Func.ABI)
97103

98104
Inl *Inline
105+
// Aggregated Weight of the function obtained from pprof profiles.
106+
NodeFreq NodeFrequency
99107

100108
// Closgen tracks how many closures have been generated within
101109
// this function. Used by closurename for creating unique

0 commit comments

Comments
 (0)