Skip to content

Commit

Permalink
pkg/query/flamegraph_arrow: Fix label dictionaries
Browse files Browse the repository at this point in the history
Also the mapping and function dictionaries don't leak here. It must be somewhere before that.
  • Loading branch information
metalmatze committed Aug 31, 2023
1 parent 94141b7 commit 759eabe
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions pkg/query/flamegraph_arrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,7 @@ func (fb *flamegraphBuilder) NewRecord() (arrow.Record, error) {
arrays[3] = fb.builderMappingOffset.NewArray()
cleanupArrs = append(cleanupArrs, arrays[3])
arrays[4] = fb.mappingFile
cleanupArrs = append(cleanupArrs, arrays[4])
arrays[5] = fb.mappingBuildID
cleanupArrs = append(cleanupArrs, arrays[5])
arrays[6] = fb.builderLocationAddress.NewArray()
cleanupArrs = append(cleanupArrs, arrays[6])
arrays[7] = fb.builderLocationFolded.NewArray()
Expand All @@ -1032,11 +1030,8 @@ func (fb *flamegraphBuilder) NewRecord() (arrow.Record, error) {
arrays[9] = fb.builderFunctionStartLine.NewArray()
cleanupArrs = append(cleanupArrs, arrays[9])
arrays[10] = fb.functionName
cleanupArrs = append(cleanupArrs, arrays[10])
arrays[11] = fb.functionSystemName
cleanupArrs = append(cleanupArrs, arrays[11])
arrays[12] = fb.functionFilename
cleanupArrs = append(cleanupArrs, arrays[12])
arrays[13] = fb.builderChildren.NewArray()
cleanupArrs = append(cleanupArrs, arrays[13])
arrays[14] = fb.builderCumulative.NewArray()
Expand Down Expand Up @@ -1454,23 +1449,20 @@ func (fb *flamegraphBuilder) trim(ctx context.Context, tracer trace.Tracer, thre
}
fb.functionFilename = functionFilename

trimmedLabels := make([]*array.Dictionary, 0, len(fb.labels))
trimmedLabels := make([]*array.Dictionary, 0, len(trimmedLabelsIndices))
for i, index := range trimmedLabelsIndices {
trimmedIndexArray := index.NewArray()
releasers = append(releasers, trimmedIndexArray)
tl, err := compactDictionary(fb.pool, array.NewDictionaryArray(
&arrow.DictionaryType{IndexType: trimmedIndexArray.DataType(), ValueType: fb.labels[i].Dictionary().DataType()},
&arrow.DictionaryType{IndexType: trimmedIndexArray.DataType(), ValueType: fb.preparedLabels[i].Dictionary().DataType()},
trimmedIndexArray,
fb.labels[i].Dictionary(),
fb.preparedLabels[i].Dictionary(),
))
if err != nil {
return err
}
trimmedLabels = append(trimmedLabels, tl)
}
for i := range fb.labels {
fb.labels[i].Release()
}
fb.labels = trimmedLabels

if fb.builderLabelsOnly != nil {
Expand Down

0 comments on commit 759eabe

Please sign in to comment.