`GitAccess` iterates over all pushed commits for all pushed branches even if no push rules are going to be run
From https://gitlab.zendesk.com/agent/tickets/90556 / https://gitlab.slack.com/archives/C4Y5DRKLK/p1518732760000212, where a customer saw an initial push to a new project with over 9000 branches time out.
The problem, or at least one of the problems, seems to be that GitAccess
calls Checks::ChangeAccess#exec
for each pushed ref, which calls project.repository.new_commits(newrev)
to get all commit shas (git rev-list <newrev> --not --all
), then looks up every single commit individually using Repository#commit
, and calls Gitlab::Checks::CommitCheck#validate
for each of them, which returns early immediately because they don’t have any push rules set up. We should be able to skip all of these expensive rev-list
s and commit lookups if we see that we won’t actually run any validations.
Even if we get rid of that, 9000 branches are a lot of branches to process at once. If we take even 10ms per branch, we will hit the 60s timeout, so fixing this issue may not yet solve the problem entirely.
/cc @stanhu @dblessing