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
:
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:
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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