mirror of https://github.com/golang/go.git
cmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name
When two callees have equal weight, we need to sort by another criteria to ensure that we get stable output. Note that this is only for the CallStat debug JSON output. The actual callee selection already does this secondary sort in findHotConcreteCallee. Change-Id: I0de105623c5ccc793ca6f5799ea25e57bc286722 Reviewed-on: https://go-review.googlesource.com/c/go/+/527796 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
e8ba0579e2
commit
4b17b36b3f
|
|
@ -223,6 +223,18 @@ func constructCallStat(p *pgo.Profile, fn *ir.Func, name string, call *ir.CallEx
|
|||
|
||||
offset := pgo.NodeLineOffset(call, fn)
|
||||
|
||||
hotter := func(e *pgo.IREdge) bool {
|
||||
if stat.Hottest == "" {
|
||||
return true
|
||||
}
|
||||
if e.Weight != stat.HottestWeight {
|
||||
return e.Weight > stat.HottestWeight
|
||||
}
|
||||
// If weight is the same, arbitrarily sort lexicographally, as
|
||||
// findHotConcreteCallee does.
|
||||
return e.Dst.Name() < stat.Hottest
|
||||
}
|
||||
|
||||
// Sum of all edges from this callsite, regardless of callee.
|
||||
// For direct calls, this should be the same as the single edge
|
||||
// weight (except for multiple calls on one line, which we
|
||||
|
|
@ -233,7 +245,7 @@ func constructCallStat(p *pgo.Profile, fn *ir.Func, name string, call *ir.CallEx
|
|||
continue
|
||||
}
|
||||
stat.Weight += edge.Weight
|
||||
if edge.Weight > stat.HottestWeight {
|
||||
if hotter(edge) {
|
||||
stat.HottestWeight = edge.Weight
|
||||
stat.Hottest = edge.Dst.Name()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue