Skip to content

Avoid reallocating map in MatchLabels#10715

Merged
roidelapluie merged 1 commit intoprometheus:mainfrom
prymitive:labels_match
May 20, 2022
Merged

Avoid reallocating map in MatchLabels#10715
roidelapluie merged 1 commit intoprometheus:mainfrom
prymitive:labels_match

Conversation

@prymitive
Copy link
Copy Markdown
Contributor

We know the max size of our map so we can create it with that information and avoid extra allocations

Signed-off-by: Łukasz Mierzwa l.mierzwa@gmail.com

We know the max size of our map so we can create it with that information and avoid extra allocations

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
@netlify
Copy link
Copy Markdown

netlify bot commented May 19, 2022

👷 Deploy request for prometheus-react accepted.

Name Link
🔨 Latest commit 7febde5
🔍 Latest deploy log https://app.netlify.com/sites/prometheus-react/deploys/62863c3ea559110008c32301

@prymitive
Copy link
Copy Markdown
Contributor Author

prymitive commented May 19, 2022

I've benchmarked it with:

func BenchmarkLabels_MatchLabels(b *testing.B) {
        maxLabels := 30
        allLabels := make(Labels, maxLabels)
        allNames := [][]string{}
        for i := 0; i < maxLabels; i++ {
                allLabels[i] = Label{Name: strings.Repeat(string('a'+byte(i)), 5)}
                if i%5 == 0 || i == maxLabels-1 {
                        names := []string{}
                        for j := 0; j <= i; j++ {
                                names = append(names, allLabels[j].Name)
                        }
                        allNames = append(allNames, names)

                        names = names[:0]
                        for j := 0; j <= i; j++ {
                                names = append(names, allLabels[j].Name+"_miss")
                        }
                        allNames = append(allNames, names)
                }
        }
        for _, size := range []int{5, 10, maxLabels} {
                labels := allLabels[:size]
                for _, on := range []bool{true, false} {
                        for _, names := range allNames {
                                b.Run(fmt.Sprintf("with %d labels on=%v names=%d", size, on, len(names)), func(b *testing.B) {
                                        b.ReportAllocs()
                                        b.ResetTimer()
                                        for i := 0; i < b.N; i++ {
                                                labels.MatchLabels(on, names...)
                                        }
                                })
                        }
                }
        }
}

But wasn't sure if that's a useful benchmark so didn't add it. Diff is below.

