Faster ReposourceCloneURLToRepoName
Created by: ryanslade
We noticed that on sourcegraph.com running ReposourceCloneURLToRepoName could be very slow, often take more than 3 seconds to return.
There were two problems:
- We fetch up to 500 external services at a time
- For each service, we need to decrypt config which makes an API call taking around 7m. These were run in sequence.
This PR improves the performance in four ways:
- As a fast path, should be able to get the repo name from
external_service_repos
table in a simple query if we already have the repo cloned. - If that fails, we first try our
cloud_default
external services as they'll match the majority of repos. - We fetch in smaller batches
- We make the API calls to decrypt in parallel.
Found while investigating https://github.com/sourcegraph/sourcegraph/issues/23775