From a3abdf3f5c4141e73b4b1c72b8a2028c183f4899 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Mon, 10 Jun 2024 13:28:58 +0200 Subject: [PATCH] Allow to use numeric labels (#37) * allow for usage of numeric labels * add missing sorting --- go.mod | 4 ++-- go.sum | 4 ++++ pprof_analysis.go | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1da9352..1ea7433 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/dbenamy/profiler-correctness/v1 go 1.19 require ( - github.com/google/pprof v0.0.0-20210423192551-a2663126120b - github.com/pierrec/lz4/v4 v4.1.18 + github.com/google/pprof v0.0.0-20240528025155-186aa0362fba + github.com/pierrec/lz4/v4 v4.1.21 ) diff --git a/go.sum b/go.sum index 186fe01..bb7d5e7 100644 --- a/go.sum +++ b/go.sum @@ -3,9 +3,13 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/google/pprof v0.0.0-20210423192551-a2663126120b h1:l2YRhr+YLzmSp7KJMswRVk/lO5SwoFIcCLzJsVj+YPc= github.com/google/pprof v0.0.0-20210423192551-a2663126120b/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g= +github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= +github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/pprof_analysis.go b/pprof_analysis.go index d5801a9..e8c791e 100644 --- a/pprof_analysis.go +++ b/pprof_analysis.go @@ -10,6 +10,7 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" "testing" @@ -149,7 +150,7 @@ func contains_str(s []string, v string) bool { func captureProfData(t *testing.T, prof *profile.Profile, path string, testName string, profileDuration float64) { // labels to ignore - keysToIgnore := []string{"thread id", "thread native id"} + keysToIgnore := []string{"thread native id"} var capturedData StackTestData capturedData.TestName = testName @@ -237,7 +238,7 @@ func getProfileType(t *testing.T, profile *profile.Profile, type_ string) []Stac // t.Logf("Found '%s' smaple type at idx %d\n", type_, typeIdx) // if err := profile.Aggregate(true, true, false, p.LineNumbers, false); err != nil { - if err := profile.Aggregate(true, true, false, false, false); err != nil { + if err := profile.Aggregate(true, true, false, false, false, false); err != nil { t.Fatalf("Error aggregating profile samples: %v", err) } profile = profile.Compact() @@ -266,6 +267,13 @@ func getProfileType(t *testing.T, profile *profile.Profile, type_ string) []Stac labels[k] = v // t.Log("Sorted labels :", v) } + for k, v := range sample.NumLabel { + for _, i := range v { + labels[k] = append(labels[k], strconv.FormatInt(i, 10)) + } + sort.Strings(labels[k]); + } + ss := StackSample{ Stack: strings.Join(frames, ";"), Val: sample.Value[typeIdx],