Remove superfluous Repository#exists? calls
As noted in gitlab-com/gl-infra/production#936 (comment 187992797) , Repository#exists?
is a very-frequently-called Gitaly RPC. Since we cache positive values, it is also a very commonly called Redis cache item.
Very often, we twin Repository#exists?
with other calls that make it superfluous - Repository#has_visible_content?
being a prime example, but I'm sure there are others.
We should search for sites where this is the case and see if we can reduce the frequency with which this particular RPC/cached value is requested. Each individual call is cheap, but it adds up!
We could also consider moving this knowledge to the database. If we create a row in the project_repositories
table (say) only when we've had a positive response to the CreateRepository
RPC, and remove it when we remove the repo, we can just assume the repo is there and not bother to check with gitaly most of the time. This will cause 500 errors in various places, instead of 400 errors, in cases where a repository goes missing unexpectedly, but I don't think that's a bad thing.