Migration Analysis: Projects::BranchesController#index

~Conversation: #217 (closed)

Related to: https://gitlab.com/gitlab-org/gitlab-ce/issues/27379


Goal: perform a migration analysis on the Projects::BranchesController#index controller in GitLab-Rails.

Reference: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/controllers/projects/branches_controller.rb#L10

TODO

  • Investigate required changes in gitlab-rails

    • According to graphana's WALL time chart shows that the most time consuming operations involve Repository#branches_sorted_by. Running a profiling on that action when sorting gives the following data:

Captura_de_pantalla_2017-03-14_a_las_22.41.17

We can see we spend most of the time within Rugged::BranchCollection#each, and decorating each of these references to create Gitlab::Git::Branch objects. It may be because I worked on optimizing this code before (😉) but this doesn't feel like it should be taking so long, other than the general reason of "git access is hitting hard the file system". In any, we should Migrate local_branches to gitaly allowing them to be sorted. This response should include all the necessary data to create the Gitlab::Git::Branch object, including the Gitlab::Git::Commit object for the head reference. This will allow us to sort and condense all the data in one operation, which even without caching should help speed this action.

/cc @andrewn @jacobvosmaer-gitlab

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information