Skip to content

Lazy load commit date and authored date

The Repository File Blame API has been found to perform notably badly.

I have analyzed backend with StackProf. I used the generated file (using this script) with 10.000 commits.

Here are some details that I found in the flamegraph:

Screenshot_at_Jun_05_17-54-37

Method init_date_from_gittaly looks like a good candidate to optimize. Total time that this method takes for execution is 5.30 seconds where total time to this block was 6.60s.

It is used to calculate: authored_date and committed_date on Git::Commit initialization by init_from_gittaly.

Since it includes Time.zone calculation, this can be expensive.

What does this MR do?

This MR extract and lazy load authored_date and committed_date.

With this change the flame graph looks promising:

Screenshot_at_Jun_05_17-52-52

Method init_from_gittaly now takes only 70ms.

Gitlab::Blame.groups call now takes 1.24s instead of 5.61s.

branch Gitlab::Blame.groups (s) init_from_gittaly
master 5.61s 2.21s
lazy_load_authored_date_and_commited_date 1.24s 0.70

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #217570

Edited by 🤖 GitLab Bot 🤖

Merge request reports