Skip to content

Commit

Permalink
use pprof::bass=true to mark diff base samples
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanmar511 committed May 4, 2018
1 parent d8c13e5 commit 5b29f9e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions doc/pprof.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions internal/driver/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}},
},
},
"",
Expand Down
6 changes: 3 additions & 3 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions internal/report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]},
Expand All @@ -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]},
Expand All @@ -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"}},
},
}

Expand Down

0 comments on commit 5b29f9e

Please sign in to comment.