Skip to content

Speed up the BlameController: view part

Aleksei Lipniagov requested to merge 217572-make-blame-view-faster into master

What does this MR do?

An attempt to speed up the BlameController.

I found the view code was the biggest offender when I started to profile it locally.

The main idea of the fix is to avoid calculating the same values multiple times (e.g links to sprites), which is very expensive for such a huge page (see the first flamegraph).

On my local env, TTFB reduced from ~40s to ~13s on http://127.0.0.1:3000/root/imported/-/blame/master/locale/gitlab.pot (gitlabhq).

It still slow and could be optimized further, but this small change looks like low hanging fruit™ to me (it's a good start).

What have changed

  • Move blame_group render into partial (to reduce the complexity of the original view, don't affect performance)
  • Cache sprite_icon and icon calls - they are the same for every commit inside every blame, it was a huge issue (see the flame graph screenshot).
  • Another observation: on gitlabhq, for the locale/gitlab.pot page, we had ~9600 blame_groups, having only ~1000 unique commits in them. That means we could cache everything item generated for each commit (e.g. links).

Screenshots

Flamegraph (view code only) from the master:

Notice 18s (!) being spent in IconsHelper 🙂

Screenshot_2020-05-28_at_14.56.34

--

After moving per-commit precalculation to the presenter (Stackprof wrapped around controller this time, as views are rather trivial now, at least compared with what was before):

Screenshot_2020-06-01_at_19.28.38

stackprof-controller-4.json

--

After moving per-commit precalculation to the presenter (Stackprof wrapped around the view):

Screenshot_2020-06-01_at_19.07.42

stackprof-view-2.json

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

N/A

Security

N/A

Related #217572 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports