diff --git a/go.mod b/go.mod index b678a7e7ba..0a4cd53fa2 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/armon/go-metrics v0.4.1 github.com/aws/aws-sdk-go v1.55.5 github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 - github.com/cespare/xxhash v1.1.0 github.com/cortexproject/promqlsmith v0.0.0-20241121054008-8b48fe2471ef github.com/dustin/go-humanize v1.0.1 github.com/efficientgo/core v1.0.0-rc.3 @@ -52,8 +51,8 @@ require ( github.com/spf13/afero v1.11.0 github.com/stretchr/testify v1.10.0 github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97 - github.com/thanos-io/promql-engine v0.0.0-20241203103240-2f49f80c7c68 - github.com/thanos-io/thanos v0.37.2-0.20241210234302-0ea6bac096ce + github.com/thanos-io/promql-engine v0.0.0-20241217103156-9dbff30059cf + github.com/thanos-io/thanos v0.37.3-0.20241224143735-2d041dc774da github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/weaveworks/common v0.0.0-20230728070032-dd9e68f319d5 go.etcd.io/etcd/api/v3 v3.5.17 diff --git a/go.sum b/go.sum index 866d42b1ad..bcbf2121ac 100644 --- a/go.sum +++ b/go.sum @@ -798,9 +798,6 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8 github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/OneOfOne/xxhash v1.2.6 h1:U68crOE3y3MPttCMQGywZOLrTeF5HHJ3/vDBCJn9/bA= -github.com/OneOfOne/xxhash v1.2.6/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= @@ -904,8 +901,6 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -1619,9 +1614,6 @@ github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v1.0.0 h1:feX5fGGXSl3dYd4aHZItw+FpHLvvoaqkawKjVNiFMNQ= github.com/sony/gobreaker v1.0.0/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= @@ -1663,10 +1655,10 @@ github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e h1:f1 github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e/go.mod h1:jXcofnrSln/cLI6/dhlBxPQZEEQHVPCcFaH75M+nSzM= github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97 h1:VjG0mwhN1DkncwDHFvrpd12/2TLfgYNRmEQA48ikp+0= github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97/go.mod h1:vyzFrBXgP+fGNG2FopEGWOO/zrIuoy7zt3LpLeezRsw= -github.com/thanos-io/promql-engine v0.0.0-20241203103240-2f49f80c7c68 h1:cChM/FbpXeYmrSmXO1/MmmSlONviLVxWAWCB0/g4JrY= -github.com/thanos-io/promql-engine v0.0.0-20241203103240-2f49f80c7c68/go.mod h1:wx0JlRZtsB2S10JYUgeg5GqLfMxw31SzArP+28yyE00= -github.com/thanos-io/thanos v0.37.2-0.20241210234302-0ea6bac096ce h1:77bIiukjCF+GRZFjwJOsLIwWri7BO8LTwhchkPI7l5U= -github.com/thanos-io/thanos v0.37.2-0.20241210234302-0ea6bac096ce/go.mod h1:5Ni7Uc1Bc8UCGOYmZ/2f/LVvDkZKNDdqDJZqjDFG+rI= +github.com/thanos-io/promql-engine v0.0.0-20241217103156-9dbff30059cf h1:JFh4PjC9yQidiFi4qMWbPddIgsLWPIsSEbXs75+tLxs= +github.com/thanos-io/promql-engine v0.0.0-20241217103156-9dbff30059cf/go.mod h1:wx0JlRZtsB2S10JYUgeg5GqLfMxw31SzArP+28yyE00= +github.com/thanos-io/thanos v0.37.3-0.20241224143735-2d041dc774da h1:xnaeDaL1kOUgqA7BL6bPO5v5K66imXUweVYk8HqDFsA= +github.com/thanos-io/thanos v0.37.3-0.20241224143735-2d041dc774da/go.mod h1:E+olRxu9jl7KknntphHYXhLieVaMXXl/Q/Ioh6tj+oE= github.com/tjhop/slog-gokit v0.1.2 h1:pmQI4SvU9h4gA0vIQsdhJQSqQg4mOmsPykG2/PM3j1I= github.com/tjhop/slog-gokit v0.1.2/go.mod h1:8fhlcp8C8ELbg3GCyKv06tgt4B5sDq2P1r2DQAu1HuM= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= diff --git a/pkg/chunk/cache/memcached_client_selector.go b/pkg/chunk/cache/memcached_client_selector.go index e3e1c960ca..38fff0b340 100644 --- a/pkg/chunk/cache/memcached_client_selector.go +++ b/pkg/chunk/cache/memcached_client_selector.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/bradfitz/gomemcache/memcache" - "github.com/cespare/xxhash" + "github.com/cespare/xxhash/v2" "github.com/facette/natsort" ) diff --git a/vendor/github.com/cespare/xxhash/LICENSE.txt b/vendor/github.com/cespare/xxhash/LICENSE.txt deleted file mode 100644 index 24b53065f4..0000000000 --- a/vendor/github.com/cespare/xxhash/LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2016 Caleb Spare - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/cespare/xxhash/README.md b/vendor/github.com/cespare/xxhash/README.md deleted file mode 100644 index 0982fd25e5..0000000000 --- a/vendor/github.com/cespare/xxhash/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# xxhash - -[![GoDoc](https://godoc.org/github.com/cespare/xxhash?status.svg)](https://godoc.org/github.com/cespare/xxhash) - -xxhash is a Go implementation of the 64-bit -[xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a -high-quality hashing algorithm that is much faster than anything in the Go -standard library. - -The API is very small, taking its cue from the other hashing packages in the -standard library: - - $ go doc github.com/cespare/xxhash ! - package xxhash // import "github.com/cespare/xxhash" - - Package xxhash implements the 64-bit variant of xxHash (XXH64) as described - at http://cyan4973.github.io/xxHash/. - - func New() hash.Hash64 - func Sum64(b []byte) uint64 - func Sum64String(s string) uint64 - -This implementation provides a fast pure-Go implementation and an even faster -assembly implementation for amd64. - -## Benchmarks - -Here are some quick benchmarks comparing the pure-Go and assembly -implementations of Sum64 against another popular Go XXH64 implementation, -[github.com/OneOfOne/xxhash](https://github.com/OneOfOne/xxhash): - -| input size | OneOfOne | cespare (purego) | cespare | -| --- | --- | --- | --- | -| 5 B | 416 MB/s | 720 MB/s | 872 MB/s | -| 100 B | 3980 MB/s | 5013 MB/s | 5252 MB/s | -| 4 KB | 12727 MB/s | 12999 MB/s | 13026 MB/s | -| 10 MB | 9879 MB/s | 10775 MB/s | 10913 MB/s | - -These numbers were generated with: - -``` -$ go test -benchtime 10s -bench '/OneOfOne,' -$ go test -tags purego -benchtime 10s -bench '/xxhash,' -$ go test -benchtime 10s -bench '/xxhash,' -``` - -## Projects using this package - -- [InfluxDB](https://github.com/influxdata/influxdb) -- [Prometheus](https://github.com/prometheus/prometheus) diff --git a/vendor/github.com/cespare/xxhash/rotate.go b/vendor/github.com/cespare/xxhash/rotate.go deleted file mode 100644 index f3eac5ebc0..0000000000 --- a/vendor/github.com/cespare/xxhash/rotate.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build !go1.9 - -package xxhash - -// TODO(caleb): After Go 1.10 comes out, remove this fallback code. - -func rol1(x uint64) uint64 { return (x << 1) | (x >> (64 - 1)) } -func rol7(x uint64) uint64 { return (x << 7) | (x >> (64 - 7)) } -func rol11(x uint64) uint64 { return (x << 11) | (x >> (64 - 11)) } -func rol12(x uint64) uint64 { return (x << 12) | (x >> (64 - 12)) } -func rol18(x uint64) uint64 { return (x << 18) | (x >> (64 - 18)) } -func rol23(x uint64) uint64 { return (x << 23) | (x >> (64 - 23)) } -func rol27(x uint64) uint64 { return (x << 27) | (x >> (64 - 27)) } -func rol31(x uint64) uint64 { return (x << 31) | (x >> (64 - 31)) } diff --git a/vendor/github.com/cespare/xxhash/rotate19.go b/vendor/github.com/cespare/xxhash/rotate19.go deleted file mode 100644 index b99612bab8..0000000000 --- a/vendor/github.com/cespare/xxhash/rotate19.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build go1.9 - -package xxhash - -import "math/bits" - -func rol1(x uint64) uint64 { return bits.RotateLeft64(x, 1) } -func rol7(x uint64) uint64 { return bits.RotateLeft64(x, 7) } -func rol11(x uint64) uint64 { return bits.RotateLeft64(x, 11) } -func rol12(x uint64) uint64 { return bits.RotateLeft64(x, 12) } -func rol18(x uint64) uint64 { return bits.RotateLeft64(x, 18) } -func rol23(x uint64) uint64 { return bits.RotateLeft64(x, 23) } -func rol27(x uint64) uint64 { return bits.RotateLeft64(x, 27) } -func rol31(x uint64) uint64 { return bits.RotateLeft64(x, 31) } diff --git a/vendor/github.com/cespare/xxhash/xxhash.go b/vendor/github.com/cespare/xxhash/xxhash.go deleted file mode 100644 index f896bd28f0..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash.go +++ /dev/null @@ -1,168 +0,0 @@ -// Package xxhash implements the 64-bit variant of xxHash (XXH64) as described -// at http://cyan4973.github.io/xxHash/. -package xxhash - -import ( - "encoding/binary" - "hash" -) - -const ( - prime1 uint64 = 11400714785074694791 - prime2 uint64 = 14029467366897019727 - prime3 uint64 = 1609587929392839161 - prime4 uint64 = 9650029242287828579 - prime5 uint64 = 2870177450012600261 -) - -// NOTE(caleb): I'm using both consts and vars of the primes. Using consts where -// possible in the Go code is worth a small (but measurable) performance boost -// by avoiding some MOVQs. Vars are needed for the asm and also are useful for -// convenience in the Go code in a few places where we need to intentionally -// avoid constant arithmetic (e.g., v1 := prime1 + prime2 fails because the -// result overflows a uint64). -var ( - prime1v = prime1 - prime2v = prime2 - prime3v = prime3 - prime4v = prime4 - prime5v = prime5 -) - -type xxh struct { - v1 uint64 - v2 uint64 - v3 uint64 - v4 uint64 - total int - mem [32]byte - n int // how much of mem is used -} - -// New creates a new hash.Hash64 that implements the 64-bit xxHash algorithm. -func New() hash.Hash64 { - var x xxh - x.Reset() - return &x -} - -func (x *xxh) Reset() { - x.n = 0 - x.total = 0 - x.v1 = prime1v + prime2 - x.v2 = prime2 - x.v3 = 0 - x.v4 = -prime1v -} - -func (x *xxh) Size() int { return 8 } -func (x *xxh) BlockSize() int { return 32 } - -// Write adds more data to x. It always returns len(b), nil. -func (x *xxh) Write(b []byte) (n int, err error) { - n = len(b) - x.total += len(b) - - if x.n+len(b) < 32 { - // This new data doesn't even fill the current block. - copy(x.mem[x.n:], b) - x.n += len(b) - return - } - - if x.n > 0 { - // Finish off the partial block. - copy(x.mem[x.n:], b) - x.v1 = round(x.v1, u64(x.mem[0:8])) - x.v2 = round(x.v2, u64(x.mem[8:16])) - x.v3 = round(x.v3, u64(x.mem[16:24])) - x.v4 = round(x.v4, u64(x.mem[24:32])) - b = b[32-x.n:] - x.n = 0 - } - - if len(b) >= 32 { - // One or more full blocks left. - b = writeBlocks(x, b) - } - - // Store any remaining partial block. - copy(x.mem[:], b) - x.n = len(b) - - return -} - -func (x *xxh) Sum(b []byte) []byte { - s := x.Sum64() - return append( - b, - byte(s>>56), - byte(s>>48), - byte(s>>40), - byte(s>>32), - byte(s>>24), - byte(s>>16), - byte(s>>8), - byte(s), - ) -} - -func (x *xxh) Sum64() uint64 { - var h uint64 - - if x.total >= 32 { - v1, v2, v3, v4 := x.v1, x.v2, x.v3, x.v4 - h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) - h = mergeRound(h, v1) - h = mergeRound(h, v2) - h = mergeRound(h, v3) - h = mergeRound(h, v4) - } else { - h = x.v3 + prime5 - } - - h += uint64(x.total) - - i, end := 0, x.n - for ; i+8 <= end; i += 8 { - k1 := round(0, u64(x.mem[i:i+8])) - h ^= k1 - h = rol27(h)*prime1 + prime4 - } - if i+4 <= end { - h ^= uint64(u32(x.mem[i:i+4])) * prime1 - h = rol23(h)*prime2 + prime3 - i += 4 - } - for i < end { - h ^= uint64(x.mem[i]) * prime5 - h = rol11(h) * prime1 - i++ - } - - h ^= h >> 33 - h *= prime2 - h ^= h >> 29 - h *= prime3 - h ^= h >> 32 - - return h -} - -func u64(b []byte) uint64 { return binary.LittleEndian.Uint64(b) } -func u32(b []byte) uint32 { return binary.LittleEndian.Uint32(b) } - -func round(acc, input uint64) uint64 { - acc += input * prime2 - acc = rol31(acc) - acc *= prime1 - return acc -} - -func mergeRound(acc, val uint64) uint64 { - val = round(0, val) - acc ^= val - acc = acc*prime1 + prime4 - return acc -} diff --git a/vendor/github.com/cespare/xxhash/xxhash_amd64.go b/vendor/github.com/cespare/xxhash/xxhash_amd64.go deleted file mode 100644 index d617652680..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash_amd64.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build !appengine -// +build gc -// +build !purego - -package xxhash - -// Sum64 computes the 64-bit xxHash digest of b. -// -//go:noescape -func Sum64(b []byte) uint64 - -func writeBlocks(x *xxh, b []byte) []byte diff --git a/vendor/github.com/cespare/xxhash/xxhash_amd64.s b/vendor/github.com/cespare/xxhash/xxhash_amd64.s deleted file mode 100644 index 757f2011f0..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash_amd64.s +++ /dev/null @@ -1,233 +0,0 @@ -// +build !appengine -// +build gc -// +build !purego - -#include "textflag.h" - -// Register allocation: -// AX h -// CX pointer to advance through b -// DX n -// BX loop end -// R8 v1, k1 -// R9 v2 -// R10 v3 -// R11 v4 -// R12 tmp -// R13 prime1v -// R14 prime2v -// R15 prime4v - -// round reads from and advances the buffer pointer in CX. -// It assumes that R13 has prime1v and R14 has prime2v. -#define round(r) \ - MOVQ (CX), R12 \ - ADDQ $8, CX \ - IMULQ R14, R12 \ - ADDQ R12, r \ - ROLQ $31, r \ - IMULQ R13, r - -// mergeRound applies a merge round on the two registers acc and val. -// It assumes that R13 has prime1v, R14 has prime2v, and R15 has prime4v. -#define mergeRound(acc, val) \ - IMULQ R14, val \ - ROLQ $31, val \ - IMULQ R13, val \ - XORQ val, acc \ - IMULQ R13, acc \ - ADDQ R15, acc - -// func Sum64(b []byte) uint64 -TEXT ·Sum64(SB), NOSPLIT, $0-32 - // Load fixed primes. - MOVQ ·prime1v(SB), R13 - MOVQ ·prime2v(SB), R14 - MOVQ ·prime4v(SB), R15 - - // Load slice. - MOVQ b_base+0(FP), CX - MOVQ b_len+8(FP), DX - LEAQ (CX)(DX*1), BX - - // The first loop limit will be len(b)-32. - SUBQ $32, BX - - // Check whether we have at least one block. - CMPQ DX, $32 - JLT noBlocks - - // Set up initial state (v1, v2, v3, v4). - MOVQ R13, R8 - ADDQ R14, R8 - MOVQ R14, R9 - XORQ R10, R10 - XORQ R11, R11 - SUBQ R13, R11 - - // Loop until CX > BX. -blockLoop: - round(R8) - round(R9) - round(R10) - round(R11) - - CMPQ CX, BX - JLE blockLoop - - MOVQ R8, AX - ROLQ $1, AX - MOVQ R9, R12 - ROLQ $7, R12 - ADDQ R12, AX - MOVQ R10, R12 - ROLQ $12, R12 - ADDQ R12, AX - MOVQ R11, R12 - ROLQ $18, R12 - ADDQ R12, AX - - mergeRound(AX, R8) - mergeRound(AX, R9) - mergeRound(AX, R10) - mergeRound(AX, R11) - - JMP afterBlocks - -noBlocks: - MOVQ ·prime5v(SB), AX - -afterBlocks: - ADDQ DX, AX - - // Right now BX has len(b)-32, and we want to loop until CX > len(b)-8. - ADDQ $24, BX - - CMPQ CX, BX - JG fourByte - -wordLoop: - // Calculate k1. - MOVQ (CX), R8 - ADDQ $8, CX - IMULQ R14, R8 - ROLQ $31, R8 - IMULQ R13, R8 - - XORQ R8, AX - ROLQ $27, AX - IMULQ R13, AX - ADDQ R15, AX - - CMPQ CX, BX - JLE wordLoop - -fourByte: - ADDQ $4, BX - CMPQ CX, BX - JG singles - - MOVL (CX), R8 - ADDQ $4, CX - IMULQ R13, R8 - XORQ R8, AX - - ROLQ $23, AX - IMULQ R14, AX - ADDQ ·prime3v(SB), AX - -singles: - ADDQ $4, BX - CMPQ CX, BX - JGE finalize - -singlesLoop: - MOVBQZX (CX), R12 - ADDQ $1, CX - IMULQ ·prime5v(SB), R12 - XORQ R12, AX - - ROLQ $11, AX - IMULQ R13, AX - - CMPQ CX, BX - JL singlesLoop - -finalize: - MOVQ AX, R12 - SHRQ $33, R12 - XORQ R12, AX - IMULQ R14, AX - MOVQ AX, R12 - SHRQ $29, R12 - XORQ R12, AX - IMULQ ·prime3v(SB), AX - MOVQ AX, R12 - SHRQ $32, R12 - XORQ R12, AX - - MOVQ AX, ret+24(FP) - RET - -// writeBlocks uses the same registers as above except that it uses AX to store -// the x pointer. - -// func writeBlocks(x *xxh, b []byte) []byte -TEXT ·writeBlocks(SB), NOSPLIT, $0-56 - // Load fixed primes needed for round. - MOVQ ·prime1v(SB), R13 - MOVQ ·prime2v(SB), R14 - - // Load slice. - MOVQ b_base+8(FP), CX - MOVQ CX, ret_base+32(FP) // initialize return base pointer; see NOTE below - MOVQ b_len+16(FP), DX - LEAQ (CX)(DX*1), BX - SUBQ $32, BX - - // Load vN from x. - MOVQ x+0(FP), AX - MOVQ 0(AX), R8 // v1 - MOVQ 8(AX), R9 // v2 - MOVQ 16(AX), R10 // v3 - MOVQ 24(AX), R11 // v4 - - // We don't need to check the loop condition here; this function is - // always called with at least one block of data to process. -blockLoop: - round(R8) - round(R9) - round(R10) - round(R11) - - CMPQ CX, BX - JLE blockLoop - - // Copy vN back to x. - MOVQ R8, 0(AX) - MOVQ R9, 8(AX) - MOVQ R10, 16(AX) - MOVQ R11, 24(AX) - - // Construct return slice. - // NOTE: It's important that we don't construct a slice that has a base - // pointer off the end of the original slice, as in Go 1.7+ this will - // cause runtime crashes. (See discussion in, for example, - // https://github.com/golang/go/issues/16772.) - // Therefore, we calculate the length/cap first, and if they're zero, we - // keep the old base. This is what the compiler does as well if you - // write code like - // b = b[len(b):] - - // New length is 32 - (CX - BX) -> BX+32 - CX. - ADDQ $32, BX - SUBQ CX, BX - JZ afterSetBase - - MOVQ CX, ret_base+32(FP) - -afterSetBase: - MOVQ BX, ret_len+40(FP) - MOVQ BX, ret_cap+48(FP) // set cap == len - - RET diff --git a/vendor/github.com/cespare/xxhash/xxhash_other.go b/vendor/github.com/cespare/xxhash/xxhash_other.go deleted file mode 100644 index c68d13f89e..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash_other.go +++ /dev/null @@ -1,75 +0,0 @@ -// +build !amd64 appengine !gc purego - -package xxhash - -// Sum64 computes the 64-bit xxHash digest of b. -func Sum64(b []byte) uint64 { - // A simpler version would be - // x := New() - // x.Write(b) - // return x.Sum64() - // but this is faster, particularly for small inputs. - - n := len(b) - var h uint64 - - if n >= 32 { - v1 := prime1v + prime2 - v2 := prime2 - v3 := uint64(0) - v4 := -prime1v - for len(b) >= 32 { - v1 = round(v1, u64(b[0:8:len(b)])) - v2 = round(v2, u64(b[8:16:len(b)])) - v3 = round(v3, u64(b[16:24:len(b)])) - v4 = round(v4, u64(b[24:32:len(b)])) - b = b[32:len(b):len(b)] - } - h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) - h = mergeRound(h, v1) - h = mergeRound(h, v2) - h = mergeRound(h, v3) - h = mergeRound(h, v4) - } else { - h = prime5 - } - - h += uint64(n) - - i, end := 0, len(b) - for ; i+8 <= end; i += 8 { - k1 := round(0, u64(b[i:i+8:len(b)])) - h ^= k1 - h = rol27(h)*prime1 + prime4 - } - if i+4 <= end { - h ^= uint64(u32(b[i:i+4:len(b)])) * prime1 - h = rol23(h)*prime2 + prime3 - i += 4 - } - for ; i < end; i++ { - h ^= uint64(b[i]) * prime5 - h = rol11(h) * prime1 - } - - h ^= h >> 33 - h *= prime2 - h ^= h >> 29 - h *= prime3 - h ^= h >> 32 - - return h -} - -func writeBlocks(x *xxh, b []byte) []byte { - v1, v2, v3, v4 := x.v1, x.v2, x.v3, x.v4 - for len(b) >= 32 { - v1 = round(v1, u64(b[0:8:len(b)])) - v2 = round(v2, u64(b[8:16:len(b)])) - v3 = round(v3, u64(b[16:24:len(b)])) - v4 = round(v4, u64(b[24:32:len(b)])) - b = b[32:len(b):len(b)] - } - x.v1, x.v2, x.v3, x.v4 = v1, v2, v3, v4 - return b -} diff --git a/vendor/github.com/cespare/xxhash/xxhash_safe.go b/vendor/github.com/cespare/xxhash/xxhash_safe.go deleted file mode 100644 index dfa15ab7e2..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash_safe.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build appengine - -// This file contains the safe implementations of otherwise unsafe-using code. - -package xxhash - -// Sum64String computes the 64-bit xxHash digest of s. -func Sum64String(s string) uint64 { - return Sum64([]byte(s)) -} diff --git a/vendor/github.com/cespare/xxhash/xxhash_unsafe.go b/vendor/github.com/cespare/xxhash/xxhash_unsafe.go deleted file mode 100644 index d2b64e8bb0..0000000000 --- a/vendor/github.com/cespare/xxhash/xxhash_unsafe.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build !appengine - -// This file encapsulates usage of unsafe. -// xxhash_safe.go contains the safe implementations. - -package xxhash - -import ( - "reflect" - "unsafe" -) - -// Sum64String computes the 64-bit xxHash digest of s. -// It may be faster than Sum64([]byte(s)) by avoiding a copy. -// -// TODO(caleb): Consider removing this if an optimization is ever added to make -// it unnecessary: https://golang.org/issue/2205. -// -// TODO(caleb): We still have a function call; we could instead write Go/asm -// copies of Sum64 for strings to squeeze out a bit more speed. -func Sum64String(s string) uint64 { - // See https://groups.google.com/d/msg/golang-nuts/dcjzJy-bSpw/tcZYBzQqAQAJ - // for some discussion about this unsafe conversion. - var b []byte - bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data - bh.Len = len(s) - bh.Cap = len(s) - return Sum64(b) -} diff --git a/vendor/github.com/thanos-io/promql-engine/engine/distributed.go b/vendor/github.com/thanos-io/promql-engine/engine/distributed.go index fef4243892..a7c7378209 100644 --- a/vendor/github.com/thanos-io/promql-engine/engine/distributed.go +++ b/vendor/github.com/thanos-io/promql-engine/engine/distributed.go @@ -69,37 +69,45 @@ func NewDistributedEngine(opts Opts, endpoints api.RemoteEndpoints) *Distributed func (l DistributedEngine) SetQueryLogger(log promql.QueryLogger) {} func (l DistributedEngine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error) { + return l.MakeInstantQuery(ctx, q, fromPromQLOpts(opts), qs, ts) +} + +func (l DistributedEngine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error) { + return l.MakeRangeQuery(ctx, q, fromPromQLOpts(opts), qs, start, end, interval) +} + +func (l DistributedEngine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, plan logicalplan.Node, ts time.Time) (promql.Query, error) { // Truncate milliseconds to avoid mismatch in timestamps between remote and local engines. // Some clients might only support second precision when executing queries. ts = ts.Truncate(time.Second) - return l.remoteEngine.NewInstantQuery(ctx, q, opts, qs, ts) + return l.remoteEngine.MakeInstantQueryFromPlan(ctx, q, opts, plan, ts) } -func (l DistributedEngine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error) { +func (l DistributedEngine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, plan logicalplan.Node, start, end time.Time, interval time.Duration) (promql.Query, error) { // Truncate milliseconds to avoid mismatch in timestamps between remote and local engines. // Some clients might only support second precision when executing queries. start = start.Truncate(time.Second) end = end.Truncate(time.Second) interval = interval.Truncate(time.Second) - return l.remoteEngine.NewRangeQuery(ctx, q, opts, qs, start, end, interval) + return l.remoteEngine.MakeRangeQueryFromPlan(ctx, q, opts, plan, start, end, interval) } -func (l DistributedEngine) NewRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, plan logicalplan.Node, start, end time.Time, interval time.Duration) (promql.Query, error) { +func (l DistributedEngine) MakeInstantQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, ts time.Time) (promql.Query, error) { // Truncate milliseconds to avoid mismatch in timestamps between remote and local engines. // Some clients might only support second precision when executing queries. - start = start.Truncate(time.Second) - end = end.Truncate(time.Second) - interval = interval.Truncate(time.Second) + ts = ts.Truncate(time.Second) - return l.remoteEngine.NewRangeQueryFromPlan(ctx, q, opts, plan, start, end, interval) + return l.remoteEngine.MakeInstantQuery(ctx, q, opts, qs, ts) } -func (l DistributedEngine) NewInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, plan logicalplan.Node, ts time.Time) (promql.Query, error) { +func (l DistributedEngine) MakeRangeQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error) { // Truncate milliseconds to avoid mismatch in timestamps between remote and local engines. // Some clients might only support second precision when executing queries. - ts = ts.Truncate(time.Second) + start = start.Truncate(time.Second) + end = end.Truncate(time.Second) + interval = interval.Truncate(time.Second) - return l.remoteEngine.NewInstantQueryFromPlan(ctx, q, opts, plan, ts) + return l.remoteEngine.MakeRangeQuery(ctx, q, opts, qs, start, end, interval) } diff --git a/vendor/github.com/thanos-io/promql-engine/engine/engine.go b/vendor/github.com/thanos-io/promql-engine/engine/engine.go index 6a5648544c..152947e042 100644 --- a/vendor/github.com/thanos-io/promql-engine/engine/engine.go +++ b/vendor/github.com/thanos-io/promql-engine/engine/engine.go @@ -75,6 +75,9 @@ type Opts struct { // EnableAnalysis enables query analysis. EnableAnalysis bool + // EnablePartialResponses enables partial responses in distributed mode. + EnablePartialResponses bool + // SelectorBatchSize specifies the maximum number of samples to be returned by selectors in a single batch. SelectorBatchSize int64 @@ -96,6 +99,33 @@ func (o Opts) getLogicalOptimizers() []logicalplan.Optimizer { return optimizers } +// QueryOpts implements promql.QueryOpts but allows to override more engine default options. +type QueryOpts struct { + // These values are used to implement promql.QueryOpts, they have weird "Param" suffix because + // they are accessed by methods of the same name. + LookbackDeltaParam time.Duration + EnablePerStepStatsParam bool + + // DecodingConcurrency can be used to override the DecodingConcurrency engine setting. + DecodingConcurrency int + + // EnablePartialResponses can be used to override the EnablePartialResponses engine setting. + EnablePartialResponses bool +} + +func (opts QueryOpts) LookbackDelta() time.Duration { return opts.LookbackDeltaParam } +func (opts QueryOpts) EnablePerStepStats() bool { return opts.EnablePerStepStatsParam } + +func fromPromQLOpts(opts promql.QueryOpts) *QueryOpts { + if opts == nil { + return &QueryOpts{} + } + return &QueryOpts{ + LookbackDeltaParam: opts.LookbackDelta(), + EnablePerStepStatsParam: opts.EnablePerStepStats(), + } +} + // New creates a new query engine with the given options. The query engine will // use the storage passed in NewInstantQuery and NewRangeQuery for retrieving // data when executing queries. @@ -184,14 +214,15 @@ func NewWithScanners(opts Opts, scanners engstorage.Scanners) *Engine { disableDuplicateLabelChecks: opts.DisableDuplicateLabelChecks, disableFallback: opts.DisableFallback, - logger: opts.Logger, - lookbackDelta: opts.LookbackDelta, - enablePerStepStats: opts.EnablePerStepStats, - logicalOptimizers: opts.getLogicalOptimizers(), - timeout: opts.Timeout, - metrics: metrics, - extLookbackDelta: opts.ExtLookbackDelta, - enableAnalysis: opts.EnableAnalysis, + logger: opts.Logger, + lookbackDelta: opts.LookbackDelta, + enablePerStepStats: opts.EnablePerStepStats, + logicalOptimizers: opts.getLogicalOptimizers(), + timeout: opts.Timeout, + metrics: metrics, + extLookbackDelta: opts.ExtLookbackDelta, + enableAnalysis: opts.EnableAnalysis, + enablePartialResponses: opts.EnablePartialResponses, noStepSubqueryIntervalFn: func(d time.Duration) time.Duration { return time.Duration(opts.NoStepSubqueryIntervalFn(d.Milliseconds()) * 1000000) }, @@ -225,45 +256,21 @@ type Engine struct { extLookbackDelta time.Duration decodingConcurrency int enableAnalysis bool + enablePartialResponses bool noStepSubqueryIntervalFn func(time.Duration) time.Duration } -func (e *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error) { - idx, err := e.activeQueryTracker.Insert(ctx, qs) - if err != nil { - return nil, err - } - defer e.activeQueryTracker.Delete(idx) - +func (e *Engine) MakeInstantQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, ts time.Time) (promql.Query, error) { expr, err := parser.NewParser(qs, parser.WithFunctions(e.functions)).ParseExpr() if err != nil { return nil, err } - - if opts == nil { - opts = promql.NewPrometheusQueryOpts(false, e.lookbackDelta) - } - if opts.LookbackDelta() <= 0 { - opts = promql.NewPrometheusQueryOpts(opts.EnablePerStepStats(), e.lookbackDelta) - } - // determine sorting order before optimizers run, we do this by looking for "sort" // and "sort_desc" and optimize them away afterwards since they are only needed at // the presentation layer and not when computing the results. resultSort := newResultSort(expr) - qOpts := &query.Options{ - Start: ts, - End: ts, - Step: 0, - StepsBatch: stepsBatch, - LookbackDelta: opts.LookbackDelta(), - EnablePerStepStats: e.enablePerStepStats && opts.EnablePerStepStats(), - ExtLookbackDelta: e.extLookbackDelta, - EnableAnalysis: e.enableAnalysis, - NoStepSubqueryIntervalFn: e.noStepSubqueryIntervalFn, - DecodingConcurrency: e.decodingConcurrency, - } + qOpts := e.makeQueryOpts(ts, ts, 0, opts) if qOpts.StepsBatch > 64 { return nil, ErrStepsBatchTooLarge } @@ -301,20 +308,13 @@ func (e *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts }, nil } -func (e *Engine) NewInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, ts time.Time) (promql.Query, error) { +func (e *Engine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, root logicalplan.Node, ts time.Time) (promql.Query, error) { idx, err := e.activeQueryTracker.Insert(ctx, root.String()) if err != nil { return nil, err } defer e.activeQueryTracker.Delete(idx) - if opts == nil { - opts = promql.NewPrometheusQueryOpts(false, e.lookbackDelta) - } - if opts.LookbackDelta() <= 0 { - opts = promql.NewPrometheusQueryOpts(opts.EnablePerStepStats(), e.lookbackDelta) - } - qOpts := e.makeQueryOpts(ts, ts, 0, opts) if qOpts.StepsBatch > 64 { return nil, ErrStepsBatchTooLarge @@ -355,7 +355,7 @@ func (e *Engine) NewInstantQueryFromPlan(ctx context.Context, q storage.Queryabl }, nil } -func (e *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, step time.Duration) (promql.Query, error) { +func (e *Engine) MakeRangeQuery(ctx context.Context, q storage.Queryable, opts *QueryOpts, qs string, start, end time.Time, step time.Duration) (promql.Query, error) { idx, err := e.activeQueryTracker.Insert(ctx, qs) if err != nil { return nil, err @@ -371,12 +371,6 @@ func (e *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts pr if expr.Type() != parser.ValueTypeVector && expr.Type() != parser.ValueTypeScalar { return nil, errors.Newf("invalid expression type %q for range query, must be Scalar or instant Vector", parser.DocumentedType(expr.Type())) } - if opts == nil { - opts = promql.NewPrometheusQueryOpts(false, e.lookbackDelta) - } - if opts.LookbackDelta() <= 0 { - opts = promql.NewPrometheusQueryOpts(opts.EnablePerStepStats(), e.lookbackDelta) - } qOpts := e.makeQueryOpts(start, end, step, opts) if qOpts.StepsBatch > 64 { return nil, ErrStepsBatchTooLarge @@ -413,19 +407,13 @@ func (e *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts pr }, nil } -func (e *Engine) NewRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, root logicalplan.Node, start, end time.Time, step time.Duration) (promql.Query, error) { +func (e *Engine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts *QueryOpts, root logicalplan.Node, start, end time.Time, step time.Duration) (promql.Query, error) { idx, err := e.activeQueryTracker.Insert(ctx, root.String()) if err != nil { return nil, err } defer e.activeQueryTracker.Delete(idx) - if opts == nil { - opts = promql.NewPrometheusQueryOpts(false, e.lookbackDelta) - } - if opts.LookbackDelta() <= 0 { - opts = promql.NewPrometheusQueryOpts(opts.EnablePerStepStats(), e.lookbackDelta) - } qOpts := e.makeQueryOpts(start, end, step, opts) if qOpts.StepsBatch > 64 { return nil, ErrStepsBatchTooLarge @@ -461,20 +449,50 @@ func (e *Engine) NewRangeQueryFromPlan(ctx context.Context, q storage.Queryable, }, nil } -func (e *Engine) makeQueryOpts(start time.Time, end time.Time, step time.Duration, opts promql.QueryOpts) *query.Options { - qOpts := &query.Options{ +// PromQL compatibility constructors + +// NewInstantQuery implements the promql.Engine interface. +func (e *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error) { + return e.MakeInstantQuery(ctx, q, fromPromQLOpts(opts), qs, ts) +} + +// NewRangeQuery implements the promql.Engine interface. +func (e *Engine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, step time.Duration) (promql.Query, error) { + return e.MakeRangeQuery(ctx, q, fromPromQLOpts(opts), qs, start, end, step) +} + +func (e *Engine) makeQueryOpts(start time.Time, end time.Time, step time.Duration, opts *QueryOpts) *query.Options { + res := &query.Options{ Start: start, End: end, Step: step, StepsBatch: stepsBatch, - LookbackDelta: opts.LookbackDelta(), - EnablePerStepStats: e.enablePerStepStats && opts.EnablePerStepStats(), + LookbackDelta: e.lookbackDelta, + EnablePerStepStats: e.enablePerStepStats, ExtLookbackDelta: e.extLookbackDelta, EnableAnalysis: e.enableAnalysis, + EnablePartialResponses: e.enablePartialResponses, NoStepSubqueryIntervalFn: e.noStepSubqueryIntervalFn, DecodingConcurrency: e.decodingConcurrency, } - return qOpts + if opts == nil { + return res + } + + if opts.LookbackDelta() > 0 { + res.LookbackDelta = opts.LookbackDelta() + } + if opts.EnablePerStepStats() { + res.EnablePerStepStats = opts.EnablePerStepStats() + } + + if opts.DecodingConcurrency != 0 { + res.DecodingConcurrency = opts.DecodingConcurrency + } + if opts.EnablePartialResponses { + res.EnablePartialResponses = opts.EnablePartialResponses + } + return res } func (e *Engine) storageScanners(queryable storage.Queryable, qOpts *query.Options, lplan logicalplan.Plan) (engstorage.Scanners, error) { diff --git a/vendor/github.com/thanos-io/promql-engine/execution/execution.go b/vendor/github.com/thanos-io/promql-engine/execution/execution.go index 8746693b02..d465410199 100644 --- a/vendor/github.com/thanos-io/promql-engine/execution/execution.go +++ b/vendor/github.com/thanos-io/promql-engine/execution/execution.go @@ -386,7 +386,7 @@ func newRemoteExecution(ctx context.Context, e logicalplan.RemoteExecution, opts // We need to set the lookback for the selector to 0 since the remote query already applies one lookback. selectorOpts := *opts selectorOpts.LookbackDelta = 0 - remoteExec := remote.NewExecution(qry, model.NewVectorPool(opts.StepsBatch), e.QueryRangeStart, &selectorOpts, hints) + remoteExec := remote.NewExecution(qry, model.NewVectorPool(opts.StepsBatch), e.QueryRangeStart, e.Engine.LabelSets(), &selectorOpts, hints) return exchange.NewConcurrent(remoteExec, 2, opts), nil } diff --git a/vendor/github.com/thanos-io/promql-engine/execution/remote/operator.go b/vendor/github.com/thanos-io/promql-engine/execution/remote/operator.go index 645b9b273d..35f290dd71 100644 --- a/vendor/github.com/thanos-io/promql-engine/execution/remote/operator.go +++ b/vendor/github.com/thanos-io/promql-engine/execution/remote/operator.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/efficientgo/core/errors" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage" @@ -29,8 +30,8 @@ type Execution struct { model.OperatorTelemetry } -func NewExecution(query promql.Query, pool *model.VectorPool, queryRangeStart time.Time, opts *query.Options, _ storage.SelectHints) *Execution { - storage := newStorageFromQuery(query, opts) +func NewExecution(query promql.Query, pool *model.VectorPool, queryRangeStart time.Time, engineLabels []labels.Labels, opts *query.Options, _ storage.SelectHints) *Execution { + storage := newStorageFromQuery(query, opts, engineLabels) oper := &Execution{ storage: storage, query: query, @@ -90,16 +91,18 @@ func (e *Execution) Samples() *stats.QuerySamples { type storageAdapter struct { query promql.Query opts *query.Options + lbls []labels.Labels once sync.Once err error series []promstorage.SignedSeries } -func newStorageFromQuery(query promql.Query, opts *query.Options) *storageAdapter { +func newStorageFromQuery(query promql.Query, opts *query.Options, lbls []labels.Labels) *storageAdapter { return &storageAdapter{ query: query, opts: opts, + lbls: lbls, } } @@ -120,7 +123,12 @@ func (s *storageAdapter) executeQuery(ctx context.Context) { warnings.AddToContext(w, ctx) } if result.Err != nil { - s.err = result.Err + err := errors.Wrapf(result.Err, "remote exec error [%s]", s.lbls) + if s.opts.EnablePartialResponses { + warnings.AddToContext(err, ctx) + } else { + s.err = err + } return } switch val := result.Value.(type) { diff --git a/vendor/github.com/thanos-io/promql-engine/logicalplan/distribute.go b/vendor/github.com/thanos-io/promql-engine/logicalplan/distribute.go index 0f16847d0a..f1ae3e0cbd 100644 --- a/vendor/github.com/thanos-io/promql-engine/logicalplan/distribute.go +++ b/vendor/github.com/thanos-io/promql-engine/logicalplan/distribute.go @@ -254,7 +254,6 @@ func (m DistributedExecutionOptimizer) Optimize(plan Node, opts *query.Options) *current = m.distributeQuery(current, engines, m.subqueryOpts(parents, current, opts), minEngineOverlap) return true }) - return plan, *warns } diff --git a/vendor/github.com/thanos-io/promql-engine/query/options.go b/vendor/github.com/thanos-io/promql-engine/query/options.go index 5dbb3c0971..decdda36cd 100644 --- a/vendor/github.com/thanos-io/promql-engine/query/options.go +++ b/vendor/github.com/thanos-io/promql-engine/query/options.go @@ -17,6 +17,7 @@ type Options struct { ExtLookbackDelta time.Duration NoStepSubqueryIntervalFn func(time.Duration) time.Duration EnableAnalysis bool + EnablePartialResponses bool DecodingConcurrency int } diff --git a/vendor/github.com/thanos-io/promql-engine/storage/prometheus/vector_selector.go b/vendor/github.com/thanos-io/promql-engine/storage/prometheus/vector_selector.go index 082a689f63..2cc88fcd20 100644 --- a/vendor/github.com/thanos-io/promql-engine/storage/prometheus/vector_selector.go +++ b/vendor/github.com/thanos-io/promql-engine/storage/prometheus/vector_selector.go @@ -242,6 +242,5 @@ func selectPoint(it *storage.MemoizedSeriesIterator, ts, lookbackDelta, offset i if value.IsStaleNaN(v) || (fh != nil && value.IsStaleNaN(fh.Sum)) { return 0, 0, nil, false, nil } - return t, v, fh, true, nil } diff --git a/vendor/github.com/thanos-io/thanos/pkg/cacheutil/memcached_server_selector.go b/vendor/github.com/thanos-io/thanos/pkg/cacheutil/memcached_server_selector.go index 00a122e075..5426d6af33 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/cacheutil/memcached_server_selector.go +++ b/vendor/github.com/thanos-io/thanos/pkg/cacheutil/memcached_server_selector.go @@ -8,7 +8,7 @@ import ( "sync" "github.com/bradfitz/gomemcache/memcache" - "github.com/cespare/xxhash" + "github.com/cespare/xxhash/v2" "github.com/facette/natsort" ) diff --git a/vendor/github.com/thanos-io/thanos/pkg/query/remote_engine.go b/vendor/github.com/thanos-io/thanos/pkg/query/remote_engine.go index 77a74c9a6f..c44dd04b8d 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/query/remote_engine.go +++ b/vendor/github.com/thanos-io/thanos/pkg/query/remote_engine.go @@ -33,11 +33,12 @@ import ( // Opts are the options for a PromQL query. type Opts struct { - AutoDownsample bool - ReplicaLabels []string - PartitionLabels []string - Timeout time.Duration - EnablePartialResponse bool + AutoDownsample bool + ReplicaLabels []string + PartitionLabels []string + Timeout time.Duration + EnablePartialResponse bool + QueryDistributedWithOverlappingInterval bool } // Client is a query client that executes PromQL queries. @@ -114,6 +115,7 @@ func NewRemoteEngine(logger log.Logger, queryClient Client, opts Opts) *remoteEn // a block due to retention before other replicas did the same. // See https://github.com/thanos-io/promql-engine/issues/187. func (r *remoteEngine) MinT() int64 { + r.mintOnce.Do(func() { var ( hashBuf = make([]byte, 0, 128) @@ -126,7 +128,11 @@ func (r *remoteEngine) MinT() int64 { highestMintByLabelSet[key] = lset.MinTime continue } - if lset.MinTime > lsetMinT { + // If we are querying with overlapping intervals, we want to find the first available timestamp + // otherwise we want to find the last available timestamp. + if r.opts.QueryDistributedWithOverlappingInterval && lset.MinTime < lsetMinT { + highestMintByLabelSet[key] = lset.MinTime + } else if !r.opts.QueryDistributedWithOverlappingInterval && lset.MinTime > lsetMinT { highestMintByLabelSet[key] = lset.MinTime } } diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go b/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go index 1c434f503f..33fb4732dc 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go @@ -14,13 +14,14 @@ import ( "math" "os" "path" + "slices" "sort" "strings" "sync" "time" "github.com/alecthomas/units" - "github.com/cespare/xxhash" + "github.com/cespare/xxhash/v2" "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/gogo/protobuf/types" @@ -35,7 +36,6 @@ import ( "github.com/prometheus/prometheus/tsdb/encoding" "github.com/prometheus/prometheus/tsdb/index" "github.com/weaveworks/common/httpgrpc" - "golang.org/x/exp/slices" "golang.org/x/sync/errgroup" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/cache/filter_cache.go b/vendor/github.com/thanos-io/thanos/pkg/store/cache/filter_cache.go index 44d46db709..ade9da4c81 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/cache/filter_cache.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/cache/filter_cache.go @@ -6,11 +6,11 @@ package storecache import ( "context" "fmt" + "slices" "github.com/oklog/ulid" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" - "golang.org/x/exp/slices" ) type FilteredIndexCache struct { diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/flushable.go b/vendor/github.com/thanos-io/thanos/pkg/store/flushable.go index 33680c3c89..aa722b6aac 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/flushable.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/flushable.go @@ -4,8 +4,9 @@ package store import ( + "slices" + "github.com/prometheus/prometheus/model/labels" - "golang.org/x/exp/slices" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go b/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go index ef7ae5d00a..783e04b31b 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go @@ -6,6 +6,7 @@ package store import ( "context" "math" + "slices" "strings" "github.com/go-kit/log/level" @@ -14,7 +15,6 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/index" - "golang.org/x/exp/slices" "github.com/thanos-io/thanos/pkg/block/indexheader" ) diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/tsdb_selector.go b/vendor/github.com/thanos-io/thanos/pkg/store/tsdb_selector.go index 463ab96b14..761aa46737 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/tsdb_selector.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/tsdb_selector.go @@ -4,12 +4,12 @@ package store import ( - "sort" + "maps" + "slices" "strings" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/relabel" - "golang.org/x/exp/maps" "github.com/thanos-io/thanos/pkg/store/storepb" ) @@ -88,8 +88,7 @@ func MatchersForLabelSets(labelSets []labels.Labels) []storepb.LabelMatcher { matchers := make([]storepb.LabelMatcher, 0, len(labelNameValues)) for lblName, lblVals := range labelNameValues { - values := maps.Keys(lblVals) - sort.Strings(values) + values := slices.Sorted(maps.Keys(lblVals)) matcher := storepb.LabelMatcher{ Name: lblName, Value: strings.Join(values, "|"), diff --git a/vendor/golang.org/x/exp/maps/maps.go b/vendor/golang.org/x/exp/maps/maps.go deleted file mode 100644 index ecc0dabb74..0000000000 --- a/vendor/golang.org/x/exp/maps/maps.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package maps defines various functions useful with maps of any type. -package maps - -// Keys returns the keys of the map m. -// The keys will be in an indeterminate order. -func Keys[M ~map[K]V, K comparable, V any](m M) []K { - r := make([]K, 0, len(m)) - for k := range m { - r = append(r, k) - } - return r -} - -// Values returns the values of the map m. -// The values will be in an indeterminate order. -func Values[M ~map[K]V, K comparable, V any](m M) []V { - r := make([]V, 0, len(m)) - for _, v := range m { - r = append(r, v) - } - return r -} - -// Equal reports whether two maps contain the same key/value pairs. -// Values are compared using ==. -func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || v1 != v2 { - return false - } - } - return true -} - -// EqualFunc is like Equal, but compares values using eq. -// Keys are still compared with ==. -func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || !eq(v1, v2) { - return false - } - } - return true -} - -// Clear removes all entries from m, leaving it empty. -func Clear[M ~map[K]V, K comparable, V any](m M) { - for k := range m { - delete(m, k) - } -} - -// Clone returns a copy of m. This is a shallow clone: -// the new keys and values are set using ordinary assignment. -func Clone[M ~map[K]V, K comparable, V any](m M) M { - // Preserve nil in case it matters. - if m == nil { - return nil - } - r := make(M, len(m)) - for k, v := range m { - r[k] = v - } - return r -} - -// Copy copies all key/value pairs in src adding them to dst. -// When a key in src is already present in dst, -// the value in dst will be overwritten by the value associated -// with the key in src. -func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { - for k, v := range src { - dst[k] = v - } -} - -// DeleteFunc deletes any key/value pairs from m for which del returns true. -func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) { - for k, v := range m { - if del(k, v) { - delete(m, k) - } - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7d17aceab0..3922b35f95 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -293,9 +293,6 @@ github.com/caio/go-tdigest # github.com/cenkalti/backoff/v4 v4.3.0 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 -# github.com/cespare/xxhash v1.1.0 -## explicit -github.com/cespare/xxhash # github.com/cespare/xxhash/v2 v2.3.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 @@ -967,7 +964,7 @@ github.com/thanos-io/objstore/providers/gcs github.com/thanos-io/objstore/providers/s3 github.com/thanos-io/objstore/providers/swift github.com/thanos-io/objstore/tracing/opentracing -# github.com/thanos-io/promql-engine v0.0.0-20241203103240-2f49f80c7c68 +# github.com/thanos-io/promql-engine v0.0.0-20241217103156-9dbff30059cf ## explicit; go 1.22.0 github.com/thanos-io/promql-engine/api github.com/thanos-io/promql-engine/engine @@ -990,7 +987,7 @@ github.com/thanos-io/promql-engine/query github.com/thanos-io/promql-engine/ringbuffer github.com/thanos-io/promql-engine/storage github.com/thanos-io/promql-engine/storage/prometheus -# github.com/thanos-io/thanos v0.37.2-0.20241210234302-0ea6bac096ce +# github.com/thanos-io/thanos v0.37.3-0.20241224143735-2d041dc774da ## explicit; go 1.23.0 github.com/thanos-io/thanos/pkg/api/query/querypb github.com/thanos-io/thanos/pkg/block @@ -1307,7 +1304,6 @@ golang.org/x/crypto/pkcs12/internal/rc2 # golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 ## explicit; go 1.20 golang.org/x/exp/constraints -golang.org/x/exp/maps golang.org/x/exp/slices # golang.org/x/mod v0.21.0 ## explicit; go 1.22.0