N + 1: CommitDelta for large pushes
Problem
The Git hooks timings are mostly spend on calling the internal/allowed
API, to verify Gitaly should accept a push. This happens before the client sends data, and creates the pause between calling git push origin HEAD
and standard counters output. This API call from Gitaly to Rails can be very slow:
Investigating further, I found instances where the API call results in over 300 CommitDelta RPC calls back to Gitaly. This is the case, as GitAccess#check_change_access!
will iterate over each branch that changed. For each of these, it will call check_single_change_access
which in turn will perform a GitLab::Checks::DiffCheck#validate!
. This seems to be the culprit of over 500 RPC calls at GitLab.com.
Proposal
Replace the CommitDelta RPC with DiffStats
Edited by Daniel Gruesso