Commit 8a9fc2b6 authored by Stan Hu's avatar Stan Hu

Cache the commit author in RequestStore to avoid extra lookups in PostReceive

In a PostReceive task with 697 commits (8.9 RC1 -> RC8), looking up
the commit author takes about 10% of the time. Caching this information
in RequestStore saves a few seconds from the overall processing time.

Improves #18663
parent 95efb6f1
...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased) v 8.11.0 (unreleased)
- Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell) - Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
- Fix CI status icon link underline (ClemMakesApps) - Fix CI status icon link underline (ClemMakesApps)
- Cache the commit author in RequestStore to avoid extra lookups in PostReceive
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI' - Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable - Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable
- Limit git rev-list output count to one in forced push check - Limit git rev-list output count to one in forced push check
......
...@@ -178,7 +178,14 @@ class Commit ...@@ -178,7 +178,14 @@ class Commit
end end
def author def author
@author ||= User.find_by_any_email(author_email.downcase) key = "commit_author:#{author_email}"
# nil is a valid value since no author may exist in the system
unless RequestStore.store.has_key?(key)
RequestStore.store[key] = User.find_by_any_email(author_email.downcase)
end
@author ||= RequestStore.store[key]
end end
def committer def committer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment