GinSettings should use static caching

Created on 25 December 2023, 12 months ago
Updated 27 January 2024, 11 months ago

Problem/Motivation

When loading a form with a lot of fields, the hook `gin_preprocess_form_element` is called for each element. For each call to this hook, the GinDescriptionToggle class calls the GinSettings get method which leads to a DB lookup of the user_data table. While this query isn't expensive, we shouldn't need to repeat it for each field in the form.

Steps to reproduce

Profile some pages with gin forms

Proposed resolution

We could use a static cache in Gin Settings to reuse values already fetched

Remaining tasks

This code could be improved upon, it seems the new way loads all the settings from one DB call, potentially we could statically cache all those values at once. I didn't fully grok the fallback legacy stuff, so I played it safe with the way the first patch works.

Feature request
Status

Needs review

Component

Code

Created by

🇦🇺Australia Jon Nunan

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024