Skip to content

Conversation

iblancasa
Copy link
Contributor

Description

Link to tracking issue

This is part of #13106
It introduces a new MergeFrom method, which allows merging to profiles.

Continuation fort #13588

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 65.86667% with 128 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.45%. Comparing base (5ec1466) to head (e2010f9).

Files with missing lines Patch % Lines
pdata/pprofile/merge.go 65.86% 87 Missing and 41 partials ⚠️

❌ Your patch check has failed because the patch coverage (65.86%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13928      +/-   ##
==========================================
- Coverage   91.67%   91.45%   -0.22%     
==========================================
  Files         652      653       +1     
  Lines       42516    42891     +375     
==========================================
+ Hits        38977    39228     +251     
- Misses       2731     2815      +84     
- Partials      808      848      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Israel Blancas <[email protected]>
Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

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

This is pretty nice. I'd look into splitting the PR into smaller bits, to ease review.

return ErrDictionarySizeExceeded
}
if int64(destDict.AttributeTable().Len())+int64(sourceDict.AttributeTable().Len()) > math.MaxInt32 {
return ErrDictionarySizeExceeded
Copy link
Member

Choose a reason for hiding this comment

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

This returns many times the same error, making it a bit hard to know which table exceeds the size. How about building a dynamic error with the name of the table?

attributeTable map[int32]int32
}

func (ms Profiles) mergeDictionaries(destDict, sourceDict ProfilesDictionary) (*indexMappings, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I would move this (and the other relevant methods) into the ProfilesDictionary struct.
Not as a public method (we probably don't need it exposed), but as mergeFrom.

return nil
}

func stacksEqual(a, b Stack) bool {
Copy link
Member

Choose a reason for hiding this comment

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

For these, we have been introducing Equal() public methods. How about doing the same here?

Copy link
Member

Choose a reason for hiding this comment

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

See #13952

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!


func applyStringMappingToValueType(v ValueType, stringMapping map[int32]int32) {
if idx := v.TypeStrindex(); idx >= 0 {
if newIdx, exists := stringMapping[idx]; exists {
Copy link
Member

Choose a reason for hiding this comment

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

This assumes the string always exists in the destination string table, which may not be the case.
We should use SetString here, which is meant exactly for that.

}
}

func copyValueType(src, dest ValueType, stringMapping map[int32]int32) {
Copy link
Member

Choose a reason for hiding this comment

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

How about a ValueType.mergeFrom method instead?

destIndices.EnsureCapacity(sourceIndices.Len())
for i := 0; i < sourceIndices.Len(); i++ {
idx := sourceIndices.At(i)
if newIdx, exists := mapping[idx]; exists {
Copy link
Member

Choose a reason for hiding this comment

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

This has the same issue as above with data missing from the mapping table. It should use PutAttribute/SetString.

github-merge-queue bot pushed a commit that referenced this pull request Oct 10, 2025
This introduces `Stack.Equal()`, to help with profiles merging.
See #13928
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.

2 participants