cmd/compile/internal/inline: add callsite trace output debugging flag

Add a new debug flag "-d=dumpinlcallsitescores" that dumps out a
summary of all callsites in the package being compiled with info on
inlining heuristics, for human consumption. Sample output lines:

  Score  Adjustment  Status  Callee  CallerPos ScoreFlags
  ...
  115    40	     DEMOTED  cmd/compile/internal/abi.(*ABIParamAssignment).Offset	expand_calls.go:1679:14|6	panicPathAdj
  ...
  76     -5          PROMOTED runtime.persistentalloc	mcheckmark.go:48:45|3	inLoopAdj
  ...
  201    0	     --- PGO  unicode.DecodeRuneInString	utf8.go:312:30|1
  ...
  7      -5	     --- PGO  internal/abi.Name.DataChecked	type.go:625:22|0	inLoopAdj

Here "Score" is the final score calculated for the callsite,
"Adjustment" is the amount added to or subtracted from the original
hairyness estimate to form the score. "Status" shows whether anything
changed with the site -- did the adjustment bump it down just below
the threshold ("PROMOTED") or instead bump it above the threshold
("DEMOTED") or did nothing happen as a result of the heuristics
("---"); "Status" also shows whether PGO was involved. "Callee" is the
name of the function called, "CallerPos" is the position of the
callsite, and "ScoreFlags" is a digest of the specific properties we
used to make adjustments to callsite score via heuristics.

Change-Id: Iea4b1cbfee038bc68df6ab81e9973f145636300b
Reviewed-on: https://go-review.googlesource.com/c/go/+/513455
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Than McIntosh 2023-07-24 10:58:26 -04:00
parent a278550c40
commit dab9c502c4
4 changed files with 138 additions and 4 deletions

View file

@ -22,6 +22,7 @@ type DebugFlags struct {
Defer int `help:"print information about defer compilation"`
DisableNil int `help:"disable nil checks" concurrent:"ok"`
DumpInlFuncProps string `help:"dump function properties from inl heuristics to specified file"`
DumpInlCallSiteScores int `help:"dump scored callsites during inlining"`
DumpPtrs int `help:"show Node pointers values in dump output"`
DwarfInl int `help:"print information about DWARF inlined function creation"`
EscapeMutationsCalls int `help:"print extra escape analysis diagnostics about mutations and calls" concurrent:"ok"`