benchstat diff
name                                                      old time/op    new time/op    delta
Labels_MatchLabels/with_5_labels_on=true_names=1-8          45.1ns ± 5%    49.2ns ± 4%   +9.12%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=1#01-8       48.3ns ± 7%    49.7ns ± 7%     ~     (p=0.310 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=6-8           137ns ± 3%     148ns ± 6%   +8.05%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=6#01-8        145ns ± 6%     149ns ± 5%     ~     (p=0.198 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=11-8          565ns ± 4%     467ns ± 5%  -17.36%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=11#01-8       585ns ± 6%     500ns ± 9%  -14.59%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=16-8         1.22µs ± 4%    0.66µs ± 4%  -45.99%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=16#01-8      1.20µs ± 8%    0.66µs ± 3%  -44.93%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21-8         1.34µs ± 2%    0.83µs ± 5%  -38.46%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21#01-8      1.33µs ± 7%    0.86µs ± 4%  -35.28%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26-8         1.53µs ± 0%    1.07µs ± 5%  -30.32%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26#01-8      1.54µs ± 3%    1.18µs ±12%  -23.25%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30-8         2.48µs ± 4%    1.22µs ± 9%  -50.94%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30#01-8      2.56µs ± 9%    1.42µs ±23%  -44.41%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=1-8          360ns ± 2%     443ns ±23%  +23.20%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=1#01-8       355ns ± 1%     472ns ±23%  +33.05%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=6-8          468ns ± 1%     570ns ± 9%  +21.92%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=6#01-8       491ns ± 8%     566ns ±18%     ~     (p=0.310 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=11-8        1.02µs ±11%    0.85µs ± 8%  -15.85%  (p=0.016 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=11#01-8      961ns ±12%    1117ns ±52%     ~     (p=0.690 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=16-8        1.76µs ±21%    1.25µs ±35%  -28.83%  (p=0.032 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=16#01-8     1.92µs ±18%    1.07µs ± 7%  -44.24%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21-8        1.89µs ±15%    1.15µs ± 4%  -38.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21#01-8     1.81µs ±16%    1.16µs ±11%  -35.89%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26-8        2.11µs ±28%    1.35µs ±10%  -35.85%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26#01-8     2.06µs ±12%    1.42µs ± 5%  -31.30%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=30-8        3.09µs ±15%    1.46µs ± 3%  -52.66%  (p=0.016 n=5+4)
Labels_MatchLabels/with_5_labels_on=false_names=30#01-8     3.41µs ±13%    1.53µs ± 2%  -55.07%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=1-8         71.6ns ± 2%    82.1ns ± 6%  +14.68%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=1#01-8      71.3ns ± 0%    81.2ns ± 2%  +13.95%  (p=0.016 n=4+5)
Labels_MatchLabels/with_10_labels_on=true_names=6-8          189ns ± 4%     213ns ± 5%  +12.81%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=6#01-8       190ns ± 2%     208ns ± 4%   +9.80%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=11-8         673ns ± 6%     531ns ± 7%  -21.09%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=11#01-8      695ns ±14%     532ns ± 4%  -23.42%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=16-8        1.26µs ± 5%    0.81µs ± 5%  -35.53%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=16#01-8     1.29µs ±17%    0.78µs ± 5%  -39.65%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21-8        1.45µs ± 8%    0.98µs ±13%  -32.33%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21#01-8     1.48µs ± 7%    1.00µs ± 9%  -32.01%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26-8        1.67µs ± 4%    1.19µs ±14%  -28.89%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26#01-8     1.82µs ±17%    1.13µs ± 8%  -37.87%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30-8        2.84µs ± 9%    1.33µs ±12%  -53.01%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30#01-8     2.57µs ± 9%    1.38µs ±22%  -46.36%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=1-8         629ns ±19%     676ns ± 0%     ~     (p=0.190 n=5+4)
Labels_MatchLabels/with_10_labels_on=false_names=1#01-8      584ns ±11%     609ns ±17%     ~     (p=0.690 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=6-8         825ns ±23%     893ns ±27%     ~     (p=0.690 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=6#01-8      745ns ±15%     900ns ±21%     ~     (p=0.095 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=11-8       1.24µs ±11%    1.26µs ±12%     ~     (p=0.810 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=11#01-8    1.50µs ±24%    1.40µs ±23%     ~     (p=0.421 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=16-8       1.85µs ±11%    1.38µs ±15%  -25.14%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=16#01-8    1.78µs ± 3%    1.72µs ± 9%     ~     (p=0.556 n=4+5)
Labels_MatchLabels/with_10_labels_on=false_names=21-8       2.17µs ±13%    1.82µs ±23%  -16.37%  (p=0.032 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=21#01-8    2.53µs ±22%    1.74µs ±23%  -31.22%  (p=0.016 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=26-8       2.77µs ±19%    2.14µs ±17%  -22.88%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=26#01-8    2.39µs ±11%    2.27µs ±15%     ~     (p=0.222 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30-8       3.58µs ± 7%    2.09µs ±11%  -41.78%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30#01-8    3.75µs ±12%    2.35µs ±11%  -37.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=1-8          190ns ± 1%     199ns ± 4%   +4.61%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=1#01-8       192ns ± 4%     197ns ± 4%     ~     (p=0.079 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=6-8          410ns ±10%     383ns ± 4%     ~     (p=0.151 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=6#01-8       396ns ± 6%     386ns ± 3%     ~     (p=0.310 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=11-8         940ns ± 7%     837ns ± 4%  -11.02%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=11#01-8      958ns ± 9%     829ns ±12%  -13.45%  (p=0.032 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=16-8        1.66µs ±15%    1.06µs ± 4%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=16#01-8     1.63µs ±10%    1.10µs ± 6%  -32.58%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21-8        1.80µs ± 9%    1.20µs ± 3%  -33.56%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21#01-8     1.81µs ±10%    1.25µs ±12%  -30.80%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=26-8        2.08µs ± 4%    1.46µs ± 3%  -29.69%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=26#01-8     2.11µs ± 7%    1.52µs ± 6%  -28.23%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30-8        2.91µs ± 8%    1.70µs ±16%  -41.56%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30#01-8     2.99µs ± 5%    1.58µs ±11%  -47.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=1-8        1.05µs ± 8%    0.94µs ± 3%  -10.23%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=1#01-8      968ns ± 8%     885ns ± 3%   -8.56%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=6-8        1.31µs ±17%    1.45µs ±13%     ~     (p=0.087 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=6#01-8     1.30µs ± 9%    1.47µs ± 6%  +13.45%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=11-8       1.88µs ± 5%    1.96µs ±13%     ~     (p=0.548 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=11#01-8    1.84µs ± 8%    2.01µs ±19%     ~     (p=0.222 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=16-8       2.38µs ± 4%    2.16µs ±19%     ~     (p=0.151 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=16#01-8    2.60µs ±14%    1.96µs ± 6%  -24.71%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21-8       2.66µs ±15%    2.27µs ±21%     ~     (p=0.056 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21#01-8    2.72µs ± 3%    2.64µs ±11%     ~     (p=0.222 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=26-8       2.92µs ± 4%    3.16µs ± 4%   +8.25%  (p=0.024 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=26#01-8    2.88µs ± 6%    3.06µs ±23%     ~     (p=0.548 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=30-8       3.92µs ±14%    3.25µs ±17%  -17.14%  (p=0.032 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=30#01-8    4.13µs ± 4%    2.95µs ±29%  -28.59%  (p=0.008 n=5+5)

name                                                      old alloc/op   new alloc/op   delta
Labels_MatchLabels/with_5_labels_on=true_names=1-8           0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=1#01-8        0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=6-8           0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=6#01-8        0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=11-8           297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=11#01-8        297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=16-8           906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=16#01-8        906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21-8           934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21#01-8        934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26-8         1.01kB ± 0%    0.68kB ± 0%  -32.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26#01-8      1.01kB ± 0%    0.68kB ± 0%  -32.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30-8         2.17kB ± 0%    1.16kB ± 0%  -46.40%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30#01-8      2.17kB ± 0%    1.16kB ± 0%  -46.40%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=1-8           480B ± 0%      480B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=1#01-8        480B ± 0%      480B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=6-8           480B ± 0%      480B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=6#01-8        480B ± 0%      480B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=11-8          777B ± 0%      777B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=11#01-8       777B ± 0%      777B ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=16-8        1.39kB ± 0%    1.06kB ± 0%  -23.52%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=16#01-8     1.39kB ± 0%    1.06kB ± 0%  -23.52%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21-8        1.41kB ± 0%    1.09kB ± 0%  -23.06%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21#01-8     1.41kB ± 0%    1.09kB ± 0%  -23.06%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26-8        1.49kB ± 0%    1.16kB ± 0%  -21.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26#01-8     1.49kB ± 0%    1.16kB ± 0%  -21.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=30-8        2.65kB ± 0%    1.64kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_5_labels_on=false_names=30#01-8     2.65kB ± 0%    1.64kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_10_labels_on=true_names=1-8          0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=1#01-8       0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=6-8          0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=6#01-8       0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=11-8          297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=11#01-8       297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=16-8          906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=16#01-8       906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21-8          934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21#01-8       934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26-8        1.01kB ± 0%    0.68kB ± 0%  -32.45%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26#01-8     1.01kB ± 0%    0.68kB ± 0%  -32.45%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30-8        2.17kB ± 0%    1.16kB ± 0%  -46.40%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30#01-8     2.17kB ± 0%    1.16kB ± 0%  -46.41%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=1-8          992B ± 0%      992B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=1#01-8       992B ± 0%      992B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=6-8          992B ± 0%      992B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=6#01-8       992B ± 0%      992B ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=11-8       1.29kB ± 0%    1.29kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=11#01-8    1.29kB ± 0%    1.29kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=16-8       1.90kB ± 0%    1.57kB ± 0%  -17.18%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=16#01-8    1.90kB ± 0%    1.57kB ± 0%  -17.18%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=21-8       1.93kB ± 0%    1.60kB ± 0%  -16.93%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=21#01-8    1.93kB ± 0%    1.60kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_10_labels_on=false_names=26-8       2.00kB ± 0%    1.67kB ± 0%  -16.34%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=26#01-8    2.00kB ± 0%    1.67kB ± 0%  -16.34%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30-8       3.16kB ± 0%    2.15kB ± 0%  -31.84%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30#01-8    3.16kB ± 0%    2.15kB ± 0%  -31.84%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=1-8          0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=1#01-8       0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=6-8          0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=6#01-8       0.00B          0.00B          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=11-8          297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=11#01-8       297B ± 0%      297B ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=16-8          906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=16#01-8       906B ± 0%      580B ± 0%  -35.98%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21-8          934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21#01-8       934B ± 0%      608B ± 0%  -34.90%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=26-8        1.01kB ± 0%    0.68kB ± 0%  -32.50%  (p=0.000 n=5+4)
Labels_MatchLabels/with_30_labels_on=true_names=26#01-8     1.01kB ± 0%    0.68kB ± 0%  -32.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30-8        2.17kB ± 0%    1.16kB ± 0%  -46.41%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30#01-8     2.17kB ± 0%    1.16kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_30_labels_on=false_names=1-8        2.02kB ± 0%    2.02kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=1#01-8     2.02kB ± 0%    2.02kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=6-8        2.02kB ± 0%    2.02kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=6#01-8     2.02kB ± 0%    2.02kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=11-8       2.31kB ± 0%    2.31kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=11#01-8    2.31kB ± 0%    2.31kB ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=16-8       2.92kB ± 0%    2.60kB ± 0%  -11.16%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=16#01-8    2.92kB ± 0%    2.60kB ± 0%  -11.16%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21-8       2.95kB ± 0%    2.62kB ± 0%  -11.05%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21#01-8    2.95kB ± 0%    2.62kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_30_labels_on=false_names=26-8       3.02kB ± 0%    2.69kB ± 0%  -10.82%  (p=0.000 n=5+4)
Labels_MatchLabels/with_30_labels_on=false_names=26#01-8    3.02kB ± 0%    2.70kB ± 0%  -10.80%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=30-8       4.18kB ± 0%    3.18kB ± 0%     ~     (p=0.079 n=4+5)
Labels_MatchLabels/with_30_labels_on=false_names=30#01-8    4.18kB ± 0%    3.18kB ± 0%     ~     (p=0.079 n=4+5)

name                                                      old allocs/op  new allocs/op  delta
Labels_MatchLabels/with_5_labels_on=true_names=1-8            0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=1#01-8         0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=6-8            0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=6#01-8         0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=11-8           1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=11#01-8        1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=true_names=16-8           2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=16#01-8        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21-8           2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=21#01-8        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26-8           2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=26#01-8        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30-8           4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=true_names=30#01-8        4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=1-8           4.00 ± 0%      4.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=1#01-8        4.00 ± 0%      4.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=6-8           4.00 ± 0%      4.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=6#01-8        4.00 ± 0%      4.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=11-8          5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=11#01-8       5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_5_labels_on=false_names=16-8          6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=16#01-8       6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21-8          6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=21#01-8       6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26-8          6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=26#01-8       6.00 ± 0%      5.00 ± 0%  -16.67%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=30-8          8.00 ± 0%      5.00 ± 0%  -37.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_5_labels_on=false_names=30#01-8       8.00 ± 0%      5.00 ± 0%  -37.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=1-8           0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=1#01-8        0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=6-8           0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=6#01-8        0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=11-8          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=11#01-8       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=true_names=16-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=16#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=21#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=26#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30-8          4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=true_names=30#01-8       4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=1-8          5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=1#01-8       5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=6-8          5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=6#01-8       5.00 ± 0%      5.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=11-8         6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=11#01-8      6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_10_labels_on=false_names=16-8         7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=16#01-8      7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=21-8         7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=21#01-8      7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=26-8         7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=26#01-8      7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30-8         9.00 ± 0%      6.00 ± 0%  -33.33%  (p=0.008 n=5+5)
Labels_MatchLabels/with_10_labels_on=false_names=30#01-8      9.00 ± 0%      6.00 ± 0%  -33.33%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=1-8           0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=1#01-8        0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=6-8           0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=6#01-8        0.00           0.00          ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=11-8          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=11#01-8       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=true_names=16-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=16#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=21#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=26-8          2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=26#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30-8          4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=true_names=30#01-8       4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=1-8          6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=1#01-8       6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=6-8          6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=6#01-8       6.00 ± 0%      6.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=11-8         7.00 ± 0%      7.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=11#01-8      7.00 ± 0%      7.00 ± 0%     ~     (all equal)
Labels_MatchLabels/with_30_labels_on=false_names=16-8         8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=16#01-8      8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21-8         8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=21#01-8      8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=26-8         8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=26#01-8      8.00 ± 0%      7.00 ± 0%  -12.50%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=30-8         10.0 ± 0%       7.0 ± 0%  -30.00%  (p=0.008 n=5+5)
Labels_MatchLabels/with_30_labels_on=false_names=30#01-8      10.0 ± 0%       7.0 ± 0%  -30.00%  (p=0.008 n=5+5)

@roidelapluie
Copy link
Copy Markdown
Member

I don't expect this to make a visible difference, but it's good to have it.

@roidelapluie roidelapluie merged commit 89de30a into prometheus:main May 20, 2022
@prymitive prymitive deleted the labels_match branch May 20, 2022 08:23
roidelapluie pushed a commit to roidelapluie/prometheus that referenced this pull request Jun 22, 2022
We know the max size of our map so we can create it with that information and avoid extra allocations

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants