]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pprof: add -runtime flag
authorDmitry Vyukov <dvyukov@google.com>
Thu, 19 Feb 2015 12:21:05 +0000 (15:21 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Thu, 19 Feb 2015 19:46:20 +0000 (19:46 +0000)
The flag disables stripping of runtime frames in profiles.
This is useful when analyzing runtime itself.

Before:
$ go tool pprof --text --alloc_objects --lines fmt.test /tmp/mprof
      flat  flat%   sum%        cum   cum%
      2768 79.65% 79.65%      32768 79.65%  fmt_test.TestComplexFormatting fmt/fmt_test.go:744
      6554 15.93% 95.58%       6554 15.93%  regexp/syntax.(*compiler).rune regexp/syntax/compile.go:267
      1820  4.42%   100%       1820  4.42%  runtime.malg runtime/proc1.go:1977

After:
$ go tool pprof --text --alloc_objects --lines --runtime fmt.test /tmp/mprof
      flat  flat%   sum%        cum   cum%
     32768 79.65% 79.65%      32768 79.65%  runtime.convT2E runtime/iface.go:139
      6554 15.93% 95.58%       6554 15.93%  runtime.growslice runtime/slice.go:89
      1820  4.42%   100%       1820  4.42%  runtime.malg runtime/proc1.go:1977

Change-Id: If468dfa5c5bbd0809c45a58d912d3115fac009ed
Reviewed-on: https://go-review.googlesource.com/5291
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/cmd/pprof/internal/driver/driver.go

index a9f6c844f454a8b7c9aee9d947a1e61f5b46110c..9703bafa633e01cb116c35bc4940bd496eb3c86e 100644 (file)
@@ -106,7 +106,9 @@ func PProf(flagset plugin.FlagSet, fetch plugin.Fetcher, sym plugin.Symbolizer,
                return err
        }
 
-       prof.RemoveUninteresting()
+       if !*f.flagRuntime {
+               prof.RemoveUninteresting()
+       }
 
        if *f.flagInteractive {
                return interactive(prof, obj, ui, f)
@@ -445,6 +447,7 @@ type flags struct {
        flagNodeFraction *float64 // Hide nodes below <f>*total
        flagEdgeFraction *float64 // Hide edges below <f>*total
        flagTrim         *bool    // Set to false to ignore NodeCount/*Fraction
+       flagRuntime      *bool    // Show runtime call frames in memory profiles
        flagFocus        *string  // Restricts to paths going through a node matching regexp
        flagIgnore       *string  // Skips paths going through any nodes matching regexp
        flagHide         *string  // Skips sample locations matching regexp
@@ -640,6 +643,7 @@ func getFlags(flag plugin.FlagSet, overrides commands.Commands, ui plugin.UI) (*
                flagNodeFraction: flag.Float64("nodefraction", 0.005, "Hide nodes below <f>*total"),
                flagEdgeFraction: flag.Float64("edgefraction", 0.001, "Hide edges below <f>*total"),
                flagTrim:         flag.Bool("trim", true, "Honor nodefraction/edgefraction/nodecount defaults"),
+               flagRuntime:      flag.Bool("runtime", false, "Show runtime call frames in memory profiles"),
                flagFocus:        flag.String("focus", "", "Restricts to paths going through a node matching regexp"),
                flagIgnore:       flag.String("ignore", "", "Skips paths going through any nodes matching regexp"),
                flagHide:         flag.String("hide", "", "Skips nodes matching regexp"),
@@ -877,6 +881,7 @@ var usageMsg = "Output file parameters (for file-based output formats):\n" +
        "  -contentions      Display number of delays at each region\n" +
        "  -mean_delay       Display mean delay at each region\n" +
        "Filtering options:\n" +
+       "  -runtime          Show runtime call frames in memory profiles\n" +
        "  -focus=r          Restricts to paths going through a node matching regexp\n" +
        "  -ignore=r         Skips paths going through any nodes matching regexp\n" +
        "  -tagfocus=r       Restrict to samples tagged with key:value matching regexp\n" +