ConfigFactory::doLoadMultiple() calls getConfigCacheKey() for every requested name. That calls getCacheKeys(), which loops over all config override services and calls getCacheSuffix() on each of them. The suffix is the same for every name in that call.

On our site (language + domain config overrides) this shows up in profiles, as config gets loaded a lot per request.

Proposed fix: build the suffix once before the loop, and once more after loadOverrides() (an override can change its suffix while collecting overrides, the current code also builds the key after that). getConfigCacheKey() stays for other callers, the cache key format doesn't change.

Patch attached, I'll open an MR for it.

Issue fork drupal-3632305

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bceyssens created an issue. See original summary.

bceyssens’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs tests

Think before we change this we should show how it's a problem.

Summary is also incomplete, please use the summary template written in own words

bceyssens’s picture

Status: Needs work » Closed (won't fix)

This patch was an attempt to fix a performance issue on our site, written before we used AI tools. Measuring it now with AI tooling disproves it.

Measured on our site: Drupal 11.4.7, 37 languages, 34 domains, 5 config override services (language, domain_config, domain_language, config_split, key). Three anonymous page requests, warm caches, old and new doLoadMultiple() swapped in after kernel boot.

Per request:

  • doLoadMultiple(): ~2,700 calls with ~3,900 names in total. Most calls load one name.
  • getCacheKeys(): ~4,550 calls before, ~3,100 after (-1,450).
  • One getCacheKeys() call with these 5 overrides takes 0.16 µs.

That is about 0.25 ms per request on a 1.2-1.4 s page render. The total time in doLoadMultiple() (80-100 ms, mostly storage reads) varies more than that between runs. The change only helps loadMultiple() calls with many names; single-name get() calls build the suffix the same number of times.

Closing this, the saving is about 0.02% of the request. We drop the patch on our side.

Generated with the help of an LLM.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.