From 9aa6e041d3b6cc9b7041c93d1bf34b3b11d2294e Mon Sep 17 00:00:00 2001 From: Oleg Zaytsev Date: Tue, 26 Nov 2024 16:03:45 +0100 Subject: [PATCH] MemPostings: allocate ListPostings once in PFALV (#15465) Same as #15427 but for the new method added in #14144 Instead of allocating each ListPostings one by one, allocate them all in one go. Signed-off-by: Oleg Zaytsev --- tsdb/index/postings.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tsdb/index/postings.go b/tsdb/index/postings.go index f211bade5..a0e7d035a 100644 --- a/tsdb/index/postings.go +++ b/tsdb/index/postings.go @@ -454,10 +454,14 @@ func (p *MemPostings) PostingsForAllLabelValues(ctx context.Context, name string e := p.m[name] its := make([]Postings, 0, len(e)) + lps := make([]ListPostings, len(e)) + i := 0 for _, refs := range e { if len(refs) > 0 { - its = append(its, NewListPostings(refs)) + lps[i] = ListPostings{list: refs} + its = append(its, &lps[i]) } + i++ } // Let the mutex go before merging.