From d75fbe5d0ce476eb18844fb014da7074a2e832b0 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Wed, 19 Apr 2023 17:18:07 -0700 Subject: [PATCH 1/7] sort ProxyResponseHeap comparing only diff labels Signed-off-by: Walther Lee --- pkg/store/proxy_heap.go | 21 ++++++- pkg/store/proxy_heap_test.go | 117 +++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index 028ac81a7e..9e927aaed3 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -172,7 +172,7 @@ func (h *ProxyResponseHeap) Less(i, j int) bool { if iResp.GetSeries() != nil && jResp.GetSeries() != nil { iLbls := labelpb.ZLabelsToPromLabels(iResp.GetSeries().Labels) jLbls := labelpb.ZLabelsToPromLabels(jResp.GetSeries().Labels) - return labels.Compare(iLbls, jLbls) < 0 + return compareDiffLabels(iLbls, jLbls) < 0 } else if iResp.GetSeries() == nil && jResp.GetSeries() != nil { return true } else if iResp.GetSeries() != nil && jResp.GetSeries() == nil { @@ -737,6 +737,25 @@ func newEagerRespSet( return ret } +// compareDiffLabels compares the two label sets, skipping labels with the same value in both sets. +func compareDiffLabels(a, b labels.Labels) int { + a = a.Copy() + b = b.Copy() + aMap := make(map[string]string) + labelsToRemove := make(map[string]struct{}) + for i := 0; i < len(a); i++ { + aMap[a[i].Name] = a[i].Value + } + for i := 0; i < len(b); i++ { + if v, ok := aMap[b[i].Name]; ok { + if b[i].Value == v { + labelsToRemove[b[i].Name] = struct{}{} + } + } + } + return labels.Compare(rmLabels(a, labelsToRemove), rmLabels(b, labelsToRemove)) +} + func rmLabels(l labels.Labels, labelsToRemove map[string]struct{}) labels.Labels { for i := 0; i < len(l); i++ { if _, ok := labelsToRemove[l[i].Name]; !ok { diff --git a/pkg/store/proxy_heap_test.go b/pkg/store/proxy_heap_test.go index d37b4e4840..bfa17361ec 100644 --- a/pkg/store/proxy_heap_test.go +++ b/pkg/store/proxy_heap_test.go @@ -22,6 +22,123 @@ func TestRmLabelsCornerCases(t *testing.T) { }), labels.Labels{}) } +type testingRespSet struct { + bufferedResponse []*storepb.SeriesResponse + i int +} + +func (l *testingRespSet) Close() {} + +func (l *testingRespSet) At() *storepb.SeriesResponse { + return l.bufferedResponse[l.i] +} + +func (l *testingRespSet) Next() bool { + l.i++ + return l.i < len(l.bufferedResponse) +} + +func (l *testingRespSet) StoreID() string { + return "" +} + +func (l *testingRespSet) Labelset() string { + return "" +} + +func (l *testingRespSet) Empty() bool { + return l.i >= len(l.bufferedResponse) +} + +func TestProxyResponseHeapSort(t *testing.T) { + for _, tcase := range []struct { + input []respSet + exp []*storepb.SeriesResponse + }{ + // Different sorted response sets + { + input: []respSet{ + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3", "d", "4")), + }, + }, + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "4", "e", "5")), + }, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3", "d", "4")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "4", "e", "5")), + }, + }, + // Sorted response sets with different number of labels in their series + { + input: []respSet{ + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("b", "2", "c", "3")), + }, + }, + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "e", "5")), + }, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("b", "2", "c", "3")), + }, + }, + // Duplicated response sets that are sorted if you remove common label-values + // This is similar to response sets from stores that sort the set before adding external labels + { + input: []respSet{ + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + }, + }, + &testingRespSet{ + bufferedResponse: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + }, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + }, + }, + } { + t.Run("", func(t *testing.T) { + h := NewProxyResponseHeap(tcase.input...) + if !h.Empty() { + got := []*storepb.SeriesResponse{h.At()} + for h.Next() { + got = append(got, h.At()) + } + testutil.Equals(t, tcase.exp, got) + } + }) + } +} + func TestSortWithoutLabels(t *testing.T) { for _, tcase := range []struct { input []*storepb.SeriesResponse From 4df39d74ccc8adadf9b590164490694b36c7af28 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Fri, 21 Apr 2023 19:28:27 -0700 Subject: [PATCH 2/7] proxy heap: remove store labels before comparing response series Signed-off-by: Walther Lee --- pkg/store/proxy_heap.go | 46 ++++++++++++++++++++---------------- pkg/store/proxy_heap_test.go | 31 +++++++++++++++--------- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index 9e927aaed3..eaecac71ad 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -170,9 +170,13 @@ func (h *ProxyResponseHeap) Less(i, j int) bool { jResp := (*h)[j].rs.At() if iResp.GetSeries() != nil && jResp.GetSeries() != nil { + // Response sets are sorted before adding external labels. + // This comparison excludes those labels to keep the same order. + iStoreLbls := (*h)[i].rs.StoreLabels() + jStoreLbls := (*h)[j].rs.StoreLabels() iLbls := labelpb.ZLabelsToPromLabels(iResp.GetSeries().Labels) jLbls := labelpb.ZLabelsToPromLabels(jResp.GetSeries().Labels) - return compareDiffLabels(iLbls, jLbls) < 0 + return labels.Compare(rmLabels(iLbls.Copy(), iStoreLbls), rmLabels(jLbls.Copy(), jStoreLbls)) < 0 } else if iResp.GetSeries() == nil && jResp.GetSeries() != nil { return true } else if iResp.GetSeries() != nil && jResp.GetSeries() == nil { @@ -257,6 +261,10 @@ func (l *lazyRespSet) Labelset() string { return labelpb.PromLabelSetsToString(l.storeLabelSets) } +func (l *lazyRespSet) StoreLabels() map[string]struct{} { + return l.storeLabels +} + // lazyRespSet is a lazy storepb.SeriesSet that buffers // everything as fast as possible while at the same it permits // reading response-by-response. It blocks if there is no data @@ -268,6 +276,7 @@ type lazyRespSet struct { closeSeries context.CancelFunc storeName string storeLabelSets []labels.Labels + storeLabels map[string]struct{} frameTimeout time.Duration ctx context.Context @@ -374,6 +383,11 @@ func newLazyRespSet( bufferedResponses: bufferedResponses, shardMatcher: shardMatcher, } + for _, ls := range storeLabelSets { + for _, l := range ls { + respSet.storeLabels[l.Name] = struct{}{} + } + } go func(st string, l *lazyRespSet) { bytesProcessed := 0 @@ -610,6 +624,7 @@ type eagerRespSet struct { shardMatcher *storepb.ShardMatcher removeLabels map[string]struct{} + storeLabels map[string]struct{} // Internal bookkeeping. bufferedResponses []*storepb.SeriesResponse @@ -641,6 +656,11 @@ func newEagerRespSet( shardMatcher: shardMatcher, removeLabels: removeLabels, } + for _, ls := range st.LabelSets() { + for _, l := range ls { + ret.storeLabels[l.Name] = struct{}{} + } + } ret.wg.Add(1) @@ -737,25 +757,6 @@ func newEagerRespSet( return ret } -// compareDiffLabels compares the two label sets, skipping labels with the same value in both sets. -func compareDiffLabels(a, b labels.Labels) int { - a = a.Copy() - b = b.Copy() - aMap := make(map[string]string) - labelsToRemove := make(map[string]struct{}) - for i := 0; i < len(a); i++ { - aMap[a[i].Name] = a[i].Value - } - for i := 0; i < len(b); i++ { - if v, ok := aMap[b[i].Name]; ok { - if b[i].Value == v { - labelsToRemove[b[i].Name] = struct{}{} - } - } - } - return labels.Compare(rmLabels(a, labelsToRemove), rmLabels(b, labelsToRemove)) -} - func rmLabels(l labels.Labels, labelsToRemove map[string]struct{}) labels.Labels { for i := 0; i < len(l); i++ { if _, ok := labelsToRemove[l[i].Name]; !ok { @@ -830,11 +831,16 @@ func (l *eagerRespSet) Labelset() string { return labelpb.PromLabelSetsToString(l.st.LabelSets()) } +func (l *eagerRespSet) StoreLabels() map[string]struct{} { + return l.storeLabels +} + type respSet interface { Close() At() *storepb.SeriesResponse Next() bool StoreID() string Labelset() string + StoreLabels() map[string]struct{} Empty() bool } diff --git a/pkg/store/proxy_heap_test.go b/pkg/store/proxy_heap_test.go index bfa17361ec..581502c956 100644 --- a/pkg/store/proxy_heap_test.go +++ b/pkg/store/proxy_heap_test.go @@ -24,6 +24,7 @@ func TestRmLabelsCornerCases(t *testing.T) { type testingRespSet struct { bufferedResponse []*storepb.SeriesResponse + storeLabels map[string]struct{} i int } @@ -50,13 +51,18 @@ func (l *testingRespSet) Empty() bool { return l.i >= len(l.bufferedResponse) } +func (l *testingRespSet) StoreLabels() map[string]struct{} { + return l.storeLabels +} + func TestProxyResponseHeapSort(t *testing.T) { for _, tcase := range []struct { + title string input []respSet exp []*storepb.SeriesResponse }{ - // Different sorted response sets { + title: "merge sets with different series and common labels", input: []respSet{ &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ @@ -66,56 +72,59 @@ func TestProxyResponseHeapSort(t *testing.T) { }, &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ - storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "4", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), }, }, }, exp: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), - storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3", "d", "4")), storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "4", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), }, }, - // Sorted response sets with different number of labels in their series { + title: "merge sets with different series and labels", input: []respSet{ &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), storeSeriesResponse(t, labelsFromStrings("b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("g", "7", "h", "8", "i", "9")), }, }, &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ - storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2")), - storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5", "f", "6")), }, }, }, exp: []*storepb.SeriesResponse{ - storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2")), storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), - storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "e", "5")), storeSeriesResponse(t, labelsFromStrings("b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5")), + storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5", "f", "6")), + storeSeriesResponse(t, labelsFromStrings("g", "7", "h", "8", "i", "9")), }, }, - // Duplicated response sets that are sorted if you remove common label-values - // This is similar to response sets from stores that sort the set before adding external labels { + title: "merge sets that were ordered before adding external labels", input: []respSet{ &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), }, + storeLabels: map[string]struct{}{"c": {}}, }, &testingRespSet{ bufferedResponse: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), }, + storeLabels: map[string]struct{}{"c": {}}, }, }, exp: []*storepb.SeriesResponse{ @@ -126,7 +135,7 @@ func TestProxyResponseHeapSort(t *testing.T) { }, }, } { - t.Run("", func(t *testing.T) { + t.Run(tcase.title, func(t *testing.T) { h := NewProxyResponseHeap(tcase.input...) if !h.Empty() { got := []*storepb.SeriesResponse{h.At()} From f460da5cd1e3d81df17996d7cc94ccb25d5034d8 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Mon, 24 Apr 2023 18:53:39 -0700 Subject: [PATCH 3/7] Remove testingRespSet and update comparison func Signed-off-by: Walther Lee --- pkg/store/proxy_heap.go | 6 ++- pkg/store/proxy_heap_test.go | 93 ++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 47 deletions(-) diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index eaecac71ad..8ad490eabf 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -176,7 +176,11 @@ func (h *ProxyResponseHeap) Less(i, j int) bool { jStoreLbls := (*h)[j].rs.StoreLabels() iLbls := labelpb.ZLabelsToPromLabels(iResp.GetSeries().Labels) jLbls := labelpb.ZLabelsToPromLabels(jResp.GetSeries().Labels) - return labels.Compare(rmLabels(iLbls.Copy(), iStoreLbls), rmLabels(jLbls.Copy(), jStoreLbls)) < 0 + c := labels.Compare(rmLabels(iLbls.Copy(), iStoreLbls), rmLabels(jLbls.Copy(), jStoreLbls)) + if c == 0 { + c = labels.Compare(iLbls, jLbls) + } + return c < 0 } else if iResp.GetSeries() == nil && jResp.GetSeries() != nil { return true } else if iResp.GetSeries() != nil && jResp.GetSeries() == nil { diff --git a/pkg/store/proxy_heap_test.go b/pkg/store/proxy_heap_test.go index 581502c956..d7cdc2eefb 100644 --- a/pkg/store/proxy_heap_test.go +++ b/pkg/store/proxy_heap_test.go @@ -4,6 +4,7 @@ package store import ( + "sync" "testing" "github.com/efficientgo/core/testutil" @@ -22,39 +23,6 @@ func TestRmLabelsCornerCases(t *testing.T) { }), labels.Labels{}) } -type testingRespSet struct { - bufferedResponse []*storepb.SeriesResponse - storeLabels map[string]struct{} - i int -} - -func (l *testingRespSet) Close() {} - -func (l *testingRespSet) At() *storepb.SeriesResponse { - return l.bufferedResponse[l.i] -} - -func (l *testingRespSet) Next() bool { - l.i++ - return l.i < len(l.bufferedResponse) -} - -func (l *testingRespSet) StoreID() string { - return "" -} - -func (l *testingRespSet) Labelset() string { - return "" -} - -func (l *testingRespSet) Empty() bool { - return l.i >= len(l.bufferedResponse) -} - -func (l *testingRespSet) StoreLabels() map[string]struct{} { - return l.storeLabels -} - func TestProxyResponseHeapSort(t *testing.T) { for _, tcase := range []struct { title string @@ -64,14 +32,16 @@ func TestProxyResponseHeapSort(t *testing.T) { { title: "merge sets with different series and common labels", input: []respSet{ - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3", "d", "4")), }, }, - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "4", "e", "5")), storeSeriesResponse(t, labelsFromStrings("a", "1", "d", "4")), }, @@ -87,15 +57,17 @@ func TestProxyResponseHeapSort(t *testing.T) { { title: "merge sets with different series and labels", input: []respSet{ - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), storeSeriesResponse(t, labelsFromStrings("b", "2", "c", "3")), storeSeriesResponse(t, labelsFromStrings("g", "7", "h", "8", "i", "9")), }, }, - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5")), storeSeriesResponse(t, labelsFromStrings("d", "4", "e", "5", "f", "6")), }, @@ -110,17 +82,19 @@ func TestProxyResponseHeapSort(t *testing.T) { }, }, { - title: "merge sets that were ordered before adding external labels", + title: "merge duplicated sets that were ordered before adding external labels", input: []respSet{ - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), }, storeLabels: map[string]struct{}{"c": {}}, }, - &testingRespSet{ - bufferedResponse: []*storepb.SeriesResponse{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), }, @@ -134,6 +108,33 @@ func TestProxyResponseHeapSort(t *testing.T) { storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), }, }, + { + title: "merge repeated series in stores with different external labels", + input: []respSet{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + }, + storeLabels: map[string]struct{}{"ext2": {}}, + }, + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + }, + storeLabels: map[string]struct{}{"ext1": {}, "ext2": {}}, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + }, + }, } { t.Run(tcase.title, func(t *testing.T) { h := NewProxyResponseHeap(tcase.input...) From 5a7c76418e3d9465a951afca1ccf9a9166a88545 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Mon, 24 Apr 2023 20:28:48 -0700 Subject: [PATCH 4/7] Fix tests Signed-off-by: Walther Lee --- pkg/store/proxy_heap.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index 8ad490eabf..abbca932dc 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -387,6 +387,7 @@ func newLazyRespSet( bufferedResponses: bufferedResponses, shardMatcher: shardMatcher, } + respSet.storeLabels = make(map[string]struct{}) for _, ls := range storeLabelSets { for _, l := range ls { respSet.storeLabels[l.Name] = struct{}{} @@ -660,6 +661,7 @@ func newEagerRespSet( shardMatcher: shardMatcher, removeLabels: removeLabels, } + ret.storeLabels = make(map[string]struct{}) for _, ls := range st.LabelSets() { for _, l := range ls { ret.storeLabels[l.Name] = struct{}{} From 85067c356ff56e4032fea4d9324c83b6de4f40bb Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Thu, 27 Apr 2023 09:32:23 +0200 Subject: [PATCH 5/7] Reuse buffers for label comparison Signed-off-by: Filip Petkovski --- pkg/store/proxy_heap.go | 73 ++++++++++++++++++++++++++++-------- pkg/store/proxy_heap_test.go | 55 +++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 15 deletions(-) diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index abbca932dc..d1f9acbd31 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -163,24 +163,37 @@ func (d *dedupResponseHeap) At() *storepb.SeriesResponse { // This is O(n*logk) but can be Theta(n*logk). However, // tournament trees need n-1 auxiliary nodes so there // might not be much of a difference. -type ProxyResponseHeap []ProxyResponseHeapNode +type ProxyResponseHeap struct { + nodes []ProxyResponseHeapNode + iLblsScratch labels.Labels + jLblsScratch labels.Labels +} func (h *ProxyResponseHeap) Less(i, j int) bool { - iResp := (*h)[i].rs.At() - jResp := (*h)[j].rs.At() + iResp := h.nodes[i].rs.At() + jResp := h.nodes[j].rs.At() if iResp.GetSeries() != nil && jResp.GetSeries() != nil { // Response sets are sorted before adding external labels. // This comparison excludes those labels to keep the same order. - iStoreLbls := (*h)[i].rs.StoreLabels() - jStoreLbls := (*h)[j].rs.StoreLabels() + iStoreLbls := h.nodes[i].rs.StoreLabels() + jStoreLbls := h.nodes[j].rs.StoreLabels() + iLbls := labelpb.ZLabelsToPromLabels(iResp.GetSeries().Labels) jLbls := labelpb.ZLabelsToPromLabels(jResp.GetSeries().Labels) - c := labels.Compare(rmLabels(iLbls.Copy(), iStoreLbls), rmLabels(jLbls.Copy(), jStoreLbls)) - if c == 0 { - c = labels.Compare(iLbls, jLbls) + + copyLabels(&h.iLblsScratch, iLbls) + copyLabels(&h.jLblsScratch, jLbls) + + var iExtLbls, jExtLbls labels.Labels + h.iLblsScratch, iExtLbls = dropLabels(h.iLblsScratch, iStoreLbls) + h.jLblsScratch, jExtLbls = dropLabels(h.jLblsScratch, jStoreLbls) + + c := labels.Compare(h.iLblsScratch, h.jLblsScratch) + if c != 0 { + return c < 0 } - return c < 0 + return labels.Compare(iExtLbls, jExtLbls) < 0 } else if iResp.GetSeries() == nil && jResp.GetSeries() != nil { return true } else if iResp.GetSeries() != nil && jResp.GetSeries() == nil { @@ -193,19 +206,19 @@ func (h *ProxyResponseHeap) Less(i, j int) bool { } func (h *ProxyResponseHeap) Len() int { - return len(*h) + return len(h.nodes) } func (h *ProxyResponseHeap) Swap(i, j int) { - (*h)[i], (*h)[j] = (*h)[j], (*h)[i] + h.nodes[i], h.nodes[j] = h.nodes[j], h.nodes[i] } func (h *ProxyResponseHeap) Push(x interface{}) { - *h = append(*h, x.(ProxyResponseHeapNode)) + h.nodes = append(h.nodes, x.(ProxyResponseHeapNode)) } func (h *ProxyResponseHeap) Pop() (v interface{}) { - *h, v = (*h)[:h.Len()-1], (*h)[h.Len()-1] + h.nodes, v = h.nodes[:h.Len()-1], h.nodes[h.Len()-1] return } @@ -214,7 +227,7 @@ func (h *ProxyResponseHeap) Empty() bool { } func (h *ProxyResponseHeap) Min() *ProxyResponseHeapNode { - return &(*h)[0] + return &h.nodes[0] } type ProxyResponseHeapNode struct { @@ -224,7 +237,9 @@ type ProxyResponseHeapNode struct { // NewProxyResponseHeap returns heap that k-way merge series together. // It's agnostic to duplicates and overlaps, it forwards all duplicated series in random order. func NewProxyResponseHeap(seriesSets ...respSet) *ProxyResponseHeap { - ret := make(ProxyResponseHeap, 0, len(seriesSets)) + ret := ProxyResponseHeap{ + nodes: make([]ProxyResponseHeapNode, 0, len(seriesSets)), + } for _, ss := range seriesSets { if ss.Empty() { @@ -774,6 +789,34 @@ func rmLabels(l labels.Labels, labelsToRemove map[string]struct{}) labels.Labels return l } +// dropLabels removes labels from the given label set and returns the removed labels. +func dropLabels(l labels.Labels, labelsToDrop map[string]struct{}) (labels.Labels, labels.Labels) { + cutoff := len(l) + for i := 0; i < len(l); i++ { + if i == cutoff { + break + } + if _, ok := labelsToDrop[l[i].Name]; !ok { + continue + } + + lbl := l[i] + l = append(append(l[:i], l[i+1:]...), lbl) + cutoff-- + i-- + } + + return l[:cutoff], l[cutoff:] +} + +func copyLabels(dest *labels.Labels, src labels.Labels) { + if len(*dest) < len(src) { + *dest = make([]labels.Label, len(src)) + } + *dest = (*dest)[:len(src)] + copy(*dest, src) +} + // sortWithoutLabels removes given labels from series and re-sorts the series responses that the same // series with different labels are coming right after each other. Other types of responses are moved to front. func sortWithoutLabels(set []*storepb.SeriesResponse, labelsToRemove map[string]struct{}) { diff --git a/pkg/store/proxy_heap_test.go b/pkg/store/proxy_heap_test.go index d7cdc2eefb..fdfec178ca 100644 --- a/pkg/store/proxy_heap_test.go +++ b/pkg/store/proxy_heap_test.go @@ -9,6 +9,7 @@ import ( "github.com/efficientgo/core/testutil" "github.com/prometheus/prometheus/model/labels" + "github.com/thanos-io/thanos/pkg/dedup" "github.com/thanos-io/thanos/pkg/errors" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -135,6 +136,60 @@ func TestProxyResponseHeapSort(t *testing.T) { storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), }, }, + { + title: "merge series with external labels at beginning of series", + input: []respSet{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "2")), + }, + storeLabels: map[string]struct{}{"a": {}}, + }, + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + }, + storeLabels: map[string]struct{}{"a": {}}, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "1", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "c", "3")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "2")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "c", "3")), + }, + }, + { + title: "merge series in stores with external labels not present in series (e.g. stripped during dedup)", + input: []respSet{ + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + }, + storeLabels: map[string]struct{}{"ext2": {}, "replica": {}}, + }, + &eagerRespSet{ + wg: &sync.WaitGroup{}, + bufferedResponses: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + }, + storeLabels: map[string]struct{}{"ext1": {}, "ext2": {}, "replica": {}}, + }, + }, + exp: []*storepb.SeriesResponse{ + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext1", "5", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + storeSeriesResponse(t, labelsFromStrings("a", "1", "b", "2", "ext2", "9")), + }, + }, } { t.Run(tcase.title, func(t *testing.T) { h := NewProxyResponseHeap(tcase.input...) From d2c6333cfa6305218e34e72b54988dc6d7461883 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Thu, 27 Apr 2023 15:47:51 +0200 Subject: [PATCH 6/7] Use len instead of cap Signed-off-by: Filip Petkovski --- branch-optimized.out | 58 +++++++++++++++++++++++++++++++++++++++++ branch.out | 58 +++++++++++++++++++++++++++++++++++++++++ main.out | 58 +++++++++++++++++++++++++++++++++++++++++ pkg/store/proxy_heap.go | 2 +- 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 branch-optimized.out create mode 100644 branch.out create mode 100644 main.out diff --git a/branch-optimized.out b/branch-optimized.out new file mode 100644 index 0000000000..8a26380d83 --- /dev/null +++ b/branch-optimized.out @@ -0,0 +1,58 @@ +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/0 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/1 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/2 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/3 +goos: darwin +goarch: arm64 +pkg: github.com/thanos-io/thanos/pkg/store +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 158857548 ns/op 83947138 B/op 308 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 157167155 ns/op 83947059 B/op 309 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 8 161957891 ns/op 83946597 B/op 308 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 160205798 ns/op 83946730 B/op 307 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 156346476 ns/op 83946545 B/op 308 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167804982 ns/op 83360371 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167674000 ns/op 83360365 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167907363 ns/op 83360299 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 168278554 ns/op 83360379 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167559071 ns/op 83360332 B/op 154 allocs/op +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/0 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/1 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/2 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/3 +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 80 16228542 ns/op 7638188 B/op 258 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 78 16416622 ns/op 7637896 B/op 257 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 79 16370143 ns/op 7637986 B/op 257 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 78 16848665 ns/op 7637845 B/op 257 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 75 16613844 ns/op 7637795 B/op 257 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17727925 ns/op 8206839 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17947329 ns/op 8206830 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17870753 ns/op 8206846 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17968765 ns/op 8206848 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 69 17951987 ns/op 8206832 B/op 134 allocs/op +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/0 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/1 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/2 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/3 +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71779 16359 ns/op 8227 B/op 136 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73178 16381 ns/op 8227 B/op 136 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 72333 16388 ns/op 8228 B/op 136 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71834 16622 ns/op 8228 B/op 136 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73404 16463 ns/op 8228 B/op 136 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160734 7705 ns/op 3769 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 156384 7739 ns/op 3769 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 154957 7701 ns/op 3769 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 154280 7678 ns/op 3769 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 152821 7868 ns/op 3769 B/op 80 allocs/op +PASS +ok github.com/thanos-io/thanos/pkg/store 49.669s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache 0.632s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.243s +? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] +PASS +ok github.com/thanos-io/thanos/pkg/store/labelpb 0.261s +PASS +ok github.com/thanos-io/thanos/pkg/store/storepb 0.381s +? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] +? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files] diff --git a/branch.out b/branch.out new file mode 100644 index 0000000000..c847552df0 --- /dev/null +++ b/branch.out @@ -0,0 +1,58 @@ +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/0 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/1 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/2 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/3 +goos: darwin +goarch: arm64 +pkg: github.com/thanos-io/thanos/pkg/store +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 232833200 ns/op 243947392 B/op 2500310 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 236852475 ns/op 243947772 B/op 2500310 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 4 275805448 ns/op 243947688 B/op 2500311 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 4 250956614 ns/op 243947820 B/op 2500311 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 252837850 ns/op 243947596 B/op 2500311 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 183623708 ns/op 83360374 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 182530188 ns/op 83360354 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 172891625 ns/op 83360276 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 177037911 ns/op 83360323 B/op 154 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 177693976 ns/op 83360276 B/op 154 allocs/op +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/0 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/1 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/2 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/3 +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 45 24994671 ns/op 23639309 B/op 250260 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 24830660 ns/op 23638706 B/op 250259 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 45 25789010 ns/op 23638447 B/op 250258 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 25813167 ns/op 23638650 B/op 250259 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 25142471 ns/op 23638748 B/op 250259 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17836342 ns/op 8206786 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17983012 ns/op 8206787 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17472039 ns/op 8206777 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 69 17475200 ns/op 8206782 B/op 134 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17084748 ns/op 8206760 B/op 134 allocs/op +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/0 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/1 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/2 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/3 +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 69438 16712 ns/op 8812 B/op 146 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 66511 17205 ns/op 8812 B/op 146 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 70868 16953 ns/op 8812 B/op 146 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71019 16651 ns/op 8812 B/op 146 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 72241 16729 ns/op 8812 B/op 146 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160410 7857 ns/op 3713 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 150763 7762 ns/op 3713 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 159288 7832 ns/op 3713 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 158436 7915 ns/op 3713 B/op 80 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 148728 7721 ns/op 3713 B/op 80 allocs/op +PASS +ok github.com/thanos-io/thanos/pkg/store 53.263s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache 0.423s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.124s +? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] +PASS +ok github.com/thanos-io/thanos/pkg/store/labelpb 0.148s +PASS +ok github.com/thanos-io/thanos/pkg/store/storepb 0.288s +? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] +? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files] diff --git a/main.out b/main.out new file mode 100644 index 0000000000..e6fe7a0ec7 --- /dev/null +++ b/main.out @@ -0,0 +1,58 @@ +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/0 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/1 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/2 +Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/3 +goos: darwin +goarch: arm64 +pkg: github.com/thanos-io/thanos/pkg/store +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 122496806 ns/op 83946710 B/op 303 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 129038903 ns/op 83946470 B/op 303 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 125925921 ns/op 83946382 B/op 301 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 10 124710467 ns/op 83946406 B/op 302 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 125908588 ns/op 83946278 B/op 302 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 178174250 ns/op 83360129 B/op 152 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 175442931 ns/op 83360182 B/op 152 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 177222250 ns/op 83360169 B/op 152 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 177196979 ns/op 83360238 B/op 152 allocs/op +BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 176612146 ns/op 83360208 B/op 153 allocs/op +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/0 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/1 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/2 +Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/3 +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 87 13842230 ns/op 7637714 B/op 251 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 87 13614246 ns/op 7637862 B/op 252 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 99 13466323 ns/op 7637441 B/op 251 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 100 13463995 ns/op 7637418 B/op 251 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 96 12932889 ns/op 7637346 B/op 250 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16950276 ns/op 8206591 B/op 132 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16880842 ns/op 8206579 B/op 132 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 74 16871241 ns/op 8206614 B/op 132 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 74 16911964 ns/op 8206600 B/op 132 allocs/op +BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16867682 ns/op 8206585 B/op 132 allocs/op +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/0 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/1 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/2 +Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/3 +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 70292 16737 ns/op 7852 B/op 130 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 74174 16182 ns/op 7852 B/op 130 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 74235 16361 ns/op 7852 B/op 130 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 75582 16265 ns/op 7852 B/op 130 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73658 16238 ns/op 7851 B/op 130 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 158442 7505 ns/op 3521 B/op 78 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 157891 7501 ns/op 3521 B/op 78 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160102 7546 ns/op 3521 B/op 78 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 159277 7470 ns/op 3521 B/op 78 allocs/op +BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160509 7644 ns/op 3521 B/op 78 allocs/op +PASS +ok github.com/thanos-io/thanos/pkg/store 49.631s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache 0.389s +PASS +ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.098s +? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] +PASS +ok github.com/thanos-io/thanos/pkg/store/labelpb 0.129s +PASS +ok github.com/thanos-io/thanos/pkg/store/storepb 0.262s +? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] +? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files] diff --git a/pkg/store/proxy_heap.go b/pkg/store/proxy_heap.go index d1f9acbd31..d5cc940637 100644 --- a/pkg/store/proxy_heap.go +++ b/pkg/store/proxy_heap.go @@ -810,7 +810,7 @@ func dropLabels(l labels.Labels, labelsToDrop map[string]struct{}) (labels.Label } func copyLabels(dest *labels.Labels, src labels.Labels) { - if len(*dest) < len(src) { + if len(*dest) < cap(src) { *dest = make([]labels.Label, len(src)) } *dest = (*dest)[:len(src)] From b8977d07314451865caf1e8f56f3d66486ab2ee8 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Thu, 27 Apr 2023 15:48:04 +0200 Subject: [PATCH 7/7] Use len instead of cap Signed-off-by: Filip Petkovski --- branch-optimized.out | 58 -------------------------------------------- branch.out | 58 -------------------------------------------- main.out | 58 -------------------------------------------- 3 files changed, 174 deletions(-) delete mode 100644 branch-optimized.out delete mode 100644 branch.out delete mode 100644 main.out diff --git a/branch-optimized.out b/branch-optimized.out deleted file mode 100644 index 8a26380d83..0000000000 --- a/branch-optimized.out +++ /dev/null @@ -1,58 +0,0 @@ -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/0 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/1 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/2 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1790133929/001/3 -goos: darwin -goarch: arm64 -pkg: github.com/thanos-io/thanos/pkg/store -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 158857548 ns/op 83947138 B/op 308 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 157167155 ns/op 83947059 B/op 309 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 8 161957891 ns/op 83946597 B/op 308 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 160205798 ns/op 83946730 B/op 307 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 7 156346476 ns/op 83946545 B/op 308 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167804982 ns/op 83360371 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167674000 ns/op 83360365 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167907363 ns/op 83360299 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 168278554 ns/op 83360379 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 167559071 ns/op 83360332 B/op 154 allocs/op -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/0 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/1 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/2 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples2607283477/001/3 -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 80 16228542 ns/op 7638188 B/op 258 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 78 16416622 ns/op 7637896 B/op 257 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 79 16370143 ns/op 7637986 B/op 257 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 78 16848665 ns/op 7637845 B/op 257 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 75 16613844 ns/op 7637795 B/op 257 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17727925 ns/op 8206839 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17947329 ns/op 8206830 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17870753 ns/op 8206846 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17968765 ns/op 8206848 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 69 17951987 ns/op 8206832 B/op 134 allocs/op -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/0 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/1 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/2 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples135888685/001/3 -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71779 16359 ns/op 8227 B/op 136 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73178 16381 ns/op 8227 B/op 136 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 72333 16388 ns/op 8228 B/op 136 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71834 16622 ns/op 8228 B/op 136 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73404 16463 ns/op 8228 B/op 136 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160734 7705 ns/op 3769 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 156384 7739 ns/op 3769 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 154957 7701 ns/op 3769 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 154280 7678 ns/op 3769 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 152821 7868 ns/op 3769 B/op 80 allocs/op -PASS -ok github.com/thanos-io/thanos/pkg/store 49.669s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache 0.632s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.243s -? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] -PASS -ok github.com/thanos-io/thanos/pkg/store/labelpb 0.261s -PASS -ok github.com/thanos-io/thanos/pkg/store/storepb 0.381s -? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] -? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files] diff --git a/branch.out b/branch.out deleted file mode 100644 index c847552df0..0000000000 --- a/branch.out +++ /dev/null @@ -1,58 +0,0 @@ -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/0 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/1 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/2 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples3539447388/001/3 -goos: darwin -goarch: arm64 -pkg: github.com/thanos-io/thanos/pkg/store -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 232833200 ns/op 243947392 B/op 2500310 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 236852475 ns/op 243947772 B/op 2500310 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 4 275805448 ns/op 243947688 B/op 2500311 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 4 250956614 ns/op 243947820 B/op 2500311 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 5 252837850 ns/op 243947596 B/op 2500311 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 183623708 ns/op 83360374 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 182530188 ns/op 83360354 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 172891625 ns/op 83360276 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 177037911 ns/op 83360323 B/op 154 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 177693976 ns/op 83360276 B/op 154 allocs/op -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/0 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/1 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/2 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples245905835/001/3 -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 45 24994671 ns/op 23639309 B/op 250260 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 24830660 ns/op 23638706 B/op 250259 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 45 25789010 ns/op 23638447 B/op 250258 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 25813167 ns/op 23638650 B/op 250259 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 44 25142471 ns/op 23638748 B/op 250259 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17836342 ns/op 8206786 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17983012 ns/op 8206787 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 72 17472039 ns/op 8206777 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 69 17475200 ns/op 8206782 B/op 134 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 17084748 ns/op 8206760 B/op 134 allocs/op -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/0 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/1 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/2 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2156878349/001/3 -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 69438 16712 ns/op 8812 B/op 146 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 66511 17205 ns/op 8812 B/op 146 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 70868 16953 ns/op 8812 B/op 146 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 71019 16651 ns/op 8812 B/op 146 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 72241 16729 ns/op 8812 B/op 146 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160410 7857 ns/op 3713 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 150763 7762 ns/op 3713 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 159288 7832 ns/op 3713 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 158436 7915 ns/op 3713 B/op 80 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 148728 7721 ns/op 3713 B/op 80 allocs/op -PASS -ok github.com/thanos-io/thanos/pkg/store 53.263s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache 0.423s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.124s -? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] -PASS -ok github.com/thanos-io/thanos/pkg/store/labelpb 0.148s -PASS -ok github.com/thanos-io/thanos/pkg/store/storepb 0.288s -? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] -? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files] diff --git a/main.out b/main.out deleted file mode 100644 index e6fe7a0ec7..0000000000 --- a/main.out +++ /dev/null @@ -1,58 +0,0 @@ -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/0 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/1 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/2 -Creating 250000 1-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1000000SeriesWith1Samples1104028951/001/3 -goos: darwin -goarch: arm64 -pkg: github.com/thanos-io/thanos/pkg/store -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 122496806 ns/op 83946710 B/op 303 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 129038903 ns/op 83946470 B/op 303 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 125925921 ns/op 83946382 B/op 301 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 10 124710467 ns/op 83946406 B/op 302 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/4_client_with_1_samples,_250000_series_each-8 9 125908588 ns/op 83946278 B/op 302 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 7 178174250 ns/op 83360129 B/op 152 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 175442931 ns/op 83360182 B/op 152 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 177222250 ns/op 83360169 B/op 152 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 177196979 ns/op 83360238 B/op 152 allocs/op -BenchmarkProxySeries/1000000SeriesWith1Samples/single_client_with_1_samples,_1000000_series-8 6 176612146 ns/op 83360208 B/op 153 allocs/op -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/0 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/1 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/2 -Creating 25000 25-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries100000SeriesWith100Samples1526467394/001/3 -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 87 13842230 ns/op 7637714 B/op 251 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 87 13614246 ns/op 7637862 B/op 252 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 99 13466323 ns/op 7637441 B/op 251 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 100 13463995 ns/op 7637418 B/op 251 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/4_client_with_25_samples,_25000_series_each-8 96 12932889 ns/op 7637346 B/op 250 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16950276 ns/op 8206591 B/op 132 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16880842 ns/op 8206579 B/op 132 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 74 16871241 ns/op 8206614 B/op 132 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 74 16911964 ns/op 8206600 B/op 132 allocs/op -BenchmarkProxySeries/100000SeriesWith100Samples/single_client_with_100_samples,_100000_series-8 73 16867682 ns/op 8206585 B/op 132 allocs/op -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/0 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/1 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/2 -Creating 1 2500000-sample series with 1ms interval in /var/folders/0b/r42s6hv96hs2w84ycr2yf7qh0000gn/T/BenchmarkProxySeries1SeriesWith10000000Samples2475373482/001/3 -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 70292 16737 ns/op 7852 B/op 130 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 74174 16182 ns/op 7852 B/op 130 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 74235 16361 ns/op 7852 B/op 130 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 75582 16265 ns/op 7852 B/op 130 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/4_client_with_2500000_samples,_1_series_each-8 73658 16238 ns/op 7851 B/op 130 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 158442 7505 ns/op 3521 B/op 78 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 157891 7501 ns/op 3521 B/op 78 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160102 7546 ns/op 3521 B/op 78 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 159277 7470 ns/op 3521 B/op 78 allocs/op -BenchmarkProxySeries/1SeriesWith10000000Samples/single_client_with_10000000_samples,_1_series-8 160509 7644 ns/op 3521 B/op 78 allocs/op -PASS -ok github.com/thanos-io/thanos/pkg/store 49.631s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache 0.389s -PASS -ok github.com/thanos-io/thanos/pkg/store/cache/cachekey 0.098s -? github.com/thanos-io/thanos/pkg/store/hintspb [no test files] -PASS -ok github.com/thanos-io/thanos/pkg/store/labelpb 0.129s -PASS -ok github.com/thanos-io/thanos/pkg/store/storepb 0.262s -? github.com/thanos-io/thanos/pkg/store/storepb/prompb [no test files] -? github.com/thanos-io/thanos/pkg/store/storepb/testutil [no test files]