From 9c25985b970865f054dfa9243cbe984d921df3c8 Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Wed, 17 Apr 2024 08:30:51 -0700 Subject: [PATCH] feat(blooms): record time spent resolving shards (#12636) --- pkg/logql/metrics.go | 1 + pkg/logqlmodel/stats/context.go | 15 +- pkg/logqlmodel/stats/stats.pb.go | 217 +++++++++++++--------- pkg/logqlmodel/stats/stats.proto | 2 + pkg/querier/queryrange/codec_test.go | 3 +- pkg/querier/queryrange/prometheus_test.go | 3 +- pkg/storage/stores/index/index.go | 12 ++ pkg/util/marshal/legacy/marshal_test.go | 3 +- pkg/util/marshal/marshal_test.go | 3 +- 9 files changed, 154 insertions(+), 105 deletions(-) diff --git a/pkg/logql/metrics.go b/pkg/logql/metrics.go index e9921a07c294..ed8405fc4e6e 100644 --- a/pkg/logql/metrics.go +++ b/pkg/logql/metrics.go @@ -203,6 +203,7 @@ func RecordRangeAndInstantQueryMetrics( "index_total_chunks", stats.Index.TotalChunks, "index_post_bloom_filter_chunks", stats.Index.PostFilterChunks, "index_bloom_filter_ratio", fmt.Sprintf("%.2f", bloomRatio), + "index_shard_resolver_duration", time.Duration(stats.Index.ShardsDuration), }...) logValues = append(logValues, tagsToKeyValues(queryTags)...) diff --git a/pkg/logqlmodel/stats/context.go b/pkg/logqlmodel/stats/context.go index f895f7fc6c9b..18794fb137fe 100644 --- a/pkg/logqlmodel/stats/context.go +++ b/pkg/logqlmodel/stats/context.go @@ -116,11 +116,6 @@ func (c *Context) Caches() Caches { } } -// Index returns the index statistics accumulated so far. -func (c *Context) Index() Index { - return c.index -} - // Reset clears the statistics. func (c *Context) Reset() { c.mtx.Lock() @@ -170,15 +165,6 @@ func JoinIngesters(ctx context.Context, inc Ingester) { stats.ingester.Merge(inc) } -// JoinIndex joins the index statistics in a concurrency-safe manner. -func JoinIndex(ctx context.Context, index Index) { - stats := FromContext(ctx) - stats.mtx.Lock() - defer stats.mtx.Unlock() - - stats.index.Merge(index) -} - // ComputeSummary compute the summary of the statistics. func (r *Result) ComputeSummary(execTime time.Duration, queueTime time.Duration, totalEntriesReturned int) { r.Summary.TotalBytesProcessed = r.Querier.Store.Chunk.DecompressedBytes + r.Querier.Store.Chunk.HeadChunkBytes + @@ -247,6 +233,7 @@ func (i *Ingester) Merge(m Ingester) { func (i *Index) Merge(m Index) { i.TotalChunks += m.TotalChunks i.PostFilterChunks += m.PostFilterChunks + i.ShardsDuration += m.ShardsDuration } func (c *Caches) Merge(m Caches) { diff --git a/pkg/logqlmodel/stats/stats.pb.go b/pkg/logqlmodel/stats/stats.pb.go index 9a728c161267..432cd55a7703 100644 --- a/pkg/logqlmodel/stats/stats.pb.go +++ b/pkg/logqlmodel/stats/stats.pb.go @@ -358,6 +358,8 @@ type Index struct { TotalChunks int64 `protobuf:"varint,1,opt,name=totalChunks,proto3" json:"totalChunks"` // Post-filtered chunks PostFilterChunks int64 `protobuf:"varint,2,opt,name=postFilterChunks,proto3" json:"postFilterChunks"` + // Nanosecond duration spent fetching shards + ShardsDuration int64 `protobuf:"varint,3,opt,name=shardsDuration,proto3" json:"shardsDuration"` } func (m *Index) Reset() { *m = Index{} } @@ -406,6 +408,13 @@ func (m *Index) GetPostFilterChunks() int64 { return 0 } +func (m *Index) GetShardsDuration() int64 { + if m != nil { + return m.ShardsDuration + } + return 0 +} + type Querier struct { Store Store `protobuf:"bytes,1,opt,name=store,proto3" json:"store"` } @@ -864,92 +873,94 @@ func init() { func init() { proto.RegisterFile("pkg/logqlmodel/stats/stats.proto", fileDescriptor_6cdfe5d2aea33ebb) } var fileDescriptor_6cdfe5d2aea33ebb = []byte{ - // 1358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0xcd, 0x6f, 0xdc, 0x44, - 0x14, 0xdf, 0xcd, 0xd6, 0x9b, 0x74, 0xf2, 0xd5, 0x4e, 0x52, 0xba, 0xa5, 0x95, 0x1d, 0x16, 0x2a, - 0x8a, 0x90, 0xb2, 0x2a, 0x45, 0x42, 0x20, 0x2a, 0x21, 0xa7, 0x44, 0xaa, 0x94, 0x8a, 0xf2, 0x16, - 0x04, 0x82, 0x93, 0x63, 0xbf, 0xec, 0x5a, 0xf5, 0xda, 0x8e, 0x3d, 0x0e, 0x8d, 0x84, 0x04, 0x7f, - 0x02, 0x77, 0xee, 0x88, 0x0b, 0x27, 0x4e, 0x9c, 0xb9, 0xf4, 0xd8, 0x63, 0x4f, 0x16, 0xdd, 0x5c, - 0x90, 0x4f, 0xfd, 0x03, 0x38, 0xa0, 0xf9, 0x58, 0x7f, 0xad, 0x37, 0xcd, 0x65, 0x3d, 0xef, 0xf7, - 0xde, 0xef, 0xcd, 0xcc, 0x9b, 0x79, 0xef, 0xcd, 0x92, 0x9d, 0xf0, 0xc9, 0x68, 0xe0, 0x05, 0xa3, - 0x63, 0x6f, 0x12, 0x38, 0xe8, 0x0d, 0x62, 0x66, 0xb1, 0x58, 0xfe, 0xee, 0x86, 0x51, 0xc0, 0x02, - 0xaa, 0x09, 0xe1, 0xcd, 0xed, 0x51, 0x30, 0x0a, 0x04, 0x32, 0xe0, 0x23, 0xa9, 0xec, 0xff, 0xb6, - 0x44, 0xba, 0x80, 0x71, 0xe2, 0x31, 0xfa, 0x31, 0x59, 0x8e, 0x93, 0xc9, 0xc4, 0x8a, 0x4e, 0x7b, - 0xed, 0x9d, 0xf6, 0x9d, 0xd5, 0x0f, 0x36, 0x76, 0xa5, 0x9b, 0xa1, 0x44, 0xcd, 0xcd, 0x67, 0xa9, - 0xd1, 0xca, 0x52, 0x63, 0x66, 0x06, 0xb3, 0x01, 0xa7, 0x1e, 0x27, 0x18, 0xb9, 0x18, 0xf5, 0x96, - 0x2a, 0xd4, 0x2f, 0x25, 0x5a, 0x50, 0x95, 0x19, 0xcc, 0x06, 0xf4, 0x3e, 0x59, 0x71, 0xfd, 0x11, - 0xc6, 0x0c, 0xa3, 0x5e, 0x47, 0x70, 0x37, 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xbe, 0x1b, - 0x8c, 0x5c, 0x36, 0x4e, 0x0e, 0x77, 0xed, 0x60, 0x32, 0x18, 0x45, 0xd6, 0x91, 0xe5, 0x5b, 0x03, - 0x2f, 0x78, 0xe2, 0x0e, 0x4e, 0xee, 0x0d, 0x9a, 0xfe, 0xf9, 0x1f, 0x76, 0xc5, 0xff, 0xfa, 0x7b, - 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x19, 0x80, 0x75, 0xde, 0x18, 0x10, 0x00, 0x00, + // 1378 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x58, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0xde, 0xcd, 0xd6, 0x9b, 0x74, 0xf2, 0xab, 0x9d, 0xa4, 0x74, 0x4b, 0x2b, 0x3b, 0x2c, 0x54, + 0x14, 0x21, 0x65, 0x55, 0x8a, 0x84, 0x40, 0x54, 0x42, 0x4e, 0x89, 0x54, 0x29, 0x15, 0xe5, 0x2d, + 0x08, 0x04, 0x27, 0xc7, 0x9e, 0xec, 0x5a, 0xf5, 0xda, 0x8e, 0x3d, 0x0e, 0xcd, 0x09, 0xfe, 0x04, + 0xee, 0xdc, 0x11, 0x17, 0x4e, 0x5c, 0xe0, 0xcc, 0xa5, 0xc7, 0x1e, 0x7b, 0xb2, 0xe8, 0xe6, 0x82, + 0x7c, 0xea, 0x1f, 0xc0, 0x01, 0xcd, 0x9b, 0x59, 0xff, 0x5a, 0x6f, 0x9a, 0xcb, 0x7a, 0xde, 0xf7, + 0xbe, 0xef, 0xcd, 0xf8, 0x79, 0xe6, 0xbd, 0xd1, 0x92, 0x9d, 0xf0, 0xc9, 0x68, 0xe0, 0x05, 0xa3, + 0x63, 0x6f, 0x12, 0x38, 0xcc, 0x1b, 0xc4, 0xdc, 0xe2, 0xb1, 0xfc, 0xdd, 0x0d, 0xa3, 0x80, 0x07, + 0x54, 0x43, 0xe3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xe1, 0x9d, 0x30, 0x07, 0xa1, 0x18, 0x8a, + 0xab, 0x66, 0x24, 0xd7, 0x2a, 0xcf, 0x92, 0x26, 0xaf, 0x9a, 0x33, 0x0c, 0xf2, 0x91, 0x48, 0xa0, + 0x53, 0x2e, 0xf1, 0xcb, 0x45, 0x93, 0x2c, 0xe3, 0x50, 0xb1, 0xc4, 0x79, 0xc3, 0x72, 0x7c, 0xc0, + 0xfc, 0x11, 0x1f, 0x0f, 0x59, 0x74, 0x92, 0x5f, 0x20, 0xf1, 0xbc, 0xcd, 0x39, 0x61, 0x1e, 0x32, + 0xd9, 0xf3, 0x97, 0x7a, 0xeb, 0xc5, 0x4b, 0xbd, 0xf5, 0xea, 0xa5, 0xde, 0xfe, 0x69, 0xaa, 0xb7, + 0x7f, 0x9b, 0xea, 0xed, 0x67, 0x53, 0xbd, 0xfd, 0x7c, 0xaa, 0xb7, 0xff, 0x99, 0xea, 0xed, 0x7f, + 0xa7, 0x7a, 0xeb, 0xd5, 0x54, 0x6f, 0xff, 0x7c, 0xa6, 0xb7, 0x9e, 0x9f, 0xe9, 0xad, 0x17, 0x67, + 0x7a, 0xeb, 0xbb, 0xc1, 0xc8, 0xe5, 0xe3, 0xe4, 0x70, 0xd7, 0x0e, 0x26, 0x83, 0x51, 0x64, 0x1d, + 0x59, 0xbe, 0x35, 0xf0, 0x82, 0x27, 0xee, 0xe0, 0xe4, 0xde, 0xa0, 0xe9, 0x6f, 0x83, 0xc3, 0x2e, + 0xfe, 0x29, 0x70, 0xef, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x64, 0x90, 0x88, 0xaf, 0x55, 0x10, + 0x00, 0x00, } func (this *Result) Equal(that interface{}) bool { @@ -1115,6 +1126,9 @@ func (this *Index) Equal(that interface{}) bool { if this.PostFilterChunks != that1.PostFilterChunks { return false } + if this.ShardsDuration != that1.ShardsDuration { + return false + } return true } func (this *Querier) Equal(that interface{}) bool { @@ -1371,10 +1385,11 @@ func (this *Index) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 6) + s := make([]string, 0, 7) s = append(s, "&stats.Index{") s = append(s, "TotalChunks: "+fmt.Sprintf("%#v", this.TotalChunks)+",\n") s = append(s, "PostFilterChunks: "+fmt.Sprintf("%#v", this.PostFilterChunks)+",\n") + s = append(s, "ShardsDuration: "+fmt.Sprintf("%#v", this.ShardsDuration)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -1743,6 +1758,11 @@ func (m *Index) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ShardsDuration != 0 { + i = encodeVarintStats(dAtA, i, uint64(m.ShardsDuration)) + i-- + dAtA[i] = 0x18 + } if m.PostFilterChunks != 0 { i = encodeVarintStats(dAtA, i, uint64(m.PostFilterChunks)) i-- @@ -2158,6 +2178,9 @@ func (m *Index) Size() (n int) { if m.PostFilterChunks != 0 { n += 1 + sovStats(uint64(m.PostFilterChunks)) } + if m.ShardsDuration != 0 { + n += 1 + sovStats(uint64(m.ShardsDuration)) + } return n } @@ -2361,6 +2384,7 @@ func (this *Index) String() string { s := strings.Join([]string{`&Index{`, `TotalChunks:` + fmt.Sprintf("%v", this.TotalChunks) + `,`, `PostFilterChunks:` + fmt.Sprintf("%v", this.PostFilterChunks) + `,`, + `ShardsDuration:` + fmt.Sprintf("%v", this.ShardsDuration) + `,`, `}`, }, "") return s @@ -3316,6 +3340,25 @@ func (m *Index) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardsDuration", wireType) + } + m.ShardsDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStats + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardsDuration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipStats(dAtA[iNdEx:]) diff --git a/pkg/logqlmodel/stats/stats.proto b/pkg/logqlmodel/stats/stats.proto index b53747b7941f..0b48078e9e93 100644 --- a/pkg/logqlmodel/stats/stats.proto +++ b/pkg/logqlmodel/stats/stats.proto @@ -108,6 +108,8 @@ message Index { int64 totalChunks = 1 [(gogoproto.jsontag) = "totalChunks"]; // Post-filtered chunks int64 postFilterChunks = 2 [(gogoproto.jsontag) = "postFilterChunks"]; + // Nanosecond duration spent fetching shards + int64 shardsDuration = 3 [(gogoproto.jsontag) = "shardsDuration"]; } message Querier { diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index b334ab5b0691..273750f71364 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -1691,7 +1691,8 @@ var ( }, "index": { "postFilterChunks": 0, - "totalChunks": 0 + "totalChunks": 0, + "shardsDuration": 0 }, "cache": { "chunk": { diff --git a/pkg/querier/queryrange/prometheus_test.go b/pkg/querier/queryrange/prometheus_test.go index 9d47be945b56..2888fbfdd6ac 100644 --- a/pkg/querier/queryrange/prometheus_test.go +++ b/pkg/querier/queryrange/prometheus_test.go @@ -15,7 +15,8 @@ import ( var emptyStats = `"stats": { "index": { "postFilterChunks": 0, - "totalChunks": 0 + "totalChunks": 0, + "shardsDuration": 0 }, "ingester" : { "store": { diff --git a/pkg/storage/stores/index/index.go b/pkg/storage/stores/index/index.go index 26b2a4488004..99e5b3597883 100644 --- a/pkg/storage/stores/index/index.go +++ b/pkg/storage/stores/index/index.go @@ -2,6 +2,7 @@ package index import ( "context" + "time" "github.com/grafana/dskit/instrument" "github.com/prometheus/client_golang/prometheus" @@ -160,7 +161,18 @@ func (m MonitoredReaderWriter) GetShards( var shards *logproto.ShardsResponse if err := loki_instrument.TimeRequest(ctx, "shards", instrument.NewHistogramCollector(m.metrics.indexQueryLatency), instrument.ErrorCode, func(ctx context.Context) error { var err error + start := time.Now() shards, err = m.rw.GetShards(ctx, userID, from, through, targetBytesPerShard, predicate) + + if err == nil { + // record duration here from caller to avoid needing to do this in two separate places: + // 1) when we resolve shards from the index alone + // 2) when we resolve shards from the index + blooms + // NB(owen-d): since this is measured by the callee, it does not include time in queue, + // over the wire, etc. + shards.Statistics.Index.ShardsDuration = int64(time.Since(start)) + } + return err }); err != nil { return nil, err diff --git a/pkg/util/marshal/legacy/marshal_test.go b/pkg/util/marshal/legacy/marshal_test.go index b535a390479f..90fdef6281ed 100644 --- a/pkg/util/marshal/legacy/marshal_test.go +++ b/pkg/util/marshal/legacy/marshal_test.go @@ -58,7 +58,8 @@ var queryTests = []struct { "stats" : { "index": { "postFilterChunks": 0, - "totalChunks": 0 + "totalChunks": 0, + "shardsDuration": 0 }, "ingester" : { "store": { diff --git a/pkg/util/marshal/marshal_test.go b/pkg/util/marshal/marshal_test.go index 1ccbe2158dfc..c749677f7702 100644 --- a/pkg/util/marshal/marshal_test.go +++ b/pkg/util/marshal/marshal_test.go @@ -27,7 +27,8 @@ import ( const emptyStats = `{ "index": { "postFilterChunks": 0, - "totalChunks": 0 + "totalChunks": 0, + "shardsDuration": 0 }, "ingester" : { "store": {