Cache the commit author in RequestStore to avoid extra lookups in PostReceive
1 unresolved thread
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 (moved)
Merge request reports
Activity
Reassigned to @stanhu
Reassigned to @yorickpeterse
178 178 end 179 179 180 180 def author 181 @author ||= User.find_by_any_email(author_email.downcase) 181 if RequestStore.active? 182 key = "commit_author:#{author_email.downcase}" 183 # nil is a valid value since no author may exist in the system 184 if RequestStore.store.has_key?(key) 185 @author = RequestStore.store[key] 186 else 187 @author = find_author_by_any_email 188 RequestStore.store[key] = @author 189 end @stanhu Doesn't
@author = RequestStore.store[key] ||= find_author_by_any_email
work just as well (while being less verbose)?Edited by yorickpeterse-staging@stanhu Ah, gotcha.
mentioned in commit 9b0e131b
mentioned in merge request gitlab-com/www-gitlab-com!2910 (merged)
Please register or sign in to reply