Projects::TreeController#show Gitaly migration
Investigate moving git functionality in the Projects::TreeController#show
endpoint to Gitaly.
Information
- Method Call Wall Time Charts
- Associated issue in
gitlab-ce
: Projects::TreeController#show is slow because of multiple things: https://gitlab.com/gitlab-org/gitlab-ce/issues/27158
TODO
-
Investigate required changes in gitlab-rails
- According to graphana's WALL time chart, instantiating the repository is the slowest Rugged operation in this action. This is done for all project actions in a
before_action :repository
onapp/controllers/projects/application_controller.rb
. This means that even for non-repository related project actions, such as Edit Project, the git repository is loaded into memory. There seems to be an actual reason for this: just to render theGraphs
tab in the UI menu there's a call to@repository.try(:root_ref)
. Migrate root_ref to Gitaly and remove the instantiation of a Rugged repository as a before_action on Project controllers. This should have a positive performance effect on many project actions across the board. We will have to check change@repository
access in these controllers that are expecting the variable to be instantiated to use the attr_accessorrepository
. - With the previous point as a precondition, remove the initialization of the Rugged repository in this action once all operations used in this action are migrated to gitaly.
- The next slowest Rugged operation is
Repository#tag_names
. The source of this was not clear to me from the beginning, so I ran a profiling on the action. The relevant part is:
- According to graphana's WALL time chart, instantiating the repository is the slowest Rugged operation in this action. This is done for all project actions in a
So, the source is lib/extracts_path.rb
's method extract_ref
, which is the one that in a path like foo/bar/baz/my.file
determines that foo/bar
is the branch name and baz/my.file
is the file path (for example). It does this through Repository#ref_names
by iterating through branch_names + tag_names
. Repository#tag_names
, the biggest offender, spends most of its time running Rugged::TagCollection#each
. So we should implement ref_names in Gitaly.
-
Implement required changes in gitaly
MR to follow-
Implement GRPC call SmartHTTP#root_ref -
Implement GRPC call SmartHTTP#ref_names. This probably means we can implement SmartHTTP#tag_names and SmartHTTP#branch_names at the same time.
-
-
Implement required changes in gitlab-rails
MR to follow