Refactor #33935
Speed up settings index page
Description
Currently, loading the settings page with a few plugins installed leads to ~150k allocations on my machine and around 100ms to render settings/index.html.erb even with all caches "warm" (i.e. the registry is loaded, all locales have been loaded etc.). Let's try to speed it up a bit.
Associated revisions
History
#1
Updated by The Foreman Bot over 1 year ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/8927 added
#2
Updated by The Foreman Bot over 1 year ago
- Fixed in Releases 3.2.0 added
#3
Updated by Tomer Brisker over 1 year ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|64ceeac989db073b744c05ad6b26cb063fe656dd.
#4
Updated by The Foreman Bot over 1 year ago
- Fixed in Releases 3.1.1 added
#5
Updated by Amit Upadhye over 1 year ago
- Fixed in Releases 3.1.0 added
- Fixed in Releases deleted (
3.1.1)
Fixes #33935 - Cache setting categories
Every call to `@settings.category` in the index page recalculates all
the category names and labels by iterating over all settings. Since the
categories can't change in runtime, we can calculate it once and store
the list on the settings registry. We can also get the label once per
category instead of repeating it again for every setting. On my
instance, this led to a reduction of about 50k allocations and 20ms.
There are definitly more areas for improvements. Most of the remaining
allocations come from the `grouped_settings` helper, and specifically
inside the `setting.select_values` calculation.