n+1 on Gitlab::Checks::ChangeAccess#push_rule_check [EE only]: /api/:version/internal/allowed

This code on gitlab EE has two one n+1 issues:

  • commits is the result of project.repository.new_commits(@newrev), which does the following:
       refs = ::Gitlab::Git::RevList.new(
       path_to_repo: path_to_repo,
       newrev: newrev).new_refs

      refs.map { |sha| commit(sha.strip) }

So there will be a call to CommitService.FindCommit for each new commit in a push.

  • check_commit_diff calls commit.raw_deltas, which will fire a DiffService.CommitDelta for each new commit in a push.

/cc @andrewn

Edited by Stan Hu