Improve performance of diffs_batch and diffs_metadata actions for Projects::MergeRequestsController
requested to merge 209786-improve-performance-of-diffs_batch-diffs-metadata-source-branch-exists into master
What does this MR do?
Related to: #209786 (closed)
Looking at performance bar, I noticed that there is one main redis calls slowing down the serialisation, it is when we are checking if the source_branch_exists?
. In general this is fast, but with it hitting the redis cache so much, it can be slow. Rather, we can memoize it and stop hitting up redis as much during serialisation.
Here are some stats from local environment for a large MR:
Looking at a locally run performance test here, we can see a good improvement:
Before
✓ { endpoint:diffs_batch.json }......: avg=1345.24ms min=1038.25ms med=1308.69ms max=1759.87ms p(90)=1550.95ms p(95)=1596.76ms
✓ { endpoint:diffs_metadata.json }...: avg=950.18ms min=772.55ms med=857.19ms max=1160.85ms p(90)=1150.37ms p(95)=1155.61ms
After
✓ { endpoint:diffs_batch.json }......: avg=773.41ms min=588.55ms med=769.17ms max=870.73ms p(90)=858.22ms p(95)=867.22ms
✓ { endpoint:diffs_metadata.json }...: avg=732.20ms min=608.33ms med=737.25ms max=827.33ms p(90)=815.88ms p(95)=821.60ms
Screenshots
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
Edited by Marc Shaw