Project

General

Profile

Actions

Defect #44412

open

Themes with custom icons.svg slow down page rendering

Added by Go MAEDA about 8 hours ago. Updated about 6 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Performance
Resolution:
Affected version:

Description

When the current theme provides its own icons.svg using the feature introduced in #43087, sprite_source calls Theme#icons for every icon rendered. Each call fetches the list of icon names from ActionController::Base.cache_store, which is costly when repeated for every icon. With the default file store, one fetch costs about 340 µs in my development environment.

I measured the time spent in these lookups with a third-party theme under the following conditions:

Page Rendered icons Without icons.svg With icons.svg With icons.svg and patch
Typical page (issue list, project settings, etc.) 20-65 ~0 ms 10-20 ms < 1 ms
Issue page with 30 journals and 30 attachments ~370 ~0.2 ms ~120 ms ~5 ms

Themes without their own icons.svg are not affected because Theme#icons returns before accessing the cache store.

The attached patch replaces the cache-store lookup with memoization in the Theme object, keyed by the asset digest so that changes to the sprite file are still picked up. Theme objects are shared by all requests in the process, so the memoized names remain available for the lifetime of the process.

The main benefit of keeping the cache store would be that a shared cache can avoid parsing the sprite separately in each process. However, parsing is needed only once per process and takes less than 0.4 ms in my development environment. The memoized icon-name list is also small, so removing the cache store has no significant downside.


Files

Actions

Also available in: Atom PDF