Skip to content
Snippets Groups Projects

search: share default repos cache between requests

Closed Warren Gifford requested to merge k/default-repos-cache into main

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:

image

Merge request reports

Closed by avatar (Jul 12, 2025 5:03pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 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.go
  • Created 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.

Please register or sign in to reply
Loading