diff --git a/doc/pprof.md b/doc/pprof.md index 61dc29a2e..65986acf3 100644 --- a/doc/pprof.md +++ b/doc/pprof.md @@ -249,10 +249,10 @@ profile to be subtracted. This may result in some report entries having negative values. Percentages in the report are relative to the total of the diff base. -If the merged profile is output as a protocol buffer, all samples in -the diff base profile will have a label with the key "base" and a value of "1". -If pprof is then used to look at the merged profile, it will behave as if -separate source and base profiles were passed in. +If the merged profile is output as a protocol buffer, all samples in +the diff base profile will have a label with the key "pprof::base" and a value +of "true". If pprof is then used to look at the merged profile, it will behave +as if separate source and base profiles were passed in. The **-base** option can be used in the place of the **-diff_base** option, and may be preferrable when comparing two cumulative profiles, for example two diff --git a/internal/driver/fetch.go b/internal/driver/fetch.go index 5c9180f39..61d6af798 100644 --- a/internal/driver/fetch.go +++ b/internal/driver/fetch.go @@ -136,7 +136,7 @@ func grabSourcesAndBases(sources, bases []profileSource, isDiffBase bool, fetch defer wg.Done() pbase, mbase, savebase, countbase, errbase = chunkedGrab(bases, fetch, obj, ui) if pbase != nil && isDiffBase { - pbase.SetTag("base", []string{"1"}) + pbase.SetTag("pprof::base", []string{"true"}) } }() wg.Wait() diff --git a/internal/driver/fetch_test.go b/internal/driver/fetch_test.go index 5f4198d68..2ee472ca0 100644 --- a/internal/driver/fetch_test.go +++ b/internal/driver/fetch_test.go @@ -398,27 +398,27 @@ func TestFetchWithBase(t *testing.T) { }, { values: []int64{-2700, -608881724}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, { values: []int64{-100, -23992}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, { values: []int64{-200, -179943}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, { values: []int64{-100, -17778444}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, { values: []int64{-100, -75976}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, { values: []int64{-300, -63568134}, - labels: map[string][]string{"base": {"1"}}, + labels: map[string][]string{"pprof::base": {"true"}}, }, }, "", diff --git a/internal/report/report.go b/internal/report/report.go index 1515021c3..4c6c99bc2 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -266,7 +266,7 @@ func (rpt *Report) newGraph(nodes graph.NodeSet) *graph.Graph { // Remove tag marking samples from the base profiles, so it does not appear // as a nodelet in the graph view. - prof.SetTag("base", []string{}) + prof.SetTag("pprof::base", []string{}) formatTag := func(v int64, key string) string { return measurement.ScaledLabel(v, key, o.OutputUnit) @@ -1217,7 +1217,7 @@ func NewDefault(prof *profile.Profile, options Options) *Report { } // computeTotal computes the sum of the absolute value of all sample values. -// If any samples have the tag "base" with value "1", then the total +// If any samples have the tag "pprof::base" with value "true", then the total // will only include samples with that tag. func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64) int64 { var div, total, diffDiv, diffTotal int64 @@ -1231,7 +1231,7 @@ func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64) i v = -v } total += v - if sample.HasTag("base", "1") { + if sample.HasTag("pprof::base", "true") { diffTotal += v diffDiv += d } diff --git a/internal/report/report_test.go b/internal/report/report_test.go index 8e689aef1..57e0bd266 100644 --- a/internal/report/report_test.go +++ b/internal/report/report_test.go @@ -330,7 +330,7 @@ func TestComputeTotal(t *testing.T) { { Location: []*profile.Location{testL[2], testL[1], testL[0]}, Value: []int64{-10, 3}, - Label: map[string][]string{"base": {"1"}}, + Label: map[string][]string{"pprof::base": {"true"}}, }, { Location: []*profile.Location{testL[2], testL[1], testL[0]}, @@ -339,12 +339,12 @@ func TestComputeTotal(t *testing.T) { { Location: []*profile.Location{testL[2], testL[1], testL[0]}, Value: []int64{-9000, 3}, - Label: map[string][]string{"base": {"1"}}, + Label: map[string][]string{"pprof::base": {"true"}}, }, { Location: []*profile.Location{testL[2], testL[1], testL[0]}, Value: []int64{-1, 3}, - Label: map[string][]string{"base": {"1"}}, + Label: map[string][]string{"pprof::base": {"true"}}, }, { Location: []*profile.Location{testL[4], testL[2], testL[0]}, @@ -353,7 +353,7 @@ func TestComputeTotal(t *testing.T) { { Location: []*profile.Location{testL[2], testL[1], testL[0]}, Value: []int64{100, 3}, - Label: map[string][]string{"base": {"1"}}, + Label: map[string][]string{"pprof::base": {"true"}}, }, }