Skip to content

Commit

Permalink
Fix pprof merge (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae authored Sep 8, 2023
1 parent 301751c commit cb13865
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/phlaredb/symdb/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func (r *pprofSymbols) init(symbols *Symbols, samples schemav1.Samples) {
r.symbols = symbols
r.samples = &samples
r.profile = &profile.Profile{
Sample: make([]*profile.Sample, len(samples.StacktraceIDs)),
Sample: make([]*profile.Sample, len(samples.StacktraceIDs)),
PeriodType: new(profile.ValueType),
}
r.locations = grow(r.locations, len(r.symbols.Locations))
r.mappings = grow(r.mappings, len(r.symbols.Mappings))
Expand Down
18 changes: 18 additions & 0 deletions pkg/phlaredb/symdb/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ func Test_memory_Resolver_ResolveProfile(t *testing.T) {
require.Equal(t, expectedFingerprint, profileFingerprint(resolved, 0))
}

func Test_memory_Resolver_ResolveProfile_multiple_partitions(t *testing.T) {
s := newMemSuite(t, [][]string{
{"testdata/profile.pb.gz"},
{"testdata/profile.pb.gz"},
})
expectedFingerprint := pprofFingerprint(s.profiles[0].Profile, 0)
for i := range expectedFingerprint {
expectedFingerprint[i][1] *= 2
}
r := NewResolver(context.Background(), s.db)
defer r.Release()
r.AddSamples(0, s.indexed[0][0].Samples)
r.AddSamples(1, s.indexed[1][0].Samples)
resolved, err := r.Profile()
require.NoError(t, err)
require.Equal(t, expectedFingerprint, profileFingerprint(resolved, 0))
}

func Test_memory_Resolver_ResolveTree(t *testing.T) {
s := newMemSuite(t, [][]string{{"testdata/profile.pb.gz"}})
expectedFingerprint := pprofFingerprint(s.profiles[0].Profile, 0)
Expand Down

0 comments on commit cb13865

Please sign in to comment.