fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

matchiter: capture metric NgramLookups (#608)

This instruments our matchiter code to track how often is calls Get on
the underlying ngram index. We have some queries on long strings which
are going much slower than expected and we suspect it is related to the
work done here.

This change requires a few moving pieces:
- Adding the int to Stats
- Instrumenting places we log/emit Stats
- grpc support
- capturing this work in matchiter code
- updating tests to ensure correctness

The last two points are the meat of this commit, while the rest was
mechanical work. I reworked the TestAndSearch since into TestSearchStats
since it was the only test which had useful assertions on Stats.

I was surprised to see how high the ngram lookup values were for such
simple queries. This makes me more confident in improving our
performance here.

Test Plan: go test

+316 -195
+5
api.go
··· 382 382 // Number of candidate matches as a result of searching ngrams. 383 383 NgramMatches int 384 384 385 + // NgramLookups is the number of times we accessed an ngram in the index. 386 + NgramLookups int 387 + 385 388 // Wall clock time for queued search. 386 389 Wait time.Duration 387 390 ··· 409 412 s.FilesSkipped += o.FilesSkipped 410 413 s.MatchCount += o.MatchCount 411 414 s.NgramMatches += o.NgramMatches 415 + s.NgramLookups += o.NgramLookups 412 416 s.ShardFilesConsidered += o.ShardFilesConsidered 413 417 s.ShardsScanned += o.ShardsScanned 414 418 s.ShardsSkipped += o.ShardsSkipped ··· 438 442 s.FilesSkipped > 0 || 439 443 s.MatchCount > 0 || 440 444 s.NgramMatches > 0 || 445 + s.NgramLookups > 0 || 441 446 s.ShardFilesConsidered > 0 || 442 447 s.ShardsScanned > 0 || 443 448 s.ShardsSkipped > 0 ||
+2
api_proto.go
··· 297 297 ShardsSkippedFilter: int(p.GetShardsSkippedFilter()), 298 298 MatchCount: int(p.GetMatchCount()), 299 299 NgramMatches: int(p.GetNgramMatches()), 300 + NgramLookups: int(p.GetNgramLookups()), 300 301 Wait: p.GetWait().AsDuration(), 301 302 RegexpsConsidered: int(p.GetRegexpsConsidered()), 302 303 FlushReason: FlushReasonFromProto(p.GetFlushReason()), ··· 319 320 ShardsSkippedFilter: int64(s.ShardsSkippedFilter), 320 321 MatchCount: int64(s.MatchCount), 321 322 NgramMatches: int64(s.NgramMatches), 323 + NgramLookups: int64(s.NgramLookups), 322 324 Wait: durationpb.New(s.Wait), 323 325 RegexpsConsidered: int64(s.RegexpsConsidered), 324 326 FlushReason: s.FlushReason.ToProto(),
+1
cmd/zoekt-webserver/main.go
··· 594 594 sglog.Int("stat.ShardsSkippedFilter", st.ShardsSkippedFilter), 595 595 sglog.Int("stat.MatchCount", st.MatchCount), 596 596 sglog.Int("stat.NgramMatches", st.NgramMatches), 597 + sglog.Int("stat.NgramLookups", st.NgramLookups), 597 598 sglog.Duration("stat.Wait", st.Wait), 598 599 ) 599 600 }
+1 -7
deps.bzl
··· 1256 1256 sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=", 1257 1257 version = "v0.2.0", 1258 1258 ) 1259 - go_repository( 1260 - name = "com_github_kylelemons_godebug", 1261 - build_file_proto_mode = "disable_global", 1262 - importpath = "github.com/kylelemons/godebug", 1263 - sum = "h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=", 1264 - version = "v1.1.0", 1265 - ) 1259 + 1266 1260 go_repository( 1267 1261 name = "com_github_labstack_echo_v4", 1268 1262 build_file_proto_mode = "disable_global",
+1 -1
eval.go
··· 811 811 } 812 812 } 813 813 if len(qs) == 0 { 814 - return &noMatchTree{"const"}, isEq, false, nil 814 + return &noMatchTree{Why: "const"}, isEq, false, nil 815 815 } 816 816 return &orMatchTree{qs}, isEq, false, nil 817 817 case syntax.OpStar:
+1 -2
go.mod
··· 18 18 github.com/hashicorp/go-retryablehttp v0.7.2 19 19 github.com/keegancsmith/rpc v1.3.0 20 20 github.com/keegancsmith/tmpfriend v0.0.0-20180423180255-86e88902a513 21 - github.com/kylelemons/godebug v1.1.0 22 21 github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f 23 22 github.com/opentracing/opentracing-go v1.2.0 24 23 github.com/peterbourgon/ff/v3 v3.3.0 ··· 34 33 github.com/uber/jaeger-lib v2.4.1+incompatible 35 34 github.com/xanzy/go-gitlab v0.80.0 36 35 github.com/xeipuuv/gojsonschema v1.2.0 36 + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.39.0 37 37 go.opentelemetry.io/contrib/propagators/jaeger v1.14.0 38 38 go.opentelemetry.io/contrib/propagators/ot v1.14.0 39 39 go.opentelemetry.io/otel v1.13.0 ··· 115 115 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect 116 116 github.com/yusufpapurcu/wmi v1.2.2 // indirect 117 117 go.opencensus.io v0.24.0 // indirect 118 - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.39.0 // indirect 119 118 go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.13.0 // indirect 120 119 go.opentelemetry.io/otel/metric v0.36.0 // indirect 121 120 go.opentelemetry.io/proto/otlp v0.19.0 // indirect
-2
go.sum
··· 344 344 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 345 345 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 346 346 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 347 - github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= 348 - github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 349 347 github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= 350 348 github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= 351 349 github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
+140 -128
grpc/v1/webserver.pb.go
··· 1312 1312 RegexpsConsidered int64 `protobuf:"varint,16,opt,name=regexps_considered,json=regexpsConsidered,proto3" json:"regexps_considered,omitempty"` 1313 1313 // FlushReason explains why results were flushed. 1314 1314 FlushReason FlushReason `protobuf:"varint,17,opt,name=flush_reason,json=flushReason,proto3,enum=grpc.v1.FlushReason" json:"flush_reason,omitempty"` 1315 + // NgramLookups is the number of times we accessed an ngram in the index. 1316 + NgramLookups int64 `protobuf:"varint,18,opt,name=ngram_lookups,json=ngramLookups,proto3" json:"ngram_lookups,omitempty"` 1315 1317 } 1316 1318 1317 1319 func (x *Stats) Reset() { ··· 1463 1465 return x.FlushReason 1464 1466 } 1465 1467 return FlushReason_UNKNOWN 1468 + } 1469 + 1470 + func (x *Stats) GetNgramLookups() int64 { 1471 + if x != nil { 1472 + return x.NgramLookups 1473 + } 1474 + return 0 1466 1475 } 1467 1476 1468 1477 // Progress contains information about the global progress of the running search query. ··· 2463 2472 0x63, 0x68, 0x65, 0x73, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x5f, 0x63, 2464 2473 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x1a, 0x6f, 0x74, 0x68, 0x65, 2465 2474 0x72, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x4e, 0x65, 0x77, 0x4c, 0x69, 0x6e, 0x65, 2466 - 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xdf, 0x05, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 2475 + 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x84, 0x06, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 2467 2476 0x12, 0x30, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 2468 2477 0x73, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, 2469 2478 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x4c, 0x6f, 0x61, 0x64, ··· 2509 2518 0x37, 0x0a, 0x0c, 0x66, 0x6c, 0x75, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 2510 2519 0x11, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 2511 2520 0x46, 0x6c, 0x75, 0x73, 0x68, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x0b, 0x66, 0x6c, 0x75, 2512 - 0x73, 0x68, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x58, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x67, 2513 - 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 2514 - 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 2515 - 0x12, 0x30, 0x0a, 0x14, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 2516 - 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 2517 - 0x6d, 0x61, 0x78, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 2518 - 0x74, 0x79, 0x22, 0xa3, 0x04, 0x0a, 0x09, 0x46, 0x69, 0x6c, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 2519 - 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 2520 - 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 2521 - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x12, 0x1b, 0x0a, 0x09, 2522 - 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 2523 - 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 2524 - 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 2525 - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x72, 0x61, 2526 - 0x6e, 0x63, 0x68, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x62, 0x72, 0x61, 2527 - 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6d, 0x61, 2528 - 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x72, 2529 - 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 2530 - 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0d, 2531 - 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x07, 0x20, 2532 - 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 2533 - 0x75, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 0x0c, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x4d, 2534 - 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 2535 - 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x72, 2536 - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x13, 0x72, 2537 - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 2538 - 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 2539 - 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 2540 - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 2541 - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 2542 - 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 2543 - 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x18, 0x0c, 2544 - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x2e, 2545 - 0x0a, 0x13, 0x73, 0x75, 0x62, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 2546 - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x62, 2547 - 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 2548 - 0x0a, 0x13, 0x73, 0x75, 0x62, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 2549 - 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x62, 2550 - 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 2551 - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 2552 - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xbf, 0x02, 0x0a, 0x09, 0x4c, 0x69, 0x6e, 2553 - 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 2554 - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 2555 - 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 2556 - 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 2557 - 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6c, 0x69, 0x6e, 2558 - 0x65, 0x45, 0x6e, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 2559 - 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 2560 - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 2561 - 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x14, 0x0a, 2562 - 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x66, 2563 - 0x74, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 2564 - 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 2565 - 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x52, 2566 - 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 2567 - 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x62, 2568 - 0x75, 0x67, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x41, 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 2569 - 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 2570 - 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x46, 0x72, 2571 - 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 0x0d, 0x6c, 0x69, 0x6e, 2572 - 0x65, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xba, 0x01, 0x0a, 0x11, 0x4c, 2521 + 0x73, 0x68, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x67, 0x72, 0x61, 2522 + 0x6d, 0x5f, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x03, 0x52, 2523 + 0x0c, 0x6e, 0x67, 0x72, 0x61, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x73, 0x22, 0x58, 0x0a, 2524 + 0x08, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 2525 + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x70, 0x72, 0x69, 2526 + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x30, 0x0a, 0x14, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x65, 0x6e, 2527 + 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 2528 + 0x01, 0x28, 0x01, 0x52, 0x12, 0x6d, 0x61, 0x78, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 2529 + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0xa3, 0x04, 0x0a, 0x09, 0x46, 0x69, 0x6c, 0x65, 2530 + 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x01, 2531 + 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 2532 + 0x65, 0x62, 0x75, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 2533 + 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 2534 + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 2535 + 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 2536 + 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 2537 + 0x0a, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 2538 + 0x52, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x0c, 0x6c, 0x69, 2539 + 0x6e, 0x65, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 2540 + 0x32, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x4d, 2541 + 0x61, 0x74, 0x63, 0x68, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 2542 + 0x73, 0x12, 0x38, 0x0a, 0x0d, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 2543 + 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 2544 + 0x76, 0x31, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 0x0c, 0x63, 2545 + 0x68, 0x75, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x72, 2546 + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 2547 + 0x28, 0x0d, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 2548 + 0x12, 0x2f, 0x0a, 0x13, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 2549 + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x72, 2550 + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 2551 + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 2552 + 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 2553 + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 2554 + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 2555 + 0x61, 0x67, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 2556 + 0x61, 0x67, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x62, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 2557 + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 2558 + 0x52, 0x11, 0x73, 0x75, 0x62, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 2559 + 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x62, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 2560 + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 2561 + 0x52, 0x11, 0x73, 0x75, 0x62, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x50, 2562 + 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0f, 2563 + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xbf, 0x02, 2564 + 0x0a, 0x09, 0x4c, 0x69, 0x6e, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6c, 2565 + 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 2566 + 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 2567 + 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x19, 2568 + 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 2569 + 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x45, 0x6e, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 2570 + 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 2571 + 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 2572 + 0x66, 0x6f, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 2573 + 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 2574 + 0x0c, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 2575 + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6c, 2576 + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x08, 2577 + 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 2578 + 0x65, 0x62, 0x75, 0x67, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 2579 + 0x52, 0x0a, 0x64, 0x65, 0x62, 0x75, 0x67, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x41, 0x0a, 0x0e, 2580 + 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0a, 2581 + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 2573 2582 0x69, 0x6e, 0x65, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x61, 0x74, 0x63, 0x68, 2574 - 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 2575 - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x4f, 0x66, 0x66, 0x73, 0x65, 2576 - 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 2577 - 0x0d, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x61, 0x74, 2578 - 0x63, 0x68, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 2579 - 0x0b, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x39, 0x0a, 0x0b, 2580 - 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 2581 - 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6d, 0x62, 2582 - 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 2583 - 0x49, 0x6e, 0x66, 0x6f, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73, 0x79, 0x6d, 0x62, 2584 - 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6b, 0x0a, 0x0a, 0x53, 0x79, 0x6d, 0x62, 0x6f, 2585 - 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x79, 0x6d, 0x18, 0x01, 0x20, 0x01, 2586 - 0x28, 0x09, 0x52, 0x03, 0x73, 0x79, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 2587 - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 2588 - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 2589 - 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x69, 2590 - 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 2591 - 0x4b, 0x69, 0x6e, 0x64, 0x22, 0x90, 0x02, 0x0a, 0x0a, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x4d, 0x61, 2592 - 0x74, 0x63, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 2593 - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x36, 0x0a, 2594 - 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 2583 + 0x52, 0x0d, 0x6c, 0x69, 0x6e, 0x65, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 2584 + 0xba, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x6e, 0x65, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 2585 + 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 2586 + 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 2587 + 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 2588 + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x21, 2589 + 0x0a, 0x0c, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 2590 + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x65, 0x6e, 0x67, 0x74, 2591 + 0x68, 0x12, 0x39, 0x0a, 0x0b, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 2592 + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 2593 + 0x2e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x0a, 0x73, 2594 + 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 2595 + 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6b, 0x0a, 0x0a, 2596 + 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x79, 2597 + 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x79, 0x6d, 0x12, 0x12, 0x0a, 0x04, 2598 + 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 2599 + 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 2600 + 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 2601 + 0x6e, 0x74, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 2602 + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x22, 0x90, 0x02, 0x0a, 0x0a, 0x43, 0x68, 2603 + 0x75, 0x6e, 0x6b, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 2604 + 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 2605 + 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x74, 2606 + 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 2607 + 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x63, 0x6f, 2608 + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 2609 + 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 2610 + 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x61, 0x6e, 0x67, 0x65, 2611 + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 2612 + 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x06, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 2613 + 0x34, 0x0a, 0x0b, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x05, 2614 + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 2615 + 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x79, 0x6d, 0x62, 0x6f, 2616 + 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x06, 2617 + 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 2618 + 0x65, 0x62, 0x75, 0x67, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 2619 + 0x52, 0x0a, 0x64, 0x65, 0x62, 0x75, 0x67, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x55, 0x0a, 0x05, 2620 + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 2595 2621 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 2596 - 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 2597 - 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 2598 - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 2599 - 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 2600 - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, 2601 - 0x67, 0x65, 0x52, 0x06, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x0b, 0x73, 0x79, 2602 - 0x6d, 0x62, 0x6f, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 2603 - 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 2604 - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 2605 - 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 2606 - 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 2607 - 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x62, 2608 - 0x75, 0x67, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x55, 0x0a, 0x05, 0x52, 0x61, 0x6e, 0x67, 0x65, 2609 - 0x12, 0x27, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 2610 - 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 2611 - 0x6f, 0x6e, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x03, 0x65, 0x6e, 0x64, 2612 - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 2613 - 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x64, 2614 - 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x79, 2615 - 0x74, 0x65, 0x5f, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 2616 - 0x0a, 0x62, 0x79, 0x74, 0x65, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 2617 - 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 2618 - 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 2619 - 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x63, 0x6f, 2620 - 0x6c, 0x75, 0x6d, 0x6e, 0x2a, 0x4c, 0x0a, 0x0b, 0x46, 0x6c, 0x75, 0x73, 0x68, 0x52, 0x65, 0x61, 2621 - 0x73, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 2622 - 0x12, 0x11, 0x0a, 0x0d, 0x54, 0x49, 0x4d, 0x45, 0x52, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 2623 - 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x49, 0x4e, 0x41, 0x4c, 0x5f, 0x46, 0x4c, 0x55, 2624 - 0x53, 0x48, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x41, 0x58, 0x5f, 0x53, 0x49, 0x5a, 0x45, 2625 - 0x10, 0x03, 0x32, 0xcb, 0x01, 0x0a, 0x10, 0x57, 0x65, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 2626 - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 2627 - 0x68, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 2628 - 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x72, 0x70, 0x63, 2629 - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 2630 - 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 2631 - 0x61, 0x72, 0x63, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 2632 - 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 2633 - 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 2634 - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x69, 0x73, 2635 - 0x74, 0x12, 0x14, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 2636 - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 2637 - 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 2638 - 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 2639 - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 2640 - 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 2622 + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x23, 2623 + 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x72, 2624 + 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 2625 + 0x65, 0x6e, 0x64, 0x22, 0x64, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 2626 + 0x1f, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x5f, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 2627 + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 2628 + 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 2629 + 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 2630 + 0x72, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 2631 + 0x0d, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x2a, 0x4c, 0x0a, 0x0b, 0x46, 0x6c, 0x75, 2632 + 0x73, 0x68, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 2633 + 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x54, 0x49, 0x4d, 0x45, 0x52, 0x5f, 0x45, 2634 + 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x49, 0x4e, 0x41, 2635 + 0x4c, 0x5f, 0x46, 0x4c, 0x55, 0x53, 0x48, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x41, 0x58, 2636 + 0x5f, 0x53, 0x49, 0x5a, 0x45, 0x10, 0x03, 0x32, 0xcb, 0x01, 0x0a, 0x10, 0x57, 0x65, 0x62, 0x73, 2637 + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x06, 2638 + 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 2639 + 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 2640 + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 2641 + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0c, 0x53, 0x74, 0x72, 2642 + 0x65, 0x61, 0x6d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x70, 0x63, 2643 + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 2644 + 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 2645 + 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x35, 2646 + 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 2647 + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 2648 + 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 2649 + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 2650 + 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 2651 + 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 2652 + 0x72, 0x6f, 0x74, 0x6f, 0x33, 2641 2653 } 2642 2654 2643 2655 var (
+3
grpc/v1/webserver.proto
··· 337 337 338 338 // FlushReason explains why results were flushed. 339 339 FlushReason flush_reason = 17; 340 + 341 + // NgramLookups is the number of times we accessed an ngram in the index. 342 + int64 ngram_lookups = 18; 340 343 } 341 344 342 345 enum FlushReason {
+16 -3
hititer.go
··· 120 120 } 121 121 122 122 iters := make([]hitIterator, 0, len(variants)) 123 + ngramLookups := 0 123 124 for _, v := range variants { 124 125 if fileName { 125 126 blob, err := d.fileNameNgrams.GetBlob(v) 127 + ngramLookups++ 126 128 if err != nil { 127 129 return nil, err 128 130 } ··· 133 135 } 134 136 135 137 sec := d.ngrams.Get(v) 138 + ngramLookups++ 136 139 blob, err := d.readSectionBlob(sec) 137 140 if err != nil { 138 141 return nil, err ··· 143 146 } 144 147 145 148 if len(iters) == 1 { 146 - return iters[0], nil 149 + // if we only return 1 then we need to include our ngramLookups stats 150 + iter := (iters[0]).(*compressedPostingIterator) 151 + iter.ngramLookups = ngramLookups 152 + return iter, nil 147 153 } 148 154 return &mergingIterator{ 149 - iters: iters, 155 + ngramLookups: ngramLookups, 156 + iters: iters, 150 157 }, nil 151 158 } 152 159 ··· 185 192 type compressedPostingIterator struct { 186 193 blob []byte 187 194 indexBytesLoaded int 195 + ngramLookups int 188 196 _first uint32 189 197 what ngram 190 198 } ··· 228 236 229 237 func (i *compressedPostingIterator) updateStats(s *Stats) { 230 238 s.IndexBytesLoaded += int64(i.indexBytesLoaded) 239 + s.NgramLookups += i.ngramLookups 231 240 i.indexBytesLoaded = 0 241 + i.ngramLookups = 0 232 242 } 233 243 234 244 // mergingIterator forms the merge of a set of hitIterators, to 235 245 // implement an OR operation at the hit level. 236 246 type mergingIterator struct { 237 - iters []hitIterator 247 + iters []hitIterator 248 + ngramLookups int 238 249 } 239 250 240 251 func (i *mergingIterator) String() string { ··· 242 253 } 243 254 244 255 func (i *mergingIterator) updateStats(s *Stats) { 256 + s.NgramLookups += i.ngramLookups 257 + i.ngramLookups = 0 245 258 for _, j := range i.iters { 246 259 j.updateStats(s) 247 260 }
+118 -47
index_test.go
··· 26 26 "github.com/google/go-cmp/cmp" 27 27 "github.com/google/go-cmp/cmp/cmpopts" 28 28 "github.com/grafana/regexp" 29 - "github.com/kylelemons/godebug/pretty" 30 29 31 30 "github.com/sourcegraph/zoekt/query" 32 31 ) ··· 370 369 }) 371 370 } 372 371 373 - func TestAndSearch(t *testing.T) { 374 - b := testIndexBuilder(t, nil, 372 + func TestSearchStats(t *testing.T) { 373 + ctx := context.Background() 374 + searcher := searcherForTest(t, testIndexBuilder(t, nil, 375 375 Document{Name: "f1", Content: []byte("x banana y")}, 376 376 Document{Name: "f2", Content: []byte("x apple y")}, 377 377 Document{Name: "f3", Content: []byte("x banana apple y")}, 378 - // ---------------------------------------0123456789012345 378 + // -----------------------------------0123456789012345 379 + )) 380 + 381 + andQuery := query.NewAnd( 382 + &query.Substring{ 383 + Pattern: "banana", 384 + }, 385 + &query.Substring{ 386 + Pattern: "apple", 387 + }, 379 388 ) 380 389 381 390 t.Run("LineMatches", func(t *testing.T) { 382 - sres := searchForTest(t, b, query.NewAnd( 383 - &query.Substring{ 384 - Pattern: "banana", 385 - }, 386 - &query.Substring{ 387 - Pattern: "apple", 388 - }, 389 - )) 391 + sres, err := searcher.Search(ctx, andQuery, &SearchOptions{}) 392 + if err != nil { 393 + t.Fatal(err) 394 + } 390 395 matches := sres.Files 391 396 if len(matches) != 1 || len(matches[0].LineMatches) != 1 || len(matches[0].LineMatches[0].LineFragments) != 2 { 392 397 t.Fatalf("got %#v, want 1 match with 2 fragments", matches) ··· 395 400 if matches[0].LineMatches[0].LineFragments[0].Offset != 2 || matches[0].LineMatches[0].LineFragments[1].Offset != 9 { 396 401 t.Fatalf("got %#v, want offsets 2,9", matches) 397 402 } 398 - 399 - wantStats := Stats{ 400 - FilesLoaded: 1, 401 - ContentBytesLoaded: 18, 402 - IndexBytesLoaded: 8, 403 - NgramMatches: 3, // we look at doc 1, because it's max(0,1) due to AND 404 - MatchCount: 1, 405 - FileCount: 1, 406 - FilesConsidered: 2, 407 - ShardsScanned: 1, 408 - } 409 - if diff := pretty.Compare(wantStats, sres.Stats); diff != "" { 410 - t.Errorf("got stats diff %s", diff) 411 - } 412 403 }) 413 - 414 404 t.Run("ChunkMatches", func(t *testing.T) { 415 - sres := searchForTest(t, b, query.NewAnd( 416 - &query.Substring{ 417 - Pattern: "banana", 418 - }, 419 - &query.Substring{ 420 - Pattern: "apple", 421 - }, 422 - ), chunkOpts) 405 + sres, err := searcher.Search(ctx, andQuery, &chunkOpts) 406 + if err != nil { 407 + t.Fatal(err) 408 + } 423 409 matches := sres.Files 424 410 if len(matches) != 1 || len(matches[0].ChunkMatches) != 1 || len(matches[0].ChunkMatches[0].Ranges) != 2 { 425 411 t.Fatalf("got %#v, want 1 chunk match with 2 ranges", matches) ··· 428 414 if matches[0].ChunkMatches[0].Ranges[0].Start.ByteOffset != 2 || matches[0].ChunkMatches[0].Ranges[1].Start.ByteOffset != 9 { 429 415 t.Fatalf("got %#v, want offsets 2,9", matches) 430 416 } 417 + }) 418 + t.Run("Stats", func(t *testing.T) { 419 + cases := []struct { 420 + Name string 421 + Q query.Q 422 + Want Stats 423 + }{{ 424 + Name: "and-query", 425 + Q: andQuery, 426 + Want: Stats{ 427 + FilesLoaded: 1, 428 + ContentBytesLoaded: 18, 429 + IndexBytesLoaded: 8, 430 + NgramMatches: 3, // we look at doc 1, because it's max(0,1) due to AND 431 + NgramLookups: 104, 432 + MatchCount: 2, 433 + FileCount: 1, 434 + FilesConsidered: 2, 435 + ShardsScanned: 1, 436 + }, 437 + }, { 438 + Name: "one-trigram", 439 + Q: &query.Substring{ 440 + Pattern: "a y", 441 + Content: true, 442 + CaseSensitive: true, 443 + }, 444 + Want: Stats{ 445 + ContentBytesLoaded: 12, 446 + IndexBytesLoaded: 1, 447 + FileCount: 1, 448 + FilesConsidered: 1, 449 + FilesLoaded: 1, 450 + ShardsScanned: 1, 451 + MatchCount: 1, 452 + NgramMatches: 1, 453 + NgramLookups: 2, // once to lookup frequency then again to access posting list. 454 + }, 455 + }, { 456 + Name: "one-trigram-case-insensitive", 457 + Q: &query.Substring{ 458 + Pattern: "a y", 459 + Content: true, 460 + }, 461 + Want: Stats{ 462 + ContentBytesLoaded: 12, 463 + IndexBytesLoaded: 1, 464 + FileCount: 1, 465 + FilesConsidered: 1, 466 + FilesLoaded: 1, 467 + ShardsScanned: 1, 468 + MatchCount: 1, 469 + NgramMatches: 1, 470 + NgramLookups: 8, // "a y" has 2**2 casings which we lookup twice. 471 + }, 472 + }, { 473 + Name: "one-trigram-pruned", 474 + Q: &query.Substring{ 475 + Pattern: "foo", 476 + Content: true, 477 + CaseSensitive: true, 478 + }, 479 + Want: Stats{ 480 + ShardsSkippedFilter: 1, 481 + NgramLookups: 1, // only had to lookup once 482 + }, 483 + }, { 484 + Name: "one-trigram-branch-pruned", 485 + Q: query.NewAnd( 486 + &query.Substring{ 487 + Pattern: "foo", 488 + Content: true, 489 + CaseSensitive: true, 490 + }, 491 + &query.Substring{ 492 + Pattern: "a y", 493 + Content: true, 494 + CaseSensitive: true, 495 + }, 496 + ), 497 + Want: Stats{ 498 + IndexBytesLoaded: 1, // we created an iterator for "a y" before pruning. 499 + ShardsSkippedFilter: 1, 500 + NgramLookups: 3, // we lookedup "foo" once (1), but lookedup and created "a y" (2). 501 + }, 502 + }} 431 503 432 - wantStats := Stats{ 433 - FilesLoaded: 1, 434 - ContentBytesLoaded: 18, 435 - IndexBytesLoaded: 8, 436 - NgramMatches: 3, // we look at doc 1, because it's max(0,1) due to AND 437 - MatchCount: 2, 438 - FileCount: 1, 439 - FilesConsidered: 2, 440 - ShardsScanned: 1, 441 - } 442 - if diff := pretty.Compare(wantStats, sres.Stats); diff != "" { 443 - t.Errorf("got stats diff %s", diff) 504 + for _, tc := range cases { 505 + t.Run(tc.Name, func(t *testing.T) { 506 + sres, err := searcher.Search(ctx, tc.Q, &chunkOpts) 507 + if err != nil { 508 + t.Fatal(err) 509 + } 510 + if diff := cmp.Diff(tc.Want, sres.Stats); diff != "" { 511 + t.Errorf("unexpected Stats (-want +got):\n%s", diff) 512 + } 513 + }) 444 514 } 515 + 445 516 }) 446 517 } 447 518
+9 -2
indexdata.go
··· 389 389 // Find the 2 least common ngrams from the string. 390 390 ngramOffs := splitNGrams([]byte(query.Pattern)) 391 391 frequencies := make([]uint32, 0, len(ngramOffs)) 392 + ngramLookups := 0 392 393 for _, o := range ngramOffs { 393 394 var freq uint32 394 395 if query.CaseSensitive { 395 396 freq = d.ngramFrequency(o.ngram, query.FileName) 397 + ngramLookups++ 396 398 } else { 397 399 for _, v := range generateCaseNgrams(o.ngram) { 398 400 freq += d.ngramFrequency(v, query.FileName) 401 + ngramLookups++ 399 402 } 400 403 } 401 404 ··· 403 406 return &ngramIterationResults{ 404 407 matchIterator: &noMatchTree{ 405 408 Why: "freq=0", 409 + Stats: Stats{ 410 + NgramLookups: ngramLookups, 411 + }, 406 412 }, 407 413 }, nil 408 414 } ··· 419 425 firstNG := ngramOffs[firstI].ngram 420 426 lastNG := ngramOffs[lastI].ngram 421 427 iter := &ngramDocIterator{ 422 - leftPad: firstI, 423 - rightPad: uint32(utf8.RuneCountInString(str)) - firstI, 428 + leftPad: firstI, 429 + rightPad: uint32(utf8.RuneCountInString(str)) - firstI, 430 + ngramLookups: ngramLookups, 424 431 } 425 432 if query.FileName { 426 433 iter.ends = d.fileNameEndRunes
+12 -1
matchiter.go
··· 73 73 // noMatchTree is both matchIterator and matchTree that matches nothing. 74 74 type noMatchTree struct { 75 75 Why string 76 + 77 + // Stats captures the work done to create the noMatchTree. 78 + Stats Stats 76 79 } 77 80 78 81 func (t *noMatchTree) String() string { ··· 93 96 return false, true 94 97 } 95 98 96 - func (t *noMatchTree) updateStats(*Stats) {} 99 + func (t *noMatchTree) updateStats(s *Stats) { 100 + s.Add(t.Stats) 101 + t.Stats = Stats{} 102 + } 97 103 98 104 func (m *candidateMatch) String() string { 99 105 return fmt.Sprintf("%d:%d", m.file, m.runeOffset) ··· 105 111 106 112 iter hitIterator 107 113 ends []uint32 114 + 115 + // ngramLookups is how many lookups we did to create this iterator. 116 + ngramLookups int 108 117 109 118 // mutable 110 119 fileIdx uint32 ··· 154 163 func (i *ngramDocIterator) updateStats(s *Stats) { 155 164 i.iter.updateStats(s) 156 165 s.NgramMatches += i.matchCount 166 + s.NgramLookups += i.ngramLookups 157 167 i.matchCount = 0 168 + i.ngramLookups = 0 158 169 } 159 170 160 171 func (i *ngramDocIterator) candidates() []*candidateMatch {
+2 -2
matchtree.go
··· 963 963 if s.Value { 964 964 return &bruteForceMatchTree{}, nil 965 965 } else { 966 - return &noMatchTree{"const"}, nil 966 + return &noMatchTree{Why: "const"}, nil 967 967 } 968 968 case *query.Language: 969 969 code, ok := d.metaData.LanguageMap[s.Language] 970 970 if !ok { 971 - return &noMatchTree{"lang"}, nil 971 + return &noMatchTree{Why: "lang"}, nil 972 972 } 973 973 return &docMatchTree{ 974 974 reason: "language",
+5
shards/shards.go
··· 115 115 Name: "zoekt_search_ngram_matches_total", 116 116 Help: "Total number of candidate matches as a result of searching ngrams", 117 117 }) 118 + metricSearchNgramLookupsTotal = promauto.NewCounter(prometheus.CounterOpts{ 119 + Name: "zoekt_search_ngram_lookups_total", 120 + Help: "Total number of times we accessed an ngram in the index", 121 + }) 118 122 119 123 metricListRunning = promauto.NewGauge(prometheus.GaugeOpts{ 120 124 Name: "zoekt_list_running", ··· 821 825 metricSearchShardsSkippedTotal.Add(float64(sr.Stats.ShardsSkipped)) 822 826 metricSearchMatchCountTotal.Add(float64(sr.Stats.MatchCount)) 823 827 metricSearchNgramMatchesTotal.Add(float64(sr.Stats.NgramMatches)) 828 + metricSearchNgramLookupsTotal.Add(float64(sr.Stats.NgramLookups)) 824 829 } 825 830 826 831 func copySlice(src *[]byte) {