Improve BlobController show.json performance: cache method calls
What does this MR do?
A (possible) set of "low hanging fruit improvements".
I mostly tested it on gitlabhq/-/blob/master/CHANGELOG.md
locally, as I found it to be "appropriately" slow to work from there. It takes ~40 seconds locally.
Project.markdown_reference_pattern
repeated call?
1. Avoid Looking into the flame graph, it would allow us to save ~3 seconds, as it is called in the cycle:
After caching the value, we see that Banzai::Filter::ProjectReferenceFilter#call
is faster now:
User.reference_pattern
2. The same is for (check the screenshot above)
Maybe we should deal with class methods that only generate strings through all the codebase?
Seems that we have quite a few of those, especially regexes.
It could be caching or moving them into const.
We could also create a rubocop's cop which checks that.
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
N/A
Security
N/A
Related to #217580 (closed)
Edited by Sean Carroll