summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-04-07 20:55:29 -0700
committerStan Hu <stanhu@gmail.com>2019-04-07 20:59:40 -0700
commit021e8790c6091994d3b3e31cbf180939608698da (patch)
tree602bb33ff1616e3c45b79a1f3b4e738a3529a17e
parentb4165554113a7f9ce9fecd7d169f9a64686b5c44 (diff)
downloadgitlab-ce-021e8790c6091994d3b3e31cbf180939608698da.tar.gz
Enable Gitaly FindCommit caching for TreeControllersh-add-gitaly-ref-name-caching-tree-controller
Accessing /namespace/project/tree/master appears to query FindCommit 5 times with identical parameters. This reduces the number of FindCommit queries to 1.
-rw-r--r--app/controllers/projects/tree_controller.rb2
-rw-r--r--changelogs/unreleased/sh-add-gitaly-ref-name-caching-tree-controller.yml5
-rw-r--r--spec/controllers/projects/tree_controller_spec.rb2
3 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index 90d53aa08ea..7509cc29a76 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -6,6 +6,8 @@ class Projects::TreeController < Projects::ApplicationController
include CreatesCommit
include ActionView::Helpers::SanitizeHelper
+ around_action :allow_gitaly_ref_name_caching, only: [:show]
+
before_action :require_non_empty_project, except: [:new, :create]
before_action :assign_ref_vars
before_action :assign_dir_vars, only: [:create_dir]
diff --git a/changelogs/unreleased/sh-add-gitaly-ref-name-caching-tree-controller.yml b/changelogs/unreleased/sh-add-gitaly-ref-name-caching-tree-controller.yml
new file mode 100644
index 00000000000..a051c1f70a8
--- /dev/null
+++ b/changelogs/unreleased/sh-add-gitaly-ref-name-caching-tree-controller.yml
@@ -0,0 +1,5 @@
+---
+title: Enable Gitaly FindCommit caching for TreeController
+merge_request: 27100
+author:
+type: performance
diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb
index b15a2bc84a5..78201498eaa 100644
--- a/spec/controllers/projects/tree_controller_spec.rb
+++ b/spec/controllers/projects/tree_controller_spec.rb
@@ -16,6 +16,8 @@ describe Projects::TreeController do
render_views
before do
+ expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
+
get(:show,
params: {
namespace_id: project.namespace.to_param,