Skip to content

Commit

Permalink
Upgrade to latest mimir-prometheus (#6312)
Browse files Browse the repository at this point in the history
* Upgrade to latest mimir-prometheus

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 committed Oct 10, 2023
1 parent b9acfc8 commit 8a39aa1
Show file tree
Hide file tree
Showing 74 changed files with 2,538 additions and 584 deletions.
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ require (
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/trace v1.19.0
go.uber.org/multierr v1.11.0
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
google.golang.org/api v0.146.0
google.golang.org/protobuf v1.31.0
sigs.k8s.io/kustomize/kyaml v0.14.3
Expand All @@ -91,6 +91,8 @@ require (
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/go-test/deep v1.1.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
Expand Down Expand Up @@ -159,16 +161,14 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/glog v1.1.1 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gosimple/slug v1.1.1 // indirect
github.com/grafana/gomemcache v0.0.0-20230914135007-70d78eaabfe1 // indirect
github.com/hashicorp/consul/api v1.22.0 // indirect
github.com/hashicorp/consul/api v1.25.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
Expand Down Expand Up @@ -233,11 +233,11 @@ require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
Expand All @@ -251,7 +251,7 @@ require (
)

// Using a fork of Prometheus with Mimir-specific changes.
replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20231002103016-8c43257d393c
replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20231010120800-56e19def277f

// Replace memberlist with our fork which includes some fixes that haven't been
// merged upstream yet:
Expand All @@ -269,7 +269,7 @@ replace gopkg.in/yaml.v3 => github.com/colega/go-yaml-yaml v0.0.0-20220720105220
replace github.com/grafana/regexp => github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6

// Replace goautoneg with a fork until https://github.com/munnerz/goautoneg/pull/5 is merged
replace github.com/munnerz/goautoneg => github.com/charleskorn/goautoneg v0.0.0-20230303030534-7248a2f4c9cc
replace github.com/munnerz/goautoneg => github.com/grafana/goautoneg v0.0.0-20231010094147-47ce5e72a9ae

// Replace opentracing-contrib/go-stdlib with a fork until https://github.com/opentracing-contrib/go-stdlib/pull/68 is merged.
replace github.com/opentracing-contrib/go-stdlib => github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charleskorn/goautoneg v0.0.0-20230303030534-7248a2f4c9cc h1:r9yn26N6K60wfQPMwxNeD8U2djqObFYh6o9LXfeMecg=
github.com/charleskorn/goautoneg v0.0.0-20230303030534-7248a2f4c9cc/go.mod h1:S666TGglI7cVCVpErP7i+7iFlS330LD8vZDcFk9IdCg=
github.com/chromedp/cdproto v0.0.0-20210526005521-9e51b9051fd0/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/cdproto v0.0.0-20210706234513-2bc298e8be7f/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/cdproto v0.0.0-20220629234738-4cfc9cdeeb92 h1:0kiAQSLWZDt4wsmcICou3C6in/OJ58FCqvXcB8Ax1Dk=
Expand Down Expand Up @@ -555,12 +553,14 @@ github.com/grafana/dskit v0.0.0-20231010092604-9b82fbd87ce1 h1:u46tR3g8obq3eXKj6
github.com/grafana/dskit v0.0.0-20231010092604-9b82fbd87ce1/go.mod h1:byPCvaG/pqi33Kq+Wvkp7WhLfmrlyy0RAoYG4yRh01I=
github.com/grafana/e2e v0.1.1 h1:/b6xcv5BtoBnx8cZnCiey9DbjEc8z7gXHO5edoeRYxc=
github.com/grafana/e2e v0.1.1/go.mod h1:RpNLgae5VT+BUHvPE+/zSypmOXKwEu4t+tnEMS1ATaE=
github.com/grafana/goautoneg v0.0.0-20231010094147-47ce5e72a9ae h1:Yxbw9jKGJVC6qAK5Ubzzb/qZwM6rRMMqaDc/d4Vp3pM=
github.com/grafana/goautoneg v0.0.0-20231010094147-47ce5e72a9ae/go.mod h1:GFAN9Jn9t1cX7sNfc6ZoFyc4f7i8jtm3SajrWdZM2EE=
github.com/grafana/gomemcache v0.0.0-20230914135007-70d78eaabfe1 h1:MLYY2R60/74hfYl5vRRmC2VDo0Yuql1QQ1ig8hnvgSI=
github.com/grafana/gomemcache v0.0.0-20230914135007-70d78eaabfe1/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn7VNWBIvM71O2QsgfgW9fRXZNR0DXe6pDU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/grafana/mimir-prometheus v0.0.0-20231002103016-8c43257d393c h1:noZPQueVNPPYzugAD8aNLnB5W8UV6NBqGGqygPYQ8QE=
github.com/grafana/mimir-prometheus v0.0.0-20231002103016-8c43257d393c/go.mod h1:FS+VpDcgSX2unPDcuzLAH4+qdraB8f/Kwy73bYwxFJo=
github.com/grafana/mimir-prometheus v0.0.0-20231010120800-56e19def277f h1:EvG/qXqCjGjqsDe97/+drFqALrYpHZigEkS0PP0JmjA=
github.com/grafana/mimir-prometheus v0.0.0-20231010120800-56e19def277f/go.mod h1:GikKWT3QqA+R3uYRd/RILJNNFxu0HejZYRLtXEF27tQ=
github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956 h1:em1oddjXL8c1tL0iFdtVtPloq2hRPen2MJQKoAWpxu0=
github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU=
github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6 h1:A3dhViTeFDSQcGOXuUi6ukCQSMyDtDISBp2z6OOo2YM=
Expand All @@ -569,11 +569,11 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
github.com/hashicorp/consul/api v1.22.0 h1:ydEvDooB/A0c/xpsBd8GSt7P2/zYPBui4KrNip0xGjE=
github.com/hashicorp/consul/api v1.22.0/go.mod h1:zHpYgZ7TeYqS6zaszjwSt128OwESRpnhU9aGa6ue3Eg=
github.com/hashicorp/consul/api v1.25.1 h1:CqrdhYzc8XZuPnhIYZWH45toM0LB9ZeYr/gvpLVI3PE=
github.com/hashicorp/consul/api v1.25.1/go.mod h1:iiLVwR/htV7mas/sy0O+XSuEnrdBUUydemjxcUrAt4g=
github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
github.com/hashicorp/consul/sdk v0.14.0 h1:Hly+BMNMssVzoWddbBnBFi3W+Fzytvm0haSkihhj3GU=
github.com/hashicorp/consul/sdk v0.14.0/go.mod h1:gHYeuDa0+0qRAD6Wwr6yznMBvBwHKoxSBoW5l73+saE=
github.com/hashicorp/consul/sdk v0.14.1 h1:ZiwE2bKb+zro68sWzZ1SgHF3kRMBZ94TwOCFRF4ylPs=
github.com/hashicorp/consul/sdk v0.14.1/go.mod h1:vFt03juSzocLRFo59NkeQHHmQa6+g7oU0pfzdI1mUhg=
github.com/hashicorp/cronexpr v1.1.2 h1:wG/ZYIKT+RT3QkOdgYc+xsKWVRgnxJ1OJtjjy84fJ9A=
github.com/hashicorp/cronexpr v1.1.2/go.mod h1:P4wA0KBl9C5q2hABiMO7cp6jcIg96CDh1Efb3g1PWA4=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -1064,8 +1064,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand Down Expand Up @@ -1093,8 +1093,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1375,8 +1375,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
23 changes: 16 additions & 7 deletions pkg/cardinality/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,23 @@ func extractSelector(values url.Values) (matchers []*labels.Matcher, err error)
}

// Ensure stable sorting (improves query results cache hit ratio).
slices.SortFunc(matchers, func(a, b *labels.Matcher) bool {
if a.Name != b.Name {
return a.Name < b.Name
slices.SortFunc(matchers, func(a, b *labels.Matcher) int {
switch {
case a.Name < b.Name:
return -1
case a.Name > b.Name:
return 1
case a.Type < b.Type:
return -1
case a.Type > b.Type:
return 1
case a.Value < b.Value:
return -1
case a.Value > b.Value:
return 1
default:
return 0
}
if a.Type != b.Type {
return a.Type < b.Type
}
return a.Value < b.Value
})

return matchers, nil
Expand Down
15 changes: 12 additions & 3 deletions pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,16 @@ func mkLabels(n int, extra ...string) []mimirpb.LabelAdapter {
for i := 0; i < len(extra); i += 2 {
ret[i+n+1] = mimirpb.LabelAdapter{Name: extra[i], Value: extra[i+1]}
}
slices.SortFunc(ret, func(a, b mimirpb.LabelAdapter) bool { return a.Name < b.Name })
slices.SortFunc(ret, func(a, b mimirpb.LabelAdapter) int {
switch {
case a.Name < b.Name:
return -1
case a.Name > b.Name:
return 1
default:
return 0
}
})
return ret
}

Expand Down Expand Up @@ -3591,8 +3600,8 @@ func (i *mockIngester) QueryStream(_ context.Context, req *client.QueryRequest,
series = append(series, ts)
}

slices.SortFunc(series, func(a, b *mimirpb.PreallocTimeseries) bool {
return labels.Compare(mimirpb.FromLabelAdaptersToLabels(a.Labels), mimirpb.FromLabelAdaptersToLabels(b.Labels)) < 0
slices.SortFunc(series, func(a, b *mimirpb.PreallocTimeseries) int {
return labels.Compare(mimirpb.FromLabelAdaptersToLabels(a.Labels), mimirpb.FromLabelAdaptersToLabels(b.Labels))
})

for seriesIndex, ts := range series {
Expand Down
16 changes: 11 additions & 5 deletions pkg/frontend/querymiddleware/labels_query_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,28 @@ func parseRequestMatchersParam(values url.Values, paramName string) ([][]*labels

// Ensure stable sorting (improves query results cache hit ratio).
for _, set := range matcherSets {
slices.SortFunc(set, func(a, b *labels.Matcher) bool {
return compareLabelMatchers(a, b) < 0
slices.SortFunc(set, func(a, b *labels.Matcher) int {
return compareLabelMatchers(a, b)
})
}

slices.SortFunc(matcherSets, func(a, b []*labels.Matcher) bool {
slices.SortFunc(matcherSets, func(a, b []*labels.Matcher) int {
idx := 0

for ; idx < len(a) && idx < len(b); idx++ {
if c := compareLabelMatchers(a[idx], b[idx]); c != 0 {
return c < 0
return c
}
}

// All label matchers are equal so far. Check which one has fewer matchers.
return idx < len(b)
if idx < len(b) {
return -1
}
if idx < len(a) {
return 1
}
return 0
})

return matcherSets, nil
Expand Down
11 changes: 9 additions & 2 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -2772,8 +2772,15 @@ func filterUsersToCompactToReduceInMemorySeries(numMemorySeries, earlyCompaction

// Compact all TSDBs blocks required to get the number of in-memory series below the threshold and, in addition,
// all TSDBs where the estimated series reduction is greater than the minimum reduction percentage.
slices.SortFunc(estimations, func(a, b seriesReductionEstimation) bool {
return a.estimatedCount > b.estimatedCount
slices.SortFunc(estimations, func(a, b seriesReductionEstimation) int {
switch {
case b.estimatedCount < a.estimatedCount:
return -1
case b.estimatedCount > a.estimatedCount:
return 1
default:
return 0
}
})

for _, entry := range estimations {
Expand Down
14 changes: 10 additions & 4 deletions pkg/ingester/ingester_early_compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,14 @@ func TestIngester_compactBlocksToReduceInMemorySeries_Concurrency(t *testing.T)
res, err := client.StreamsToMatrix(model.Earliest, model.Latest, s.responses)
require.NoError(t, err)

slices.SortFunc(res, func(a, b *model.SampleStream) bool {
return a.Metric.Before(b.Metric)
slices.SortFunc(res, func(a, b *model.SampleStream) int {
if a.Metric.Before(b.Metric) {
return -1
}
if a.Metric.Equal(b.Metric) {
return 0
}
return 1
})

require.Len(t, res, numSeries)
Expand Down Expand Up @@ -675,8 +681,8 @@ func listBlocksInDir(t *testing.T, dir string) (ids []ulid.ULID) {
}

// Ensure the block IDs are sorted.
slices.SortFunc(ids, func(a, b ulid.ULID) bool {
return a.Compare(b) < 0
slices.SortFunc(ids, func(a, b ulid.ULID) int {
return a.Compare(b)
})

return ids
Expand Down
11 changes: 9 additions & 2 deletions pkg/mimirpb/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,15 @@ func (p *PreallocTimeseries) SortLabelsIfNeeded() {
return
}

slices.SortFunc(p.Labels, func(a, b LabelAdapter) bool {
return a.Name < b.Name
slices.SortFunc(p.Labels, func(a, b LabelAdapter) int {
switch {
case a.Name < b.Name:
return -1
case a.Name > b.Name:
return 1
default:
return 0
}
})
p.clearUnmarshalData()
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/mimirpb/timeseries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,16 @@ func BenchmarkPreallocTimeseries_SortLabelsIfNeeded(b *testing.B) {

b.Run("unordered", benchmarkSortLabelsIfNeeded(unorderedLabels))

slices.SortFunc(unorderedLabels, func(a, b LabelAdapter) bool { return a.Name < b.Name })
slices.SortFunc(unorderedLabels, func(a, b LabelAdapter) int {
switch {
case a.Name < b.Name:
return -1
case a.Name > b.Name:
return 1
default:
return 0
}
})
b.Run("ordered", benchmarkSortLabelsIfNeeded(unorderedLabels))
})
}
Expand Down
45 changes: 45 additions & 0 deletions vendor/github.com/hashicorp/consul/api/acl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a39aa1

Please sign in to comment.