Gitaly N+1 queries in ProjectsController due to submodule links

As seen in https://log.gitlab.net/goto/e5722bbc67a44c35e0c2576502b27465, a large number of these appear to be GetTreeEntry RPCs for submodules:

[
  "lib/gitlab/gitaly_client.rb:146:in `call'",
  "lib/gitlab/gitaly_client/commit_service.rb:95:in `tree_entry'",
  "lib/gitlab/git/repository.rb:1095:in `gitaly_submodule_url_for'",
  "lib/gitlab/git/repository.rb:488:in `block in submodule_url_for'",
  "lib/gitlab/git/wraps_gitaly_errors.rb:7:in `wrapped_gitaly_errors'",
  "lib/gitlab/git/repository.rb:487:in `submodule_url_for'",
  "app/models/repository.rb:489:in `method_missing'",
  "app/helpers/submodule_helper.rb:10:in `submodule_links'",
  "app/helpers/diff_helper.rb:101:in `submodule_link'",
  "app/views/projects/tree/_tree_row.html.haml:21:in `_app_views_projects_tree__tree_row_html_haml___3867303424109623138_70287421436300'",
  "app/helpers/tree_helper.rb:23:in `render_tree'",
  "app/views/projects/tree/_tree_content.html.haml:17:in `_app_views_projects_tree__tree_content_html_haml__242411605973858056_70287420975120'",
  "app/views/projects/_files.html.haml:27:in `_app_views_projects__files_html_haml___2461648533685267167_70287140734600'",
  "app/views/projects/show.html.haml:33:in `_app_views_projects_show_html_haml___1730479539865010155_70287436853040'",
  "app/controllers/application_controller.rb:108:in `render'",
  "app/controllers/application_controller.rb:533:in `block in allow_gitaly_ref_name_caching'",
  "lib/gitlab/gitaly_client.rb:314:in `allow_ref_name_caching'",
  "app/controllers/application_controller.rb:532:in `allow_gitaly_ref_name_caching'",
  "ee/lib/gitlab/ip_address_state.rb:10:in `with'",
  "ee/app/controllers/ee/application_controller.rb:43:in `set_current_ip_address'",
  "lib/gitlab/session.rb:11:in `with_session'",
  "app/controllers/application_controller.rb:450:in `set_session_storage'",
  "app/controllers/application_controller.rb:444:in `set_locale'",
  "ee/lib/omni_auth/strategies/group_saml.rb:41:in `other_phase'",
  "ee/lib/gitlab/jira/middleware.rb:19:in `call'"
]
Assignee Loading
Time tracking Loading