Skip to content

Commit

Permalink
profiler: remove PprofDiff (#2267)
Browse files Browse the repository at this point in the history
We deprecated PprofDiff in v1.49.0, with a note that it would be removed
in a future release. There is a low likelihood that any user actually
depends on this, and at any rate we have had several releases during
which time staticcheck/other linters could flag the deprecated function.
Finally remove it and inline it into the one place it was used.
  • Loading branch information
nsrip-dd authored Oct 16, 2023
1 parent 0428ded commit c188333
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
16 changes: 0 additions & 16 deletions profiler/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,6 @@ func (fdp *fastDeltaProfiler) Delta(data []byte) (b []byte, err error) {
return b, nil
}

// PprofDiff computes the delta between all values b-a and returns them as a new
// profile. Samples that end up with a delta of 0 are dropped. WARNING: Profile
// a will be mutated by this function. You should pass a copy if that's
// undesirable.
//
// Deprecated: This function was introduced into our public API unintentionally.
// It will be removed in the next release. If you need this functionality,
// it can be implemented in two lines:
//
// a.Scale(-1)
// return pprofile.Merge([]*pprofile.Profile{a, b})
func PprofDiff(a, b *pprofile.Profile) (*pprofile.Profile, error) {
a.Scale(-1)
return pprofile.Merge([]*pprofile.Profile{a, b})
}

func goroutineDebug2ToPprof(r io.Reader, w io.Writer, t time.Time) (err error) {
// gostackparse.Parse() has been extensively tested and should not crash
// under any circumstances, but we really want to avoid crashing a customers
Expand Down
3 changes: 2 additions & 1 deletion profiler/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ func requirePprofEqual(t *testing.T, a, b []byte) {
require.NoError(t, err)
pprofB, err := pprofile.ParseData(b)
require.NoError(t, err)
pprofDiff, err := PprofDiff(pprofA, pprofB)
pprofA.Scale(-1)
pprofDiff, err := pprofile.Merge([]*pprofile.Profile{pprofA, pprofB})
require.NoError(t, err)
require.Len(t, pprofDiff.Sample, 0)
}

0 comments on commit c188333

Please sign in to comment.