summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-06-13 22:45:44 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-06-13 22:45:44 +0000
commitd8b361aff274e4b9c010a483add693af15b51371 (patch)
tree2267dcadc24c80d0eaa9c6aa7495f210d574a968
parent13fe5b0d3644f8ace47343b96bc1ba32138f8ecb (diff)
parent18020f00f880fd849800624e08e87d0a5aa5111f (diff)
downloadgitlab-ce-d8b361aff274e4b9c010a483add693af15b51371.tar.gz
Merge branch 'sh-speed-up-commit-loading' into 'master'
Speed up commit loads by disabling BatchLoader replace_methods See merge request gitlab-org/gitlab-ce!29633
-rw-r--r--app/models/commit.rb2
-rw-r--r--changelogs/unreleased/sh-speed-up-commit-loading.yml5
-rw-r--r--spec/models/commit_spec.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index fa0bf36ba49..be37fa2e76f 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -94,7 +94,7 @@ class Commit
end
def lazy(project, oid)
- BatchLoader.for({ project: project, oid: oid }).batch do |items, loader|
+ BatchLoader.for({ project: project, oid: oid }).batch(replace_methods: false) do |items, loader|
items_by_project = items.group_by { |i| i[:project] }
items_by_project.each do |project, commit_ids|
diff --git a/changelogs/unreleased/sh-speed-up-commit-loading.yml b/changelogs/unreleased/sh-speed-up-commit-loading.yml
new file mode 100644
index 00000000000..db408708385
--- /dev/null
+++ b/changelogs/unreleased/sh-speed-up-commit-loading.yml
@@ -0,0 +1,5 @@
+---
+title: Speed up commit loads by disabling BatchLoader replace_methods
+merge_request: 29633
+author:
+type: performance
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 14f4b4d692f..e76186fb280 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -44,6 +44,14 @@ describe Commit do
expect(commit.id).to eq(oids[i])
end
end
+
+ it 'does not attempt to replace methods via BatchLoader' do
+ subject.each do |commit|
+ expect(commit).to receive(:method_missing).and_call_original
+
+ commit.id
+ end
+ end
end
context 'when not found' do