mirror of
https://github.com/golang/go
synced 2024-09-29 05:24:32 -06:00
cmd/compile: replace -d=pgoinline with -d=pgodebug
We will soon have PGO specialization. It doesn't make sense for the debug flag to have inline in the name, so rename it to pgodebug. pgoinline is now a flag that can be used to disable PGO inlining. Devirtualization will have a similar debug flag. For #59959. Change-Id: I9770ff1f0d132dfa3cd417018a887a1bd5555bba Reviewed-on: https://go-review.googlesource.com/c/go/+/494716 Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
13e9696437
commit
7c2cd0bbe2
@ -50,9 +50,10 @@ type DebugFlags struct {
|
|||||||
WB int `help:"print information about write barriers"`
|
WB int `help:"print information about write barriers"`
|
||||||
ABIWrap int `help:"print information about ABI wrapper generation"`
|
ABIWrap int `help:"print information about ABI wrapper generation"`
|
||||||
MayMoreStack string `help:"call named function before all stack growth checks" concurrent:"ok"`
|
MayMoreStack string `help:"call named function before all stack growth checks" concurrent:"ok"`
|
||||||
|
PGODebug int `help:"debug profile-guided optimizations"`
|
||||||
|
PGOInline int `help:"enable profile-guided inlining" concurrent:"ok"`
|
||||||
PGOInlineCDFThreshold string `help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok"`
|
PGOInlineCDFThreshold string `help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok"`
|
||||||
PGOInlineBudget int `help:"inline budget for hot functions" concurrent:"ok"`
|
PGOInlineBudget int `help:"inline budget for hot functions" concurrent:"ok"`
|
||||||
PGOInline int `help:"debug profile-guided inlining"`
|
|
||||||
WrapGlobalMapDbg int `help:"debug trace output for global map init wrapping"`
|
WrapGlobalMapDbg int `help:"debug trace output for global map init wrapping"`
|
||||||
WrapGlobalMapCtl int `help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)"`
|
WrapGlobalMapCtl int `help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)"`
|
||||||
|
|
||||||
|
@ -168,6 +168,7 @@ func ParseFlags() {
|
|||||||
Debug.ConcurrentOk = true
|
Debug.ConcurrentOk = true
|
||||||
Debug.InlFuncsWithClosures = 1
|
Debug.InlFuncsWithClosures = 1
|
||||||
Debug.InlStaticInit = 1
|
Debug.InlStaticInit = 1
|
||||||
|
Debug.PGOInline = 1
|
||||||
Debug.SyncFrames = -1 // disable sync markers by default
|
Debug.SyncFrames = -1 // disable sync markers by default
|
||||||
|
|
||||||
Debug.Checkptr = -1 // so we can tell whether it is set explicitly
|
Debug.Checkptr = -1 // so we can tell whether it is set explicitly
|
||||||
|
@ -87,7 +87,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
|
|||||||
}
|
}
|
||||||
var hotCallsites []pgo.NodeMapKey
|
var hotCallsites []pgo.NodeMapKey
|
||||||
inlineHotCallSiteThresholdPercent, hotCallsites = hotNodesFromCDF(p)
|
inlineHotCallSiteThresholdPercent, hotCallsites = hotNodesFromCDF(p)
|
||||||
if base.Debug.PGOInline > 0 {
|
if base.Debug.PGODebug > 0 {
|
||||||
fmt.Printf("hot-callsite-thres-from-CDF=%v\n", inlineHotCallSiteThresholdPercent)
|
fmt.Printf("hot-callsite-thres-from-CDF=%v\n", inlineHotCallSiteThresholdPercent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if base.Debug.PGOInline >= 2 {
|
if base.Debug.PGODebug >= 2 {
|
||||||
fmt.Printf("hot-cg before inline in dot format:")
|
fmt.Printf("hot-cg before inline in dot format:")
|
||||||
p.PrintWeightedCallGraphDOT(inlineHotCallSiteThresholdPercent)
|
p.PrintWeightedCallGraphDOT(inlineHotCallSiteThresholdPercent)
|
||||||
}
|
}
|
||||||
@ -156,6 +156,10 @@ func hotNodesFromCDF(p *pgo.Profile) (float64, []pgo.NodeMapKey) {
|
|||||||
|
|
||||||
// InlinePackage finds functions that can be inlined and clones them before walk expands them.
|
// InlinePackage finds functions that can be inlined and clones them before walk expands them.
|
||||||
func InlinePackage(p *pgo.Profile) {
|
func InlinePackage(p *pgo.Profile) {
|
||||||
|
if base.Debug.PGOInline == 0 {
|
||||||
|
p = nil
|
||||||
|
}
|
||||||
|
|
||||||
InlineDecls(p, typecheck.Target.Decls, true)
|
InlineDecls(p, typecheck.Target.Decls, true)
|
||||||
|
|
||||||
// Perform a garbage collection of hidden closures functions that
|
// Perform a garbage collection of hidden closures functions that
|
||||||
@ -365,7 +369,7 @@ func CanInline(fn *ir.Func, profile *pgo.Profile) {
|
|||||||
if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
|
if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
|
||||||
if _, ok := candHotCalleeMap[n]; ok {
|
if _, ok := candHotCalleeMap[n]; ok {
|
||||||
budget = int32(inlineHotMaxBudget)
|
budget = int32(inlineHotMaxBudget)
|
||||||
if base.Debug.PGOInline > 0 {
|
if base.Debug.PGODebug > 0 {
|
||||||
fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
|
fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,7 +561,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
|
|||||||
lineOffset := pgo.NodeLineOffset(n, fn)
|
lineOffset := pgo.NodeLineOffset(n, fn)
|
||||||
csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
|
csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
|
||||||
if _, o := candHotEdgeMap[csi]; o {
|
if _, o := candHotEdgeMap[csi]; o {
|
||||||
if base.Debug.PGOInline > 0 {
|
if base.Debug.PGODebug > 0 {
|
||||||
fmt.Printf("hot-callsite identified at line=%v for func=%v\n", ir.Line(n), ir.PkgFuncName(v.curFunc))
|
fmt.Printf("hot-callsite identified at line=%v for func=%v\n", ir.Line(n), ir.PkgFuncName(v.curFunc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -991,7 +995,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
|
|||||||
// Hot
|
// Hot
|
||||||
|
|
||||||
if bigCaller {
|
if bigCaller {
|
||||||
if base.Debug.PGOInline > 0 {
|
if base.Debug.PGODebug > 0 {
|
||||||
fmt.Printf("hot-big check disallows inlining for call %s (cost %d) at %v in big function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
|
fmt.Printf("hot-big check disallows inlining for call %s (cost %d) at %v in big function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
|
||||||
}
|
}
|
||||||
return false, maxCost
|
return false, maxCost
|
||||||
@ -1001,7 +1005,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
|
|||||||
return false, inlineHotMaxBudget
|
return false, inlineHotMaxBudget
|
||||||
}
|
}
|
||||||
|
|
||||||
if base.Debug.PGOInline > 0 {
|
if base.Debug.PGODebug > 0 {
|
||||||
fmt.Printf("hot-budget check allows inlining for call %s (cost %d) at %v in function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
|
fmt.Printf("hot-budget check allows inlining for call %s (cost %d) at %v in function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user