search: share default repos cache between requests
Created by: keegancsmith
In https://github.com/sourcegraph/sourcegraph/pull/18933 we accidently created a new DefaultRepos store on every request. This lead to the cache being recreated on every request => no caching. In practice this increased all global queries on sourcegraph.com by about 3s. This commit adds back the global caching.
Additionally I took the liberty clean up DefaultRepos. I'm not sure why, but it is part of the database package. However, it doesn't directly interact with the database, it interacts with the repos store. So I extracted the caching logic out into a search specific repos package. The effect is we no longer have a DefaultRepos store. Instead we just have a Repos store and a structure which can cache the response of Repos.ListDefault.
See below for regression on one of our continuous queries on sourcegraph.com:
Merge request reports
Activity
Created by: sourcegraph-bot
Notifying subscribers in CODENOTIFY files for diff 79b7780a76bf93d4f153b3e5657013ca6f820d06...ee6b03a3cc1afb766758d4604164ad912a2778b3.
Notify File(s) @LawnGnome internal/database/repos_db_test.go @asdine internal/database/repos_db_test.go @eseliger internal/database/repos_db_test.go @rvantonder cmd/frontend/graphqlbackend/search.go
cmd/frontend/graphqlbackend/search_alert.goCreated by: keegancsmith
By moving the caching out of the store, I broke other uses of DefaultRepos. Will take a little longer to fix, so I created this alternative tiny PR to just fix the perf regression !19168 (merged) Will follow up on this PR soon.