summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-20 21:49:14 -0700
committerStan Hu <stanhu@gmail.com>2019-06-21 01:57:58 -0700
commit656ec23bd50197bd736596e56483d7c863db3af4 (patch)
tree976cc5bc1af8b26978f57d8159519b3672322de8 /app/models/commit.rb
parent9f07114618f957941953d0374fa43ab010a8ec9f (diff)
downloadgitlab-ce-sh-test-branch-push-2.tar.gz
Speed up MR widget by disabling BatchLoader replace_methodssh-test-branch-push-2
We've seen a significant performance penalty when using `BatchLoader#__replace_with!`. This defines methods on the batch loader that proxy to the 'real' object using send. The alternative is `method_missing`, which is slower. However, we've noticed that `method_missing` can be faster if: 1. The objects being loaded have a large interface. 2. We don't call too many methods on the loaded object. In production, we've observed a small percentage of time used in Module#define_methods as a result of the BatchLoader. Disabling this for ActiveRecord models is generally a good thing to do since there are so many methods.
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index be37fa2e76f..3723e4e8fd6 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -229,7 +229,7 @@ class Commit
end
def lazy_author
- BatchLoader.for(author_email.downcase).batch do |emails, loader|
+ BatchLoader.for(author_email.downcase).batch(replace_methods: false) do |emails, loader|
users = User.by_any_email(emails).includes(:emails)
emails.each do |email|