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.
| Comment | File | Size | Author |
|---|---|---|---|
| core-config-factory-hoist-cache-key-suffix.patch | 1.37 KB | bceyssens |
Issue fork drupal-3632305
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
Comment #3
bceyssensComment #4
smustgrave commentedThink 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
Comment #5
bceyssensThis 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:
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.