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

Configure Feed

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

shards: use selectRepoSet in List (#749)

Currently we have unindexed search asking Zoekt what commit it has for a
very specific repository. In normal search we use selectRepoSet to avoid
searching shards which are unrelated to the query. This uses the same
optimization in List.

Test Plan: go test

+25 -12
+25 -12
shards/shards.go
··· 919 919 tr.LazyPrintf("acquired process") 920 920 921 921 loaded := ss.getLoaded() 922 - shards := loaded.shards 922 + 923 + // Setup what we return now, since we may short circuit if there are no 924 + // shards to search. 925 + stillLoadingCrashes := 0 926 + if !loaded.ready { 927 + // We may have missed results due to not being fully loaded. 928 + stillLoadingCrashes++ 929 + } 930 + agg := zoekt.RepoList{ 931 + Crashes: stillLoadingCrashes, 932 + ReposMap: zoekt.ReposMap{}, 933 + Repos: []*zoekt.RepoListEntry{}, 934 + } 935 + 936 + // PERF: Select the subset of shards that we will search over for the given 937 + // query. A common List query only asks for a specific repo, so this is an 938 + // important optimization. 939 + tr.LazyPrintf("before selectRepoSet shards:%d", len(loaded.shards)) 940 + shards, r := selectRepoSet(loaded.shards, r) 941 + tr.LazyPrintf("after selectRepoSet shards:%d %s", len(shards), r) 942 + 943 + if len(shards) == 0 { 944 + return &agg, nil 945 + } 946 + 923 947 shardCount := len(shards) 924 948 all := make(chan shardListResult, shardCount) 925 949 tr.LazyPrintf("shardCount: %d", len(shards)) ··· 936 960 listOneShard(ctx, s, r, opts, all) 937 961 } 938 962 }() 939 - } 940 - 941 - stillLoadingCrashes := 0 942 - if !loaded.ready { 943 - // We may have missed results due to not being fully loaded. 944 - stillLoadingCrashes++ 945 - } 946 - 947 - agg := zoekt.RepoList{ 948 - Crashes: stillLoadingCrashes, 949 - ReposMap: zoekt.ReposMap{}, 950 963 } 951 964 952 965 uniq := map[string]*zoekt.RepoListEntry{}