Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate pprof MergeNoClone #3251

Merged
merged 2 commits into from
May 2, 2024
Merged

Conversation

kolesnikovae
Copy link
Collaborator

@kolesnikovae kolesnikovae commented Apr 25, 2024

pprof.MergeNoClone has particularly tricky semantics which is very easy to misuse: specifically, it may cause duplication of samples. Although the function is significantly cheaper than pprof.Merge and can be fixed, I think it's better to deprecate it in favour of safety

@kolesnikovae kolesnikovae force-pushed the chore/deprecate-merge-no-clone branch from c0d797d to 4121d1b Compare April 25, 2024 12:23
pkg/pprof/merge.go Outdated Show resolved Hide resolved
@kolesnikovae kolesnikovae marked this pull request as ready for review April 25, 2024 12:36
@kolesnikovae kolesnikovae requested a review from a team as a code owner April 25, 2024 12:36
Comment on lines 24 to +37
p, err := OpenFile("testdata/go.cpu.labels.pprof")
require.NoError(t, err)
var m ProfileMerge
require.NoError(t, m.Merge(p.Profile))
require.NoError(t, m.Merge(p.Profile.CloneVT()))
sortLabels(p.Profile)
testhelper.EqualProto(t, p.Profile, m.Profile())
}

func sortLabels(p *profilev1.Profile) {
for _, s := range p.Sample {
sort.Sort(LabelsByKeyValue(s.Label))
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Merge modifies profiles in place. Therefore, some tests were incorrect. MergeNoClone in addition retains the objects; it's quite hard to use the function correctly.

@kolesnikovae kolesnikovae changed the title chore: deprecate pprof MergeNoClone fix: deprecate pprof MergeNoClone Apr 25, 2024
@kolesnikovae kolesnikovae merged commit 09f0787 into main May 2, 2024
16 checks passed
@kolesnikovae kolesnikovae deleted the chore/deprecate-merge-no-clone branch May 2, 2024 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants