Drupal Version
Drupal 9
Domain module version
8.x-1.0-beta6
Expected Behavior
The number of request while loading a page after a cache clear should be increased only by the number of existing configuration overrides.
Actual Behavior
On a Drupal 8 project using Redis, after a cache flush, the total number of requests sent to the database to display a page was about 1000 requests of which about half were related to Domain Config and more precisely to DomainConfigOverrider::loadOverrides().
After the switch to Drupal 9, this number of requests after a cache clear increases to 3000 and DomainConfigOverrider::loadOverrides() triggers 2500 requests out of these 3000.
From what I understand, the problem is that in version D8 Domain Config only made a request to retrieve a config override if it actually existed.
After the switch to D9, Domain Config makes a request for all the configurations of the site.
For information I tested version 1.0-beta6 on Drupal 8 and I have 1000 requests and with the same version on Drupal 9 I have 3000 requests.
So certainly something has changed in the core of Drupal between version 8 and version 9 that explains this behavior.
Steps to reproduce
Here the steps on a fresh install without using Redis for a more easy way to reproduce :
- Install Drupal without Domain Config
- Clear all cache
- Display a page
- Using a tool like xhprof see that the number of request is ~1659
- Enable domain config and domain config ui
- Create a domain
- Go to Configuration > System > Basic site settings
- Clear all cache
- Display a page
- See that the number of requests is now ~2700
and override the configuration for the domain created above
I also attached a screenshot of comparison using xhprof.
Proposed resolution
Check that the configuration override exists before to request the database to load it.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 3272841-15.patch | 1.5 KB | agentrickard |
| #12 | interdiff_11_12.txt | 876 bytes | nixou |
| #12 | 3272841-12.patch | 1.21 KB | nixou |
Comments
Comment #2
nixou commentedComment #3
nixou commentedComment #4
nixou commentedComment #5
nixou commentedComment #6
nixou commentedComment #7
nixou commentedComment #8
nixou commentedComment #9
nixou commentedComment #10
nixou commentedComment #11
nixou commentedComment #12
nixou commentedComment #13
nixou commentedTests ok against 9.2.x (since Domain Source is not compatible with Drupal 9.3 but not relevant to this issue).
Some additional metrics on Drupal 9.3.9 - Fresh install - Minimal profile - Homepage display after clear cache :
Without Redis
With Redis
Comment #14
agentrickardNice.
We do like to use the `true` flag on `in_array`.
e.g.
https://www.php.net/manual/en/function.in-array.php
Comment #15
agentrickardMinor update.
Comment #16
agentrickardComment #18
agentrickardCommitted! (Though not really a bug,